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

Problem using custom Update Agent #53

Closed
sophokles73 opened this issue Feb 5, 2024 · 7 comments
Closed

Problem using custom Update Agent #53

sophokles73 opened this issue Feb 5, 2024 · 7 comments
Assignees
Labels
question Further information is requested
Milestone

Comments

@sophokles73
Copy link

Hi,

let's say I have implemented a custom Update Agent with domain identifier my-custom-domain.
Now I want to use the Update Manager to trigger an update on my custom agent using the following desired state which I publish to the vehicleupdate/desiredstate topic that the Update Manager is subscribed to:

{
  "activityId": "perform-custom-update",
  "payload": {
    "domains": [
      {
        "id": "my-custom-domain",
        "config": [],
        "components": [
          {
            "id": "my-component-to-be-updated",
            "version": "2.3.1",
            "config": [
              {
                "key": "image",
                "value": "https://my.repo/image.2.3.1.tgz"
              }
            ]
          }
        ]
      }
    ]
  }
}

I had been hoping to see a message being published to the mycustomdomain/desiredstate topic, but that did not happen. Instead, I saw the following in the log file of the Update Manager:

2024/02/05 08:23:46.878020  [update-manager] ERROR   cannot get current state for domain self-update cannot get current state by activityID 'initial-current-state-1707121396814' in '30s' for domain self-update
2024/02/05 08:23:46.917439  [update-manager] ERROR   cannot get current state for domain containers cannot get current state by activityID 'initial-current-state-1707121396814' in '30s' for domain containers
2024/02/05 08:41:04.145072  [update-manager] INFO    Starting update activity perform-custom-update ...
2024/02/05 08:41:04.145465  [update-manager] WARN    Cannot find Update Agent for domain my-custom-domain
2024/02/05 08:41:04.145716  [update-manager] ERROR   the desired state manifest does not contain any supported domain
2024/02/05 08:41:04.201725  [update-manager] INFO    Finished update activity perform-custom-update

Do I need to register my custom Update Agent first with the Update Manager? If so, how?

@sophokles73 sophokles73 changed the title What is sent from Update Manager to an Update Agent Problem using custom Update Agent Feb 5, 2024
@k-gostev
Copy link
Member

k-gostev commented Feb 5, 2024

Hi Kai, we are finalising an example update agent application that can easily get you started with creating custom agents.
The PR is here. While still the PR is not review and approved, the README file can still get you trough the necessary steps in order to get you custom agent working.

And to get ahead with your next question, automatic agent registration is something that we are considering as a nice to have feature, but we have not yet implemented, or even put on our roadmap.

@k-gostev k-gostev added the question Further information is requested label Feb 5, 2024
@dimitar-dimitrow
Copy link
Contributor

dimitar-dimitrow commented Feb 5, 2024

Hi @sophokles73,

yeah you should also configure the Update Manager for the new Agent, the configuration by default is found in /etc/kanto-update-manager/config.json, you can edit it and than restart the service to apply the changes. Here is an example:

{
    "agents": {
        "containers": {
            "rebootRequired": false,
            "readTimeout": "30s"
        },
        "my-custom-domain": {
            "rebootRequired": false,
            "readTimeout": "60s"
        }
    }
}

@sophokles73
Copy link
Author

Thanks for the info, @dimitar-dimitrow and @k-gostev

One additional question: what does the readTimeout parameter for the agent configuration mean?

@k-gostev
Copy link
Member

k-gostev commented Feb 5, 2024

Timeout as duration string for reading the current state for the domain. Ref.

@sophokles73
Copy link
Author

Is there a sequence diagram available which defines which interactions the Update Manager has with an Update Agent when performing an update? It seems that the Update Manager does not simply forward the desired state to the Update Agent but also requires the Update Agent to report its current state beforehand. However, I have a hard time finding the relevant information ...

@dimitar-dimitrow
Copy link
Contributor

dimitar-dimitrow commented Feb 5, 2024

@sophokles73, I could not find a sequence diagram(that should be fixed). Here is the available documentation as of now.

Here are some MQTT dumps and explanations of using Container's Update Agent(UA) - (the explanations are about original UM topics, no Ditto/Thing integration --things-enabled=false)

  1. When the Update Manager(UM) is started it tries to get the current state from the provided UAs and than reports the combined device state:
