snapshot rollback: add EventSource and EventTrigger support - #448
Closed
magic-peach wants to merge 1 commit into
Closed
magic-peach wants to merge 1 commit into
magic-peach wants to merge 1 commit into
Conversation
The rollback command restored ConfigMaps, Secrets, Clusters, ClusterProfiles, Profiles, Classifiers and RoleRequests from a snapshot but skipped EventSource and EventTrigger, even though both are already collected into snapshots. Added getAndRollbackEventSources and getAndRollbackEventTriggers following the same pattern as getAndRollbackClassifiers, plus --eventsource and --eventtrigger flags to filter by name. While adding this, found that getAndRollbackRoleRequests called rollbackClassifier instead of a RoleRequest specific function. Since GetResource looks up the typed object passed in, this fetched by the Classifier API instead of RoleRequest, so an existing RoleRequest was never actually found and the code always fell into the create path, failing with an already exists error instead of updating it. Added rollbackRoleRequest, matching the same typed pattern already used for ClusterProfile, Profile and Classifier, and wired it in. Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
Author
|
Closing this: the snapshot subcommand this PR extends (internal/commands/snapshot/rollback.go) was removed entirely from main in the v1.0.0-beta.0 release prep (PR #380), so this no longer has anything to apply to. Happy to reopen if the snapshot functionality ever comes back. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This repo has no PR template, so this is a plain factual description.
What changed
The snapshot rollback command restored ConfigMaps, Secrets, Clusters, ClusterProfiles, Profiles, Classifiers and RoleRequests from a snapshot but skipped EventSource and EventTrigger, even though both are already collected into snapshots. Added getAndRollbackEventSources and getAndRollbackEventTriggers following the same pattern as getAndRollbackClassifiers, plus --eventsource and --eventtrigger flags to filter by name. Closes #121.
While implementing this, found that getAndRollbackRoleRequests called rollbackClassifier instead of a RoleRequest specific function. Since GetResource looks up the typed object passed in, this fetched by the Classifier API instead of RoleRequest, so an existing RoleRequest was never actually found and the code always fell into the create path, failing with an already exists error instead of updating it. Added rollbackRoleRequest, matching the same typed pattern already used for ClusterProfile, Profile and Classifier, and wired it in.
Why
Issue #121 asks for this directly, and names the exact pattern to mirror. The RoleRequest bug was found by reading the surrounding code while implementing the requested feature.
Testing
go build ./..., go vet ./... and go test ./... all pass. Added rollbackRoleRequest, rollbackEventSource and rollbackEventTrigger test cases mirroring the existing rollbackClusterProfile test, plus updated the existing rollbackConfigurationToSnapshot test call site for the new function signature.