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

snapshot-service: Introduce plgd/snapshot-service #1225

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

jkralik
Copy link
Member

@jkralik jkralik commented Feb 2, 2024

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.

@jkralik jkralik force-pushed the jkralik/feature/snapshot-service branch from 973c40e to 9d47337 Compare February 2, 2024 15:36
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.
@jkralik jkralik force-pushed the jkralik/feature/snapshot-service branch from 9d47337 to 379d2c2 Compare February 2, 2024 15:43
Copy link

sonarcloud bot commented Feb 2, 2024

Quality Gate Failed Quality Gate failed

Failed conditions

18.9% Coverage on New Code (required ≥ 75%)

See analysis details on SonarCloud

@jkralik jkralik force-pushed the jkralik/feature/snapshot-service branch from 61c8bf9 to 6243430 Compare February 22, 2024 13:08
@jkralik jkralik force-pushed the jkralik/feature/snapshot-service branch from 6243430 to 0750342 Compare February 22, 2024 14:43
Copy link

coderabbitai bot commented Mar 15, 2024

Important

Auto Review Skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

snapshot-service/pb/service.proto Outdated Show resolved Hide resolved
string resource_interface = 6; // optional update interface
int64 time_to_live = 7; // optional update command time to live
}
Id id = 1;
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

repeated Resource resources = 3;
}

message CreateConfigurationReponse { Id id = 1; }
Copy link
Member

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?

Copy link
Member Author

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 Show resolved Hide resolved
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 {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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.

snapshot-service/pb/service.proto Show resolved Hide resolved
string id = 1;
string device_id = 2;
Id configuration_id = 3;
oneof executed_by {
Copy link
Member

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)?

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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.


message InvokeConfigurationRequest {
string id = 1;
repeated string device_id_filter = 2; // at least one must be set
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right

}

message InvokeConfigurationRequest {
string id = 1;
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

string id = 1;
repeated string device_id_filter = 2; // at least one must be set
bool force = 3;
bool keep_updating_on_failure = 4;
Copy link
Member

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?

Copy link
Member Author

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)

@jkralik jkralik force-pushed the jkralik/feature/snapshot-service branch from 0901447 to 013bd30 Compare April 25, 2024 08:58
FAIL = 5;
};
Status status = 3;
int64 timestamp_start = 4; // when the rule association was applied
Copy link
Member

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?

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants