Skip to content

Commit

Permalink
fix(clustertool): When flux-bootstrap fails, ensure rename change is …
Browse files Browse the repository at this point in the history
…undone first
  • Loading branch information
PrivatePuffin committed Nov 9, 2024
1 parent a62135c commit 55284f8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions clustertool/pkg/fluxhandler/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ func setupFluxCD(ctx context.Context, fluxPath string) error {

if err := kubectlcmds.KubectlApplyKustomize(ctx, fluxPath); err != nil {
log.Error().Err(err).Str("path", fluxPath).Msg("Error applying FluxCD manifest")
log.Debug().Msg("Reverting renamed files for fluxbootstrap")
if err := os.Rename(filepath.Join(fluxPath, kustomFile), filepath.Join(fluxPath, bootstrapFile)); err != nil {
log.Error().Err(err).Msg("Error renaming kustomization file back after previous error")
return err
}
if err := os.Rename(filepath.Join(fluxPath, tmpFile), filepath.Join(fluxPath, kustomFile)); err != nil {
log.Error().Err(err).Msg("Error renaming placeholder file after previous back")
return err
}
return err
}

Expand Down

0 comments on commit 55284f8

Please sign in to comment.