Skip to content

Commit

Permalink
Propagate drift correction force mode to Helm rollback (#2798)
Browse files Browse the repository at this point in the history
* Propagate drift correction force mode to Helm

This enables drift correction to be forced after the fact, which can
help users deal with edge cases such as patching ports on services, a
case known not to be supported [1] by Helm.

[1]: helm/helm#12974

* Remove service status drift end-to-end test case

That test case is now covered in integration tests.

* Order service drift integration tests

This may reduce the risk of flakiness.
  • Loading branch information
weyfonk committed Sep 16, 2024
1 parent f4bef08 commit ba5ffb0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
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

0 comments on commit ba5ffb0

Please sign in to comment.