Skip to content

Commit

Permalink
Read live Job state for replaceUnready check (#1578)
Browse files Browse the repository at this point in the history
The check added in de129e3 mistakenly did not check the
live status of the Job, but instead checked the user inputs.
This would lead to erroneous replacements for ready Jobs.
  • Loading branch information
lblackstone committed May 14, 2021
1 parent de129e3 commit 170e01f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Allow opting out of CRD rendering for Helm v3 by specifying `SkipCRDRendering` argument to Helm charts. (https://github.com/pulumi/pulumi-kubernetes/pull/1572)
- Add replaceUnready annotation for Jobs. (https://github.com/pulumi/pulumi-kubernetes/pull/1575)
- Read live Job state for replaceUnready check. (https://github.com/pulumi/pulumi-kubernetes/pull/1578)

## 3.1.2 (May 12, 2021)

Expand Down
17 changes: 10 additions & 7 deletions provider/pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1372,13 +1372,16 @@ func (k *kubeProvider) Diff(
if metadata.ReplaceUnready(newInputs) {
switch newInputs.GetKind() {
case "Job":
jobChecker := states.NewJobChecker()
job, err := clients.FromUnstructured(newInputs)
if err == nil {
jobChecker.Update(job)
if !jobChecker.Ready() {
hasChanges = pulumirpc.DiffResponse_DIFF_SOME
replaces = append(replaces, `.metadata.annotations["pulumi.com/replaceUnready"]`)
// Fetch current Job status and check point-in-time readiness. Errors are ignored.
if live, err := k.readLiveObject(newInputs); err == nil {
jobChecker := states.NewJobChecker()
job, err := clients.FromUnstructured(live)
if err == nil {
jobChecker.Update(job)
if !jobChecker.Ready() {
hasChanges = pulumirpc.DiffResponse_DIFF_SOME
replaces = append(replaces, `.metadata.annotations["pulumi.com/replaceUnready"]`)
}
}
}
default:
Expand Down

0 comments on commit 170e01f

Please sign in to comment.