Skip to content

snapshot rollback: add EventSource and EventTrigger support - #448

Closed
magic-peach wants to merge 1 commit into
projectsveltos:devfrom
magic-peach:feat/rollback-eventsource-eventtrigger
Closed

magic-peach wants to merge 1 commit into
projectsveltos:devfrom
magic-peach:feat/rollback-eventsource-eventtrigger

Conversation

@magic-peach

Copy link
Copy Markdown

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.

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>
@magic-peach

Copy link
Copy Markdown
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.

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.

1 participant