Merge pull request #657 from schylek/patch-test-fix

Loosen test conditions for patching VPA objects.
This commit is contained in:
Marcin Wielgus 2018-02-15 17:05:40 +01:00 committed by GitHub
commit b1935fc0d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 9 deletions

View File

@ -71,22 +71,17 @@ func UpdateVpaStatus(vpaClient vpa_api.VerticalPodAutoscalerInterface, vpa *mode
patches := make([]patchRecord, 0) patches := make([]patchRecord, 0)
// Verify that Status was not updated in the meantime to avoid a race // Verify that Status was not updated in the meantime to avoid a race condition.
// condition. // If LastUpdateTime is not set patch is executed unconditionally (it is a low
// risk race condition).
if !vpa.LastUpdateTime.IsZero() { if !vpa.LastUpdateTime.IsZero() {
patches = append(patches, patchRecord{ patches = append(patches, patchRecord{
Op: "test", Op: "test",
Path: "/status/lastUpdateTime", Path: "/status/lastUpdateTime",
Value: metav1.NewTime(vpa.LastUpdateTime), Value: metav1.NewTime(vpa.LastUpdateTime),
}) })
} else {
// Status field not set yet.
patches = append(patches, patchRecord{
Op: "test",
Path: "/status",
Value: nil,
})
} }
patches = append(patches, patchRecord{ patches = append(patches, patchRecord{
Op: "add", Op: "add",
Path: "/status", Path: "/status",