Skip to content

Commit

Permalink
Merge pull request #114 from topolvm/fix-periodic-job-deletion
Browse files Browse the repository at this point in the history
fix provision_observer2 to delete failing Jobs correctly
  • Loading branch information
peng225 authored Apr 2, 2024
2 parents 81eb71e + b8496f0 commit 1bb1952
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/controller/provision_observer2.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (p *provisionObserver2) getNodeNameAndStorageClass(ctx context.Context, nam
}

func isProbeJob2(o metav1.OwnerReference) bool {
return o.Kind == "Job" && strings.HasPrefix(o.Name, constants.ProbeNamePrefix)
return o.Kind == "Job" && (strings.HasPrefix(o.Name, constants.MountProbeNamePrefix) || strings.HasPrefix(o.Name, constants.ProvisionProbeNamePrefix))
}

func (p *provisionObserver2) deleteOwnerJobOfPod(ctx context.Context, namespace, podName string) error {
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ var _ = Describe("PieProbe resource", func() {
}
}
}).Should(Succeed())

// Check that failing Jobs are correctly removed.
Eventually(func(g Gomega) {
stdout, _, err := kubectl("get", "job", "-n", ns, "-l", "pie-probe=pie-probe-dummy-sc")
g.Expect(err).NotTo(HaveOccurred())
g.Expect(stdout).Should(BeEmpty())
}).Should(Succeed())
})
})

Expand Down

0 comments on commit 1bb1952

Please sign in to comment.