UM containersupdate/currentstate/get {"activityId":"initial-current-state-1707129569362","timestamp":1707129569366,"payload":null}
UA containersupdate/currentstate {"activityId":"initial-current-state-1707129569362","timestamp":1707129569366,"payload":{"softwareNodes":[{"id":"containers-update-agent","version":"1.0.0","name":"Eclipse Kanto Containers Update Agent","parameters":[{"key":"domain","value":"containers"}],"type":"APPLICATION"},{"id":"containers:hello","version":"latest","parameters":[{"key":"image","value":"docker.io/tutum/hello-world:latest"},{"key":"port","value":"8001:80/tcp"},{"key":"status","value":"Running"},{"key":"created","value":"2024-02-05T10:24:41.334344234Z"}],"type":"CONTAINER"}],"associations":[{"sourceId":"containers-update-agent","targetId":"containers:hello"}]}}
UM deviceupdate/currentstate {"activityId":"initial-current-state-1707129569362","timestamp":1707129569408,"payload":{"softwareNodes":[{"id":"device-update-manager","version":"development","name":"Update Manager","type":"APPLICATION"},{"id":"containers-update-agent","version":"1.0.0","name":"Eclipse Kanto Containers Update Agent","parameters":[{"key":"domain","value":"containers"}],"type":"APPLICATION"},{"id":"containers:hello","version":"latest","parameters":[{"key":"image","value":"docker.io/tutum/hello-world:latest"},{"key":"port","value":"8001:80/tcp"},{"key":"status","value":"Running"},{"key":"created","value":"2024-02-05T10:24:41.334344234Z"}],"type":"CONTAINER"}],"associations":[{"sourceId":"device-update-manager","targetId":"containers-update-agent"},{"sourceId":"containers-update-agent","targetId":"containers:hello"}]}}
  1. A new desired state is received on the local MQTT broker:
deviceupdate/desiredstate {"activityId": "example","payload": {"baselines": [{"title": "example title","description": "example description","components": []}],"domains": [{"id": "containers","components": [{"id": "hello","config": [{"key": "image","value": "docker.io/tutum/hello-world:latest"},{"key": "port","value": "8001:80"}]}]}]}}
  1. The update goes as follow:
