-
Notifications
You must be signed in to change notification settings - Fork 372
feat: Allow recalling GuestOS versions #8188
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
Draft
frankdavid
wants to merge
3
commits into
master
Choose a base branch
from
frankdavid/block-rollback
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| //! Mock implementation of RegistryReplicatorTrait for testing. | ||
|
|
||
| use crate::RegistryReplicatorTrait; | ||
| use ic_interfaces_registry::{RegistryClient, RegistryDataProvider}; | ||
| use ic_registry_client::client::RegistryClientImpl; | ||
| use ic_registry_local_store::{KeyMutation, LocalStore, LocalStoreImpl, LocalStoreWriter}; | ||
| use ic_types::RegistryVersion; | ||
| use std::sync::Arc; | ||
|
|
||
| /// Mock registry replicator that syncs data from a "remote" registry data provider | ||
| /// to a local store and registry client. | ||
| pub struct MockRegistryReplicator { | ||
| /// The "remote" registry data provider that simulates the NNS registry | ||
| remote_data_provider: Arc<dyn RegistryDataProvider>, | ||
| /// The local store that gets updated during replication | ||
| local_store: Arc<LocalStoreImpl>, | ||
| /// The registry client that reads from the local store | ||
| registry_client: Arc<RegistryClientImpl>, | ||
| } | ||
|
|
||
| impl MockRegistryReplicator { | ||
| /// Creates a new mock registry replicator. | ||
| /// | ||
| /// # Arguments | ||
| /// * `remote_data_provider` - The "remote" registry that will be replicated from | ||
| /// * `local_store` - The local store that will be updated during replication | ||
| /// * `registry_client` - The registry client that reads from the local store | ||
| pub fn new( | ||
| remote_data_provider: Arc<dyn RegistryDataProvider>, | ||
| local_store: Arc<LocalStoreImpl>, | ||
| registry_client: Arc<RegistryClientImpl>, | ||
| ) -> Self { | ||
| Self { | ||
| remote_data_provider, | ||
| local_store, | ||
| registry_client, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[async_trait::async_trait] | ||
| impl RegistryReplicatorTrait for MockRegistryReplicator { | ||
| /// Simulates polling the remote registry by fetching updates from the remote | ||
| /// data provider and applying them to the local store. | ||
| async fn poll(&self) -> Result<(), String> { | ||
| // Get the current latest version in the local store | ||
| let local_latest_version = self.registry_client.get_latest_version(); | ||
|
|
||
| // Fetch all updates from the remote data provider since the local version | ||
| let updates = self | ||
| .remote_data_provider | ||
| .get_updates_since(local_latest_version) | ||
| .map_err(|e| format!("Failed to get updates from remote: {:?}", e))?; | ||
|
|
||
| // Group updates by version | ||
| let mut version_mutations: std::collections::BTreeMap<RegistryVersion, Vec<KeyMutation>> = | ||
| std::collections::BTreeMap::new(); | ||
|
|
||
| for record in updates { | ||
| version_mutations | ||
| .entry(record.version) | ||
| .or_insert_with(Vec::new) | ||
| .push(KeyMutation { | ||
| key: record.key, | ||
| value: record.value, | ||
| }); | ||
| } | ||
|
|
||
| // Apply updates to the local store | ||
| for (version, mutations) in version_mutations { | ||
| self.local_store | ||
| .store(version, mutations) | ||
| .map_err(|e| format!("Failed to store updates: {:?}", e))?; | ||
| } | ||
|
|
||
| // Update the registry client to see the new data | ||
| self.registry_client | ||
| .poll_once() | ||
| .map_err(|e| format!("Failed to update registry client: {:?}", e))?; | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| fn get_registry_client(&self) -> Arc<dyn RegistryClient> { | ||
| self.registry_client.clone() | ||
| } | ||
|
|
||
| fn get_local_store(&self) -> Arc<dyn LocalStore> { | ||
| self.local_store.clone() | ||
| } | ||
|
|
||
| async fn stop_polling_and_set_local_registry_data(&self, _new_local_store: &dyn LocalStore) { | ||
| // Mock implementation does nothing - not needed for testing | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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 continue using
replica versionor should we use the more up-to-daterecalled_guestos_version_idsname?