Skip to content

Implement backup purge command to purge orphaned snapshots #3520

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

Closed
wants to merge 9 commits into from

Conversation

dkropachev
Copy link
Collaborator

@dkropachev dkropachev commented Aug 9, 2023

Closes #3441

There could be the case when backup task is deleted, but snapshots are left on the location.
So, we need to have a command that deletes these stale snapshots

@dkropachev dkropachev force-pushed the dk/add-restapi_pugre branch 3 times, most recently from a7fa9ec to 7542cbf Compare August 11, 2023 18:54
@dkropachev dkropachev marked this pull request as ready for review September 13, 2023 20:35
@dkropachev dkropachev changed the title Dk/add restapi pugre Implement backup purge command to purge orphaned snapshots Sep 13, 2023
Copy link
Collaborator

@Michal-Leszczynski Michal-Leszczynski left a comment

Choose a reason for hiding this comment

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

Sorry for large amount of comments, most of them are some nit picks that can probably be ignored. I'm curious why there were so many changes in terms of iterating over value vs index in this PR.

Comment on lines 165 to 169
for idx := range l {
if l[idx] == location {
return true
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why iterate over idx instead of the actual value _, loc?
Also, comparing locations by all fields might be misleading, as one of those fields is DC.
I think that we would like to treat locations with the same provider and path as the same regardless of their dc assignment.

Comment on lines 176 to 180
for idx := range l {
if !out.Contains(l[idx]) {
out = append(out, l[idx])
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why iterate over idx instead of the actual value _, loc?

Comment on lines 186 to 190
for idx := range l {
if l[idx].DC != "" {
return true
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why iterate over idx instead of the actual value _, loc?

Comment on lines 336 to 409
_, have := r[taskID]
return have
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't it more idiomatic to call this variable ok?

Comment on lines 355 to 434
func (r RetentionMap) GetPolicy(taskID uuid.UUID, onMissing *RetentionPolicy) *RetentionPolicy {
if policy, ok := r[taskID]; ok {
return &policy
}
return onMissing
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why would it return a pointer?

Comment on lines 263 to 264
err := assertJsonBody(w, golden)
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe combine those two into a single line?

Comment on lines 25 to 31
for _, hi := range hosts {
if _, ok := locations[hi.Location]; ok {
for idx := range hosts {
if _, ok := locations[hosts[idx].Location]; ok {
continue
}
locations[hi.Location] = struct{}{}
locations[hosts[idx].Location] = struct{}{}

lm, err := listManifests(ctx, client, hi.IP, hi.Location, clusterID)
lm, err := listManifests(ctx, client, hosts[idx].IP, hosts[idx].Location, clusterID)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the motivation behind this change?

Comment on lines 35 to 36
for _, h := range hosts {
dc := h.DC
for idx := range hosts {
dc := hosts[idx].DC
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the motivation behind this change?

Comment on lines 179 to 181
for _, h := range hosts {
if h.ID == nodeID {
return h.IP
for idx := range hosts {
if hosts[idx].ID == nodeID {
return hosts[idx].IP
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the motivation behind this change?

Comment on lines 102 to 107
for _, hi := range hosts {
locations[hi.Location.String()] = hi
for idx := range hosts {
locations[hosts[idx].Location.String()] = hosts[idx]
}
hostPerLocation := make([]hostInfo, 0, len(locations))
for _, hi := range locations {
hostPerLocation = append(hostPerLocation, hi)
for key := range locations {
hostPerLocation = append(hostPerLocation, locations[key])
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the motivation behind this change?

@karol-kokoszka
Copy link
Collaborator

@dkropachev are all the @Michal-Leszczynski addressed ? I don't see any responses to Michals questions. Please address the comments and ping for re-review from Michal, otherwise this PR will get stalled.

@dkropachev
Copy link
Collaborator Author

@karol-kokoszka , not yet, I will complete it this week

@karol-kokoszka karol-kokoszka deleted the dk/add-restapi_pugre branch February 14, 2024 21:12
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.

Have a command for purging orphaned snapshots
3 participants