Reset start failure tracking on manual change request
@@ -135,6 +135,9 @@ func (app *SubresourceAPIApp) getVirtHandlerConnForVMI(vmi *v1.VirtualMachineIns
}
func getChangeRequestJson(vm *v1.VirtualMachine, changes ...v1.VirtualMachineStateChangeRequest) (string, error) {
+
+ var ops []string
+
verb := "add"
// Special case: if there's no status field at all, add one.
newStatus := v1.VirtualMachineStatus{}
@@ -146,10 +149,8 @@ func getChangeRequestJson(vm *v1.VirtualMachine, changes ...v1.VirtualMachineSta
if err != nil {
return "", err
}
- update := fmt.Sprintf(`{ "op": "%s", "path": "/status", "value": %s}`, verb, string(statusJson))
-
- return fmt.Sprintf("[%s]", update), nil
- }
+ ops = append(ops, fmt.Sprintf(`{ "op": "%s", "path": "/status", "value": %s}`, verb, string(statusJson)))
+ } else {
failOnConflict := true
if len(changes) == 1 && changes[0].Action == v1.StopRequest {
@@ -182,7 +183,16 @@ func getChangeRequestJson(vm *v1.VirtualMachine, changes ...v1.VirtualMachineSta
test := fmt.Sprintf(`{ "op": "test", "path": "/status/stateChangeRequests", "value": %s}`, string(oldChangeRequestsJson))
update := fmt.Sprintf(`{ "op": "%s", "path": "/status/stateChangeRequests", "value": %s}`, verb, string(newChangeRequestsJson))
- return fmt.Sprintf("[%s, %s]", test, update), nil
+
+ ops = append(ops, test)
+ ops = append(ops, update)
+ }
+
+ if vm.Status.StartFailure != nil {
+ ops = append(ops, `{ "op": "remove", "path": "/status/startFailure" }`)
+ }
+
+ return string(controller.GeneratePatchBytes(ops)), nil
}
func getRunningJson(vm *v1.VirtualMachine, running bool) string {
