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

Add timestamp annotation on update #1148

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions internal/cli/install/helm/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ import (
"helm.sh/helm/v3/pkg/storage/driver"
"k8s.io/client-go/rest"

"github.com/kubeshop/botkube/internal/cli"
"github.com/kubeshop/botkube/internal/cli/helmx"
"github.com/kubeshop/botkube/internal/cli/install/iox"
"github.com/kubeshop/botkube/internal/cli/printer"
)

const restartAnnotationFmt = "extraAnnotations.cli\\.botkube\\.io\\/restart\\-timestamp=\"%d\""

// Run provides single function signature both for install and upgrade.
type Run func(ctx context.Context, relName string, chart *chart.Chart, vals map[string]any) (*release.Release, error)

Expand Down Expand Up @@ -77,6 +80,15 @@ func (c *Helm) Install(ctx context.Context, status *printer.StatusPrinter, opts
return nil, errors.New("upgrade aborted")
}
}
restartAnnotation := fmt.Sprintf(restartAnnotationFmt, time.Now().Unix())
if cli.VerboseMode.IsEnabled() {
status.Step("Appending %q Pod annotation to enforce Pod restart", restartAnnotation)
} else {
status.Step("Appending Pod annotation to enforce Pod restart")
}
opts.Values.Values = append(opts.Values.Values, restartAnnotation)
status.End(true)

runFn = c.upgradeAction(opts)
case err == driver.ErrReleaseNotFound:
runFn = c.installAction(opts)
Expand Down
Loading