thin-edge / thin-edge.io

The open edge framework for lightweight IoT devices
https://thin-edge.io
Apache License 2.0
221 stars 54 forks source link

`tedge-mapper-c8y` service restart is required after a change of supported operation file contents #1705

Closed rina23q closed 1 year ago

rina23q commented 1 year ago

Describe the bug If you update a supported operation file in runtime of tedge-mapper-c8y, the mapper doesn't use the new content. The mapper needs to be restarted. For example,

  1. Update the command field of an operation file to new path (from /path/a to /path/b).
  2. tedge-mapper-c8y still looks up at /path/a.
  3. After restart of tedge-mapper-c8y, it starts looking at /path/b finally.

To Reproduce Prerequisites:

Steps:

  1. Create a file /etc/tedge/operations/command0.sh then make it executable.
    echo -e '#!/bin/bash\necho "file: $0"\nexit 0' |  sudo tee /etc/tedge/operations/command0.sh
    sudo chmod +x /etc/tedge/operations/command0.sh
  2. Create a file /etc/tedge/operations/c8y/c8y_Command.
    sudo -u tedge touch /etc/tedge/operations/c8y/c8y_Command
  3. Add the following content to the file /etc/tedge/operations/c8y/c8y_Command.
    [exec]
    topic = "c8y/s/ds"
    on_message = "511"
    command = "/etc/tedge/operations/command0.sh"
  4. Send a random text (e.g. "abc") with the "Shell" tab of c8y.
  5. The operation stays pending. (It is because the mapper doesn't look up the updated content in /etc/tedge/operations/c8y/c8y_Command. Should have been marked "successful" without this bug)

Workaround

The current workaround to get the mapper to re-read the custom operation mapping files, you will need to restart the tedge-mapper-c8y service, see below for an example:

sudo systemctl restart tedge-mapper-c8y.service

The pending operation should start processing the tedge-mapper-c8y service restarts. However if there are multiple operations of the same type (e.g. shell operations), then the status/result of the operation might be out of order (due to the id-less handling of operations in Cumulocity).

Expected behavior The tedge-mapper-c8y should catch the contents update of supported operation files immediately. Restart should not be required.

Screenshots

Environment (please complete the following information):

Additional context

didier-wenzek commented 1 year ago

Once validated the fix for that issue, one has to close this PR https://github.com/thin-edge/thin-edge.io/pull/1927 documenting a workaround.

gligorisaev commented 1 year ago

Before I validate the bug the one who raised it, in this case @rina23q should first confirm that the bug is fixed (and correct the text in "how to reproduce")

reubenmiller commented 1 year ago

@rina23q After talking with @gligorisaev I made a few improvements to the formatting and description of some of the steps in the initial ticket description.

gligorisaev commented 1 year ago

Bug still exists

PradeepKiruvale commented 1 year ago

Let me try again to reproduce.

reubenmiller commented 1 year ago

It works for me.

We'll debug the issue further to see what is going on here, it might just be a configuration or integration issue.

reubenmiller commented 1 year ago

@gligorisaev It can be retested. The version is already available from cloudsmith.io, 0.10.0-264-gb245979f

gligorisaev commented 1 year ago

Tested and not reproducable,