Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared-state mesh information packages async implmentation and reference state #1112

Merged
merged 47 commits into from
Aug 28, 2024

Conversation

javierbrk
Copy link
Collaborator

No description provided.

@G10h4ck G10h4ck added this to the mesh-wide milestone Jun 20, 2024
@G10h4ck G10h4ck changed the title Shared-state mesh information pacakeges async implmentation and refference state Shared-state mesh information packages async implmentation and reference state Jun 20, 2024
Copy link
Member

@G10h4ck G10h4ck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline comments.
Also please double check reference state data folder is persisted across firmware ugrades. The behaviour should be that it get lost if sysupgrade -n is used while it should be kept if plain sysupgrade is used. AFAIR file or folders that need to be kept accross upgrades need to be added in a list somewhere. Same goes for safe-upgrade.

uci set shared-state.babel_links_info=dataType
uci set shared-state.babel_links_info.name='babel_links_info'
uci set shared-state.babel_links_info.scope='community'
uci set shared-state.babel_links_info.ttl='2400'
uci set shared-state.babel_links_info.update_interval='30'
uci commit shared-state

## Refference state data type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sobra una f ;-)

@@ -0,0 +1 @@
""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an empty JSON file by default? In that case is more traditional to use an empty object {} instead of an empty string ;-) also we could use .json extension to make things more explicit, if it doesn't make things much more complex

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes ! that was the first attempt, but when jsonc parses the text and then transforms it back to text, it creates an empty array, not an empty json object. For me it can be a bug. ..

JSON = require("luci.jsonc")
print(JSON.stringify(JSON.parse("{}")))        
[]

the documentation states that "Lua tables are converted into JSON arrays if they only contain integer keys, mixed tables are turned into JSON objects with any existing numeric keys converted into strings."

@@ -0,0 +1 @@
""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as packages/shared-state-babel_links_info/files/etc/shared-state/ref_state/babel_links_info_ref

uci set shared-state.bat_links_info=dataType
uci set shared-state.bat_links_info.name='bat_links_info'
uci set shared-state.bat_links_info.scope='community'
uci set shared-state.bat_links_info.ttl='2400'
uci set shared-state.bat_links_info.update_interval='30'
uci commit shared-state

## Refference state data type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sobra una f aqui tambien ;-)

@@ -0,0 +1 @@
""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as packages/shared-state-babel_links_info/files/etc/shared-state/ref_state/babel_links_info_ref

uci set shared-state.node_info_ref.name='node_info_ref'
uci set shared-state.node_info_ref.scope='community'
uci set shared-state.node_info_ref.ttl='2400'
uci set shared-state.node_info_ref.update_interval='50'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a new line at the end of the file

uci set shared-state.node_info.update_interval='33'
uci commit shared-state

## Refference state data type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sobra una f ;-)

@@ -0,0 +1 @@
""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as packages/shared-state-babel_links_info/files/etc/shared-state/ref_state/babel_links_info_ref

uci set shared-state.wifi_links_info_ref.name='wifi_links_info_ref'
uci set shared-state.wifi_links_info_ref.scope='community'
uci set shared-state.wifi_links_info_ref.ttl='2400'
uci set shared-state.wifi_links_info_ref.update_interval='50'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line missing

@javierbrk javierbrk marked this pull request as ready for review June 25, 2024 19:49
@javierbrk
Copy link
Collaborator Author

See inline comments. Also please double check reference state data folder is persisted across firmware ugrades. The behaviour should be that it get lost if sysupgrade -n is used while it should be kept if plain sysupgrade is used. AFAIR file or folders that need to be kept accross upgrades need to be added in a list somewhere. Same goes for safe-upgrade.

yesss ! the reference state is not kept across upgrades.

Copy link
Member

@G10h4ck G10h4ck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline comments

@@ -4,10 +4,17 @@ unique_append()
{
grep -qF "$1" "$2" || echo "$1" >> "$2"
}

## information generator datatype
uci set shared-state.bat_links_info=dataType
uci set shared-state.bat_links_info.name='bat_links_info'
uci set shared-state.bat_links_info.scope='community'
uci set shared-state.bat_links_info.ttl='2400'
uci set shared-state.bat_links_info.update_interval='30'
uci commit shared-state
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line needs to be moved after the last uci set at line 20 otherwise reference state configurations are not guaranteed to be persisted across reboot

uci set shared-state.node_info_ref.name='node_info_ref'
uci set shared-state.node_info_ref.scope='community'
uci set shared-state.node_info_ref.ttl='2400'
uci set shared-state.node_info_ref.update_interval='50'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uci commit shared-state must be moved here


Reference state is designed to contain information about the node that will
persist and that is not changed to often. This is because it is stored in the
device memory and to many consequent write operations may damage the memory.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sed 's/memory/persistent memory/g'

persist and that is not changed to often. This is because it is stored in the
device memory and to many consequent write operations may damage the memory.

One thing that is important to note is that no node stores the hole status of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hole/whole

#!/usr/bin/lua

--! LibreMesh
--! Will publish all refference data_type at once
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refference/reference

Copy link
Member

@G10h4ck G10h4ck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline comments

@@ -1,9 +1,21 @@
#!/bin/sh

unique_append()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is not used anymore should be removed, also the script should be renamed ;)

@@ -4,11 +4,17 @@ unique_append()
grep -qF "$1" "$2" || echo "$1" >> "$2"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is not used anymore should be removed ;)

@@ -4,10 +4,18 @@ unique_append()
{
grep -qF "$1" "$2" || echo "$1" >> "$2"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is not used anymore should be removed, also the script should be renamed ;)

uci set lime-defaults.system.keep_on_upgrade="$(uci get lime-defaults.system.keep_on_upgrade) shared-state-ref-state"
uci commit lime-defaults
touch /tmp/done
exit 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing line at the end of the file

@@ -1,9 +1,21 @@
#!/bin/sh

unique_append()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is not used anymore should be removed ;)

@G10h4ck G10h4ck merged commit 527c1eb into libremesh:master Aug 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants