Skip to content

Conversation

@josephsawaya
Copy link

@josephsawaya josephsawaya commented Jul 18, 2022

This PR adds rollback so fetchit won't
have deployed only part of a set of changes
so the state will only correspond to one commit
at a time.

This PR adds simple rollback by trying to
undo the changes made during a failed Apply by
Applying in the opposite direction.

Signed-off-by: Joseph Sawaya [email protected]

type empty struct {
}

var badCommitList map[plumbing.Hash]empty = make(map[plumbing.Hash]empty)
Copy link

@jeffvance jeffvance Jul 18, 2022

Choose a reason for hiding this comment

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

super nit: it may be more idiomatic to see:
var badCommitList map[plumbing.Hash]struct{} = make(map[plumbing.Hash]struct{})
rather than defining empty

@josephsawaya josephsawaya changed the title [wip] fix raw and add rollback Fix raw and add rollback Jul 20, 2022
Copy link
Collaborator

@sallyom sallyom left a comment

Choose a reason for hiding this comment

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

I commented on the single-line errors nit that keeps me up at night.
If it's possible, add a workflow for this b4 merging.
Other than that, lgtm and rollback ftw!

@josephsawaya josephsawaya changed the title Fix raw and add rollback Add rollback Aug 30, 2022
@josephsawaya josephsawaya force-pushed the rollback branch 3 times, most recently from 566eee1 to 79a8c10 Compare August 31, 2022 16:49
This commit adds simple rollback by trying to
undo the changes made during a failed Apply by
Applying in the opposite direction.

Signed-off-by: Joseph Sawaya <[email protected]>
}

if _, ok := BadCommitList[directory][m.GetKind()][latest]; ok {
klog.Infof("No changes applied to target %s this run, %s currently at %s", directory, m.GetKind(), current)
Copy link
Collaborator

Choose a reason for hiding this comment

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

update klog.Infof to logger.Infof - we transitioned to using zap for logging #225

if err = m.Apply(ctx, conn, current, latest, tag); err != nil {
if target.rollback {
// Roll back automatically
klog.Errorf("Failed to apply changes, rolling back to %v: %v", current, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

klog.Errorf -> logger.Errorf

Copy link
Collaborator

@sallyom sallyom left a comment

Choose a reason for hiding this comment

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

  • update klog to logger & then run go mod tidy; go mod vendor (might need to run go mod tidy -compat=1.17, since it will try to be compatible with go 1.16 and fail)
  • I'm wondering if we should include the opt-in & the boolean type for Rollback - we're only doing that for now bc it's new, right? Maybe we should remove the option and make it the default - but still opt-in for trackBadCommits. wdyt? @cooktheryan ?

@sallyom
Copy link
Collaborator

sallyom commented Sep 2, 2022

#242 discussion on whether fetchit should/should not track bad commits

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.

3 participants