UM deviceupdate/desiredstatefeedback {"activityId":"example","timestamp":1707128681257,"payload":{"status":"IDENTIFYING"}}
UM containersupdate/desiredstate {"activityId":"example","timestamp":1707128681257,"payload":{"domains":[{"id":"containers","components":[{"id":"hello","config":[{"key":"image","value":"docker.io/tutum/hello-world:latest"},{"key":"port","value":"8001:80"}]}]}]}}
UA containersupdate/desiredstatefeedback {"activityId":"example","timestamp":1707128681260,"payload":{"status":"IDENTIFYING"}}
UA containersupdate/desiredstatefeedback {"activityId":"example","timestamp":1707128681260,"payload":{"status":"IDENTIFIED","actions":[{"component":{"id":"containers:hello"},"status":"IDENTIFIED","message":"New container will be created and started."}]}}
UM deviceupdate/desiredstatefeedback {"activityId":"example","timestamp":1707128681304,"payload":{"status":"IDENTIFIED","actions":[{"component":{"id":"containers:hello"},"status":"IDENTIFIED","message":"New container will be created and started."}]}}
UM deviceupdate/desiredstatefeedback {"activityId":"example","timestamp":1707128681304,"payload":{"status":"RUNNING","actions":[{"component":{"id":"containers:hello"},"status":"IDENTIFIED","message":"New container will be created and started."}]}}
UM containersupdate/desiredstate/command {"activityId":"example","timestamp":1707128681304,"payload":{"command":"DOWNLOAD"}}
UA containersupdate/desiredstatefeedback {"activityId":"example","timestamp":1707128681308,"payload":{"status":"DOWNLOADING","actions":[{"component":{"id":"containers:hello"},"status":"DOWNLOADING","message":"New container will be created and started."}]}}
UA containersupdate/desiredstatefeedback {"activityId":"example","timestamp":1707128681346,"payload":{"status":"DOWNLOAD_SUCCESS","actions":[{"component":{"id":"containers:hello"},"status":"DOWNLOAD_SUCCESS","message":"New container created."}]}}
UM containersupdate/desiredstate/command {"activityId":"example","timestamp":1707128681348,"payload":{"command":"UPDATE"}}
UA containersupdate/desiredstatefeedback {"activityId":"example","timestamp":1707128681392,"payload":{"status":"UPDATE_SUCCESS","actions":[{"component":{"id":"containers:hello"},"status":"UPDATE_SUCCESS","message":"New container created."}]}}
UM containersupdate/desiredstate/command {"activityId":"example","timestamp":1707128681392,"payload":{"command":"ACTIVATE"}}
UA containersupdate/desiredstatefeedback {"activityId":"example","timestamp":1707128681436,"payload":{"status":"ACTIVATING","actions":[{"component":{"id":"containers:hello"},"status":"ACTIVATING","message":"New container created."}]}}
UA containersupdate/desiredstatefeedback {"activityId":"example","timestamp":1707128681753,"payload":{"status":"ACTIVATION_SUCCESS","actions":[{"component":{"id":"containers:hello"},"status":"ACTIVATION_SUCCESS","message":"New container instance is started."}]}}
UM containersupdate/desiredstate/command {"activityId":"example","timestamp":1707128681754,"payload":{"command":"CLEANUP"}}
UA containersupdate/desiredstatefeedback {"activityId":"example","timestamp":1707128681754,"payload":{"status":"CLEANUP_SUCCESS","actions":[{"component":{"id":"containers:hello"},"status":"ACTIVATION_SUCCESS","message":"New container instance is started."}]}}
UM deviceupdate/desiredstatefeedback {"activityId":"example","timestamp":1707128681754,"payload":{"status":"COMPLETED","actions":[{"component":{"id":"containers:hello"},"status":"UPDATE_SUCCESS","message":"New container instance is started."}]}}
  1. At the end the UM get the current state again:
UM containersupdate/currentstate/get {"activityId":"example","timestamp":1707128681754,"payload":null}
UA containersupdate/currentstate {"activityId":"example","timestamp":1707128681796,"payload":{"softwareNodes":[{"id":"containers-update-agent","version":"1.0.0","name":"Eclipse Kanto Containers Update Agent","parameters":[{"key":"domain","value":"containers"}],"type":"APPLICATION"},{"id":"containers:hello","version":"latest","parameters":[{"key":"image","value":"docker.io/tutum/hello-world:latest"},{"key":"port","value":"8001:80/tcp"},{"key":"status","value":"Running"},{"key":"created","value":"2024-02-05T10:24:41.334344234Z"}],"type":"CONTAINER"}],"associations":[{"sourceId":"containers-update-agent","targetId":"containers:hello"}]}}
UM deviceupdate/currentstate {"activityId":"example","timestamp":1707128681796,"payload":{"softwareNodes":[{"id":"device-update-manager","version":"development","name":"Update Manager","type":"APPLICATION"},{"id":"containers-update-agent","version":"1.0.0","name":"Eclipse Kanto Containers Update Agent","parameters":[{"key":"domain","value":"containers"}],"type":"APPLICATION"},{"id":"containers:hello","version":"latest","parameters":[{"key":"image","value":"docker.io/tutum/hello-world:latest"},{"key":"port","value":"8001:80/tcp"},{"key":"status","value":"Running"},{"key":"created","value":"2024-02-05T10:24:41.334344234Z"}],"type":"CONTAINER"}],"associations":[{"sourceId":"device-update-manager","targetId":"containers-update-agent"},{"sourceId":"containers-update-agent","targetId":"containers:hello"}]}} 

@dimitar-dimitrow dimitar-dimitrow self-assigned this Feb 14, 2024
@dimitar-dimitrow dimitar-dimitrow added this to the M5 milestone Feb 14, 2024
@dimitar-dimitrow
Copy link
Contributor

Another issue is created for adding an UM<->UA sequence diagram in the documentation - #55.
Closing the issue as there is no new activity and the question seems to be answered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
Status: Done
Development

No branches or pull requests

3 participants