-
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
Add configuration operation support to c8y-mapper #2303
Add configuration operation support to c8y-mapper #2303
Conversation
Robot Results
|
&response.config_type, | ||
external_id.as_ref().to_string(), | ||
) | ||
.await; // We need to get rid of this await, otherwise it blocks |
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.
To be replaced by a call to the config uploader actor once #2302 is done.
Signed-off-by: Rina Fujino <18257209+rina23q@users.noreply.github.com>
Upon receiving c8y_UploadConfigFile request, c8y-mapper does * create a new config_snapshot command * upload a config file to c8y on successful state of config_snapshot cmd Upon receiving c8y_DownloadConfigFile request, c8y-mapper does * download a target file from remote if not available in cache directory * create a new config_update command * remove a symlink on successful state of config_update cmd For both matadata, c8y-mapper sends supported config types message and supported operations to c8y Signed-off-by: Rina Fujino <18257209+rina23q@users.noreply.github.com>
f93b9f1
to
a8830b1
Compare
Codecov Report
Additional details and impacted files
|
9c3decd
to
406aece
Compare
Slash is reserved for file system, therefore, using '/' inside tedgeUrl causes creating unexpected directories in the file transfer repository. Since '/' is still valid as config type, replacing slashes only in paths Signed-off-by: Rina Fujino <18257209+rina23q@users.noreply.github.com>
Signed-off-by: Rina Fujino <18257209+rina23q@users.noreply.github.com>
406aece
to
26b0c72
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.
We're going to have to include the packaging and system tests in this PR so that we avoid publishing a tedge-mapper which sends the configuration operation to a component that does not exist. So even though the additional packaging changes are not directly related to the PR, I don't see any easy way to merge this PR without fully switching over from c8y-configuration-plugin to tedge-configuration-plugin.
I've started preparing the packaging/updated system tests, however the following still needs to be done in order to assist:
- Add a
lib.rs
file and call it from themain.rs
file (similar to tedge_log_plugin/src/main.rs) - Covered by refactor to use lib file to enable calling from the multi-call binary #2339 - Add a build.rs file - Covered by fix: add missing build.rs script to use the auto generated git based versioning #2338 - so this PR can be rebased on top
-
Add the tedge-configuration-plugin to the multi-call binary setup in tedgeN/A as a follow up PR can do this.
Update
I just saw that there are feature flags included in this PR to disable this feature until we're ready with the packaging. So I don't have any problem merging.
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
.get_by_external_id(&snapshot_request.device.clone().into()) | ||
.ok_or_else(|| UnknownDevice { | ||
device_id: snapshot_request.device.to_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.
I see this pattern repeating a lot these days (for restart, log_upload etc) and this will just increase. May be it's time to add try_get_by_external_id
and try_get
API counterparts which will return that Err<UnknownDevice>
result instead of None
as returned by the existing APIs. It can be done in a follow-up PR though.
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.
Addressed in the PR #2340
"http://{}/tedge/file-transfer/{}/config_snapshot/{}-{}", | ||
&self.config.tedge_http_host, | ||
external_id, | ||
snapshot_request.config_type.replace('/', ":"), |
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.
With this, there is the risk of different config types abc:xyz
and abc/xyz
conflicting. The snapshot of the first file might get overwritten by the second one. As long as our request processing is serial, this many not be an issue. But still, why not allow those extra dirs when the type has /
in it? What's the harm?
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.
Our config_type allows to use /
(it's even a kind of default when user doesn't give specific type, then using file path as type). However, since /
is considered directory separator, so somehow need to escape. Then I introduce replacing with :
.
If we don't escape, when plugin uploads to http://localhost:8888/tedge/file-transfer/test-device/config_snapshot//etc/tedge/tedge.toml-1234
for the type /etc/tedge/tedge.toml
, the file will be stored /var/tedge/test-device/config_snapshot/etc/tedge/tedge.toml-1234
. Too many directories.
Signed-off-by: Rina Fujino <18257209+rina23q@users.noreply.github.com>
Signed-off-by: Rina Fujino <18257209+rina23q@users.noreply.github.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.
LGTM
pub enum SmartRestVariant { | ||
SmartRestLogRequest, | ||
#[derive(Debug)] | ||
pub enum SmartRestOperationVariant { |
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 enum SmartRestOperationVariant { | |
pub enum SmartRestOperation { |
As commented in thin-edge#2303#discussion_r1356364285, we have many patterns using get() or get_by_external_id() and map them None to Err. The new APIs returns Error::UnknownEntity instead of None. Signed-off-by: Rina Fujino <18257209+rina23q@users.noreply.github.com>
Proposed changes
Todo:
unwrap
s.c8y.enable.config_update
andc8y.enable.config_snapshot
Follow-up:
tedge-configuration-plugin
package)Types of changes
Paste Link to the issue
#2292
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments