-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
snapshot-service: Introduce plgd/snapshot-service #1225
base: main
Are you sure you want to change the base?
Conversation
973c40e
to
9d47337
Compare
The PLGD Snapshot Service is designed for managing devices snapshots. It provides functionality for creating, retrieving, deleting snapshots, applying snapshots, managing snapshot associations, and obtaining snapshot statuses.
9d47337
to
379d2c2
Compare
Quality Gate failedFailed conditions 18.9% Coverage on New Code (required ≥ 75%) |
61c8bf9
to
6243430
Compare
6243430
to
0750342
Compare
Important Auto Review SkippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
snapshot-service/pb/service.proto
Outdated
string resource_interface = 6; // optional update interface | ||
int64 time_to_live = 7; // optional update command time to live | ||
} | ||
Id id = 1; |
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.
@jkralik It might be misleading, as we usually use UUIDs for IDs in plgd hub. I would propose to not encapsulate version into the ID. What about having id and version directly in configuration struct?
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.
updated
snapshot-service/pb/service.proto
Outdated
repeated Resource resources = 3; | ||
} | ||
|
||
message CreateConfigurationReponse { Id id = 1; } |
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.
@jkralik In our API calls, we tend to return created/updated content. Why not here?
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.
updated
message Resource { | ||
resourceaggregate.pb.ResourceId resource_id = 1; | ||
uint32 configuration_resources_idx = 2; // index of resource in configuration resources array. For resource types it could be mutliple resources. | ||
enum Status { |
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.
@jkralik what is WAITING_FOR_RESOURCE
state describing? It would be good to have in system compatible states, mainly if they represent contextually same behaviour. Why not to reuse pending commands states?
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.
When resource still not exists in the hub, it is wait for him - it is expected that the resource will be created in short time.
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 equal to Pending Command. Isn't it? And timeout is expired for example. Aren't we dealing only with pending commands and their result state?
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.
No it's different. Currently you cannot create update resource when the resource changed of the resource is not stored or it is not published. We can introduce bool flag
which allows to create update pending request even the resource not exist. If update resource command to aggregate fails we need to somehow report the error.
string id = 1; | ||
string device_id = 2; | ||
Id configuration_id = 3; | ||
oneof executed_by { |
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.
@jkralik what if the same configuration id+version is executed by multiple conditions and also on demand? Will this result in multiple AppliedConfigurations?
What if the trigger has the same rule? -> How to evaluate if update was executed already (not saying we need to do so)?
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.
It is expected that the applied configuration for device_id, id
only once.
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.
Do you mean device_id
+ cfg id
+ cfg version
?
But how do you want to prevent that Configuration of the same id and version is not applied twice on the same device, if there are two rules referencing it, or it's invoked manually?
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.
No - just device_id
+ cfg id
. This means that the configuration has been applied. In this case version is used only to find the configuration which has been applied.
snapshot-service/pb/service.proto
Outdated
|
||
message InvokeConfigurationRequest { | ||
string id = 1; | ||
repeated string device_id_filter = 2; // at least one must be set |
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.
@jkralik Will invocation result in one AppliedConfiguration
with resources from e.g. 3 devices? Or is the granularity of the AppliedConfiguration
per Device?
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.
Will invoke set configuration with id to 3 devices.
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 not what I asked. This requests accepts filter, I can specify 3 devices. Applied configuration, which represents what happened, has a device id as a single string. That means, if 3 devices are found from the filter specified in this request, it will result in 3 AppliedConfiguration
, each with a device id matching the filter device ids. 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.
Right
snapshot-service/pb/service.proto
Outdated
} | ||
|
||
message InvokeConfigurationRequest { | ||
string id = 1; |
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.
@jkralik why do you need identifier for invocation? Do you plan to persist them?
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.
ID says which configuration you wan to apply to the devices in device_id_filter.
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.
Then use configuration_id
instead please.
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.
InvokeConfigurationRequest.configuration_id
it seems to me that i repeat to often the word configuration
.
snapshot-service/pb/service.proto
Outdated
string id = 1; | ||
repeated string device_id_filter = 2; // at least one must be set | ||
bool force = 3; | ||
bool keep_updating_on_failure = 4; |
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.
@jkralik could you describe scenarios for both, force and keep_updating please?
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.
- force: re-apply configuration to device
- keep_updating_on_failure: when some update resource fails the updates will continue (maybe this flag could be moved to Resource Config so for each update resource you can said if you want to continue)
0901447
to
013bd30
Compare
snapshot-service/pb/service.proto
Outdated
FAIL = 5; | ||
}; | ||
Status status = 3; | ||
int64 timestamp_start = 4; // when the rule association was applied |
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.
@jkralik how this differs from the applied? If the device connects, that has serial number 123, rule is triggered and immediately the pending command is created. What this timestamp start really represents? Connected device? Resource on which rule depends published and retrieved? Command queued? Command done/fail?
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 configuration is applied one by one - Not parallel (maybe in future we can add such option).
timestamp_start
it is a time when the resource update command to resource aggregate will be send.
The PLGD Snapshot Service is designed for managing devices snapshots. It provides functionality for creating, retrieving, deleting snapshots, applying snapshots, managing snapshot associations, and obtaining snapshot statuses.