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 reporting #4138

Merged
merged 10 commits into from
Nov 22, 2023
Merged

snapshot reporting #4138

merged 10 commits into from
Nov 22, 2023

Conversation

cbodonnell
Copy link
Contributor

@cbodonnell cbodonnell commented Nov 17, 2023

What this PR does / why we need it:

This PR adds reporting for snapshot provider, schedule, and retention policy (ttl)

Which issue(s) this PR fixes:

https://app.shortcut.com/replicated/story/89885/instrument-and-report-back-whether-the-end-user-is-using-snapshots

Special notes for your reviewer:

Steps to reproduce

Does this PR introduce a user-facing change?

NONE

Does this PR require documentation?

NONE

@cbodonnell cbodonnell changed the title Cbo/sc 89885/snapshot reporting snapshot reporting Nov 17, 2023
@cbodonnell cbodonnell marked this pull request as ready for review November 20, 2023 21:40
@cbodonnell cbodonnell requested a review from sgalsaleh November 20, 2023 21:40
return errors.Wrap(err, "failed to create velero clientset")
}

bsl, err := snapshot.FindBackupStoreLocation(context.TODO(), clientset, veleroClient, deployOptions.Namespace)
Copy link
Contributor Author

@cbodonnell cbodonnell Nov 20, 2023

Choose a reason for hiding this comment

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

Refactored FindBackupStoreLocation to accept a velero client interface so we can unit test it. A good chunk of the diff is related to this. We could use a similar pattern to increase unit test coverage for snapshots overall.

Comment on lines +71 to +75
headers["X-Replicated-SnapshotProvider"] = reportingInfo.SnapshotProvider
headers["X-Replicated-SnapshotFullSchedule"] = reportingInfo.SnapshotFullSchedule
headers["X-Replicated-SnapshotFullTTL"] = reportingInfo.SnapshotFullTTL
headers["X-Replicated-SnapshotPartialSchedule"] = reportingInfo.SnapshotPartialSchedule
headers["X-Replicated-SnapshotPartialTTL"] = reportingInfo.SnapshotPartialTTL
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Generally followed the pattern we have for GitOps reporting, but do we want to omit these headers if, for example, the provider is empty?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it matters in this case.

func getSnapshotReport(kotsStore store.Store, clientset kubernetes.Interface, veleroClient veleroclientv1.VeleroV1Interface, appID string, clusterID string) (*SnapshotReport, error) {
report := &SnapshotReport{}

bsl, err := snapshot.FindBackupStoreLocation(context.TODO(), clientset, veleroClient, util.PodNamespace)
Copy link
Member

Choose a reason for hiding this comment

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

How about calling this outside of the getSnapshotReport function and pass the BSL as a parameter to avoid refactoring lots of the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

bsl as a parameter to getSnapshotReport makes sense. it still seems like a worthwhile refactor to open up unit testing of snapshot code paths, but i can revert that if needed

sgalsaleh
sgalsaleh previously approved these changes Nov 21, 2023
@cbodonnell cbodonnell requested a review from sgalsaleh November 21, 2023 21:21
sgalsaleh
sgalsaleh previously approved these changes Nov 21, 2023
@cbodonnell cbodonnell merged commit 09f1c18 into main Nov 22, 2023
162 checks passed
@cbodonnell cbodonnell deleted the cbo/sc-89885/snapshot-reporting branch November 22, 2023 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants