-
Notifications
You must be signed in to change notification settings - Fork 53
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
Support for software list & update on child devices #2307
Support for software list & update on child devices #2307
Conversation
372a181
to
40dc038
Compare
Codecov Report
Additional details and impacted files
|
Robot Results
|
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.
LGTM. Happy to approve after a test run once the merge conflicts are resolved.
let smartrest_set_operation_status = | ||
SmartRestSetOperationToExecuting::from_thin_edge_json(response)?.to_smartrest()?; | ||
Ok(vec![Message::new(&topic, smartrest_set_operation_status)]) | ||
async fn register_software_list_operation( |
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.
Should we use this PR as an opportunity to refactor out all the software management related functions from this converter.rs
module to a dedicated software_operation.rs
, like log_upload.rs
or config_operation.rs
, so that this module is leaner?
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.
Indeed, it would be good to have operation specific modules or even actor extensions. However, I would prefer to address that later once both software list and software update fully ported to support child devices.
31acc8f
to
88d9d74
Compare
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.
Happy to approve once the system test failures are sorted.
The failing system test is related to self-update: thin-edge used to update thin-edge on the device. So issue is that this test doesn't update |
So this is the first problem that has popped up due to the fact that the |
86d799f
to
d87ed9d
Compare
d87ed9d
to
4f0655e
Compare
21d3e01
to
8372b7d
Compare
8372b7d
to
2062b6c
Compare
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 core changes look good. Just some refactoring suggestions.
Execute Command sudo tedge config set mqtt.topic_root te | ||
Execute Command sudo tedge config set mqtt.device_topic_id "device/${CHILD_SN}//" | ||
|
||
# Install plugin after the default settings have been updated to prevent it from starting up as the main plugin |
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.
That's a huge UX issue that we'll have to solve somehow. Most customers wouldn't do it this way. They'd install everything first and then try to configure things, right? May be we should consider not starting tedge-agent
by default, unless it was already up and running (during updates). It's probably not that easy considering self-update and other update paths.
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.
Yes we still have some conceptual work to do here as a follow up, however I wouldn't look at the exact solution until we consolidate the number of services/processes.
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.
However running thin-edge.io in a container is easier to change this as you can set an environment variable to affect the behaviour of each component. systemd does not support inheriting environment variables.
Payload: Default, | ||
{ | ||
/// Build a new command with a random id | ||
pub fn new(target: &EntityTopicId) -> Self { |
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.
pub fn new(target: &EntityTopicId) -> Self { | |
pub fn new(schema: MqttSchema, target: &EntityTopicId) -> Self { |
Seeing the topic()
, capability_message()
, command_message()
and clearing_message()
all taking the schema separately, it feels like the schema should have been a part of the constructor. It's not something that's gonna change dynamically between these function calls, right?
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.
Having the schema attached to a message looks upside down.
I would prefer to address this in a more generic manner as proposed here #2357
@@ -108,8 +107,15 @@ impl C8yMapperConfig { | |||
let mut topics = Self::default_internal_topic_filter(&config_dir)?; | |||
|
|||
// Add feature topic filters | |||
topics.add_all(mqtt_schema.topics(AnyEntity, Command(OperationType::Restart))); | |||
topics.add_all(mqtt_schema.topics(AnyEntity, CommandMetadata(OperationType::Restart))); | |||
for cmd in [ |
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:
for cmd in [ | |
for cmd_type in [ |
tests/RobotFramework/tests/cumulocity/software_management/software-update-child.robot
Outdated
Show resolved
Hide resolved
/* | ||
|
||
#[test] | ||
fn using_a_software_update_response() { |
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.
Remove that test? Looks like an irrelevant test as software update response doesn't carry the software list anymore.
e81959f
to
ddbe805
Compare
92af9ad
to
3e0466f
Compare
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. Great effort!
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.
LGTM
Device Should Have Installed Software tedge,${NEW_VERSION_ESCAPED}::apt tedge-mapper,${NEW_VERSION_ESCAPED}::apt tedge-agent,${NEW_VERSION_ESCAPED}::apt tedge-watchdog,${NEW_VERSION_ESCAPED}::apt tedge-configuration-plugin,${NEW_VERSION_ESCAPED}::apt tedge-log-plugin,${NEW_VERSION_ESCAPED}::apt tedge-apt-plugin,${NEW_VERSION_ESCAPED}::apt | ||
|
||
# Software list reported by the new agent | ||
Restart Service tedge-agent |
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.
Does this mean that end-user needs to explicitly restart the tedge-agent
after every update? Or that has always been the case?
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.
Yes. This is the case since the work on self-update. Restarting the agent during a software update operation leads to a fail operation status.
This is something we will need to fix, sure.
return Ok(None); | ||
} | ||
request.insert("id".to_string(), Value::String(cmd_id.to_string())); | ||
request.remove("status"); // as the old agent denies unknown fields |
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:
request.remove("status"); // as the old agent denies unknown fields | |
request.remove("status"); // as the old agent denies unknown status values like `init` |
"Fail to extract command 'id' from agent {cmd_type} response: {}", | ||
std::str::from_utf8(payload).unwrap_or("non utf8 payload") | ||
)) | ||
} |
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'd add some unit test coverage, if there's time, especially for the convert_to_old_agent_request
function which has some deep nested logic.
This is first step toward their deprecation. Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
A huge change but straightforward. Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
The aim is to be able to handle the case where the mapper has been updated but not the agent. This will typically arises during a self update where the tedge packages are updated by the agent. Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
9555293
to
352388d
Compare
Proposed changes
Implement
software_list
support as described by #2235te
MQTT schemesoftware-list
capability on startsoftware-list
requestsImplement
software_update
support as described by #2235software-update
capability on startsoftware-update
requestsTypes of changes
Paste Link to the issue
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments