-
Notifications
You must be signed in to change notification settings - Fork 54
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
Add firmware_update support to c8y mapper #2464
Add firmware_update support to c8y mapper #2464
Conversation
Codecov Report
Additional details and impacted files
|
Robot Results
|
pub name: Option<String>, | ||
pub version: Option<String>, | ||
#[serde(rename = "url")] | ||
pub remote_url: Option<String>, |
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.
Another field that I'm not sure if tedge
should support, just because C8y supports it. What's the use-case I wonder. Why/when would/should a device report the URL with which the firmware was installed? Is this mandatory to send this url
field after finishing the firmware update with a C8y operation?
More of a question to @reubenmiller I guess.
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.
Generally if the url of the firmware binary is known then it should be included. If you are talking about publishing the current firmware info (name, version) on startup, then it is possible that the url is not known (as it might be baked into the OS image and was not provided via a url).
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.
Since the url
is useless in the initial bootstrap message, that reports the factory firmware info on the device, the only other case where it'd be useful is after a firmware update is performed. Is the use-case something like this: A device gets its firmware updated with some binary in the URL. The device is not capable of detecting the name/version even after the update. So, all that it can report back to the cloud is that it is using the firmware that it received in the URL?
Even in this case I don't think this is needed, because the successful
status message already includes that remoteUrl
field, which the mapper is using to send the 115
message. So, including the same url
here seems redundant/unnecessary.
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 don't have the context anymore of what message we're talking about. But more information can be useful..but without concrete examples of what messages we're explicitly talking about then I can't make an informed decision.
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.
But having the url
property can't harm the message, and it is more descriptive about where the firmware came from (if the info is available).
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 don't have the context anymore of what message we're talking about. But more information can be useful..but without concrete examples of what messages we're explicitly talking about then I can't make an informed decision.
Okay, so here are the two cases where this "tedge firmware metadata" message would be sent:
- When a device is getting bootstrapped: it needs to publish its factory firmware details. In this case, at best the device would know its
version
andname
. So, the device is less likely to use theurl
field in this path. - After the device firmware is updated using a cloud request (with a remote URL): the
firmware_update
request would contain thatremoteUrl
and once this operation is successful, the device would send thesuccessful
command status message with the sameremoteUrl
. The mapper on receipt of thissuccessful
status will mark the forward that to the cloud (SR 503 message), followed by the SmartREST set firmware message (SR 115) where the sameremoteUrl
in thesuccessful
status response is used. Since the firmware version in the cloud is already updated this way, the device need not send the tedge firmware metadata message again. Now, on the next restart of the agent, this tedge firmware metadata message would be sent again, but here also, it won't be able to send thaturl
information, unless it persists that URL info after every firmware update, which is less likely/unnecessary IMO.
This is the reason why I feel that the url
field in the "tedge firmware metadata message" is completely useless and it is relevant only in the firmware_update command messages.
But having the url property can't harm the message, and it is more descriptive about where the firmware came from (if the info is available).
Yeah, having an extra field doesn't harm, but when we document this API, we'll have to give some guidance to the user on when/how to use it, right? If this field is never going to be used, as neither cases highlighted above had a need for it (without additional persistence requirements), why even have it as an optional field?
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 think we should still keep it as it "could" be useful to people if they want to implement it (e.g. workflow overriding etc.).
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 have taken the opposite approach of omitting it for now and adding it when we encounter the need for it, as it's always easy to add things to a public API than removing things. Even for the workflow overriding, I only see the remoteUrl
field in the firmware update cmd
message being used and not this url
field in the capability message.
But, since you're fairly confident that it would be useful in some use-cases, and since it's an optional field anyway, let's keep it for now. Once firmware update is fully implemented, and if this field is still not used, we can still remove it before 1.0.
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 code changes LGTM. Only two outstanding comments to be discussed/resolved:
- The need for
url
field in the firmware metadata message - Moving the cpability enabled check and warning into the
process_smartrest
function.
I removed the unreachable code by bfd52a3. However, removed the warnings since it was difficult to move warnings as there are possibilities that custom operation may catch the disabled SmartREST ID. |
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
Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
* The metadata topic gets converted to: 1. supported operation 2. current installed firmware * When a new c8y_Firmware operation is received, c8y-mapper creates a new firmware_update command with "init" state. * When the command is updated to "executing", c8y-mapper sends a SmartREST 501 to update the operation status to EXECUTING * When the command is updated to final state (successful/failed), c8y-mapper sends SmartREST 502 or 503 to update the operation status. If successful, update the command metadata as well. Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
If user disables a capability, there should be a chance that user can still use custom template for the operation. Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
bfd52a3
to
18a3a1a
Compare
Proposed changes
Implement
firmware_update
support to c8y-mapper as described in #2453.Types of changes
Paste Link to the issue
#2453
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments