-
Notifications
You must be signed in to change notification settings - Fork 56
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
tedge-mapper-c8y service restart is required after a change of supported operation file contents #1959
tedge-mapper-c8y service restart is required after a change of supported operation file contents #1959
Conversation
Signed-off-by: Pradeep Kumar K J <pradeepkumar.kj@softwareag.com>
Signed-off-by: Pradeep Kumar K J <pradeepkumar.kj@softwareag.com>
Robot Results
Passed Tests
Failed Tests
|
Signed-off-by: Pradeep Kumar K J <pradeepkumar.kj@softwareag.com>
@@ -743,7 +743,7 @@ impl Converter for CumulocityConverter { | |||
) -> Result<Option<Message>, ConversionError> { | |||
match message.ops_dir.parent() { | |||
Some(parent_dir) => { | |||
if parent_dir.eq(&self.cfg_dir.join("operations").join("c8y")) { | |||
if parent_dir.eq(&self.cfg_dir.join("operations")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the operations
directory instead of the operation/c8y
surprises me. Are you sure we should be using this, as won't that potentially listen to other non-c8y changes as well?
For example:
/etc/tedge/operations/az
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tedge-mapper-c8y
subscribes for notifications for the path /etc/tedge/operations/c8y
. So, it will receive the notifications only when there is a change in this directory. The ops_dir is derived as below.
let ops_dir = config_dir.join("operations").join("c8y")
When there is a change of operation in the parent/thin-edge device whenever the notification contains /etc/tedge/operations/c8y
. The parent directory will be /etc/tedge/operations
.
When there is a change of operation in the thin-edge cumulocity child device
the notification contains the /etc/tedge/operations/c8y<child-id>
path. In this case, the parent directory will be /etc/tedge/operations/c8y
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So why not check the paths of the event against /etc/tedge/operations/c8y
?
- if the dir of the updated file is
/etc/tedge/operations/c8y
, then the event if for the main device. - if the parent dir of the updated file is
/etc/tedge/operations/c8y
, the the event if for a child device. - otherwise the event has to be ignored.
Assuming that the mapper only subscribed to /etc/tedge/operations/c8y
is really fragile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt its redundant, if you think it's very fragile, then I am ok to add specific event
path checks for parent
n child
devices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fragile because someone else might later add an apparently innocuous new subscriptions and break things in a fully unexpected manner.
Thank you for the update.
Signed-off-by: Pradeep Kumar K J <pradeepkumar.kj@softwareag.com>
Signed-off-by: Pradeep Kumar K J <pradeepkumar.kj@softwareag.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
} else if message.ops_dir.eq(&self | ||
.cfg_dir | ||
.join("operations") | ||
.join("c8y") | ||
.join(get_child_id(&message.ops_dir)?)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Minor] One might have something simpler by comparing message.ops_dir.parent()
with Some("/etc/tedge/operations/c8y")
.
Proposed changes
The issue here is, if there is any change to the
custom operation
file content, then these changes are not reflected in the operation list that is present with thetedge-mapper-c8y
. To get it reflected the mapper has to be restarted.On the code path, on the file change notification, the mapper is wrongly updating the child device operations list.
The proposed fix is
Dynamically update/populate the
thin-edge
device operation list oftedge-mapper-c8y
when there is a change in the operation file.Added integration test to verify the fix.
Types of changes
Paste Link to the issue
#1705
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments