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

[v0.10] Propagate drift correction force mode to Helm rollback #2836

Merged
Show file tree
Hide file tree
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
21 changes: 17 additions & 4 deletions e2e/drift/drift_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,26 @@ var _ = Describe("Drift", Ordered, func() {
GinkgoWriter.Print(out)
})

It("Status is modified", func() {
// Note: more accurate checks on status changes are now done in integration tests.
It("Corrects drift when drift correction is set to force", func() {
Eventually(func() string {
out, _ := k.Namespace(env.Namespace).Get("bundles", bundleName, "-o=jsonpath={.status.conditions[*].message}")
return out
}).Should(ContainSubstring(`service.v1 drift/drift-dummy-service modified {"spec":{"ports":[` +
`{"name":"http","port":80,"protocol":"TCP","targetPort":"http-web-svc"},` +
`{"name":"http","port":1234,"protocol":"TCP","targetPort":"http-web-svc"}]}}`))
}).Should(ContainSubstring(`service.v1 drift/drift-dummy-service modified`))

out, err := k.Patch(
"gitrepo",
"drift-correction-test",
"--type=merge",
"-p",
`{"spec":{"correctDrift":{"force": true}}}`,
)
Expect(err).ToNot(HaveOccurred(), out)
GinkgoWriter.Print(out)
Eventually(func() string {
out, _ := k.Namespace(env.Namespace).Get("bundles", bundleName, "-o=jsonpath={.status.conditions[*].message}")
return out
}).ShouldNot(ContainSubstring(`drift-dummy-service modified`))
})
})

Expand Down
2 changes: 1 addition & 1 deletion integrationtests/agent/bundle_deployment_drift_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ var _ = Describe("BundleDeployment drift correction", Ordered, func() {
}))
})

Context("A release resource is modified", func() {
Context("A release resource is modified", Ordered, func() {
It("Receives a modification on a service", func() {
svc, err := env.getService(svcName)
Expect(err).NotTo(HaveOccurred())
Expand Down
3 changes: 3 additions & 0 deletions internal/helmdeployer/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ func (h *Helm) install(ctx context.Context, bundleID string, manifest *manifest.
u.TakeOwnership = true
u.EnableDNS = !options.Helm.DisableDNS
u.Force = options.Helm.Force
if options.CorrectDrift != nil {
u.Force = u.Force || options.CorrectDrift.Force
}
u.Atomic = options.Helm.Atomic
u.MaxHistory = options.Helm.MaxHistory
if u.MaxHistory == 0 {
Expand Down
Loading