On delete, also attempt to update controller state, in case we

missed a previous update.  Add a test to validate that this works
This commit is contained in:
Brendan Burns
2014-06-18 20:25:25 -07:00
parent e2974a0a75
commit 84b2a9e9f3
2 changed files with 49 additions and 1 deletions

View File

@@ -148,7 +148,21 @@ func (rm *ReplicationManager) handleWatchResponse(response *etcd.Response) (*api
} else {
return nil, fmt.Errorf("response node is null %#v", response)
}
} else if response.Action == "delete" {
// Ensure that the final state of a replication controller is applied before it is deleted.
// Otherwise, a replication controller could be modified and then deleted (for example, from 3 to 0
// replicas), and it would be non-deterministic which of its pods continued to exist.
if response.PrevNode != nil {
var controllerSpec api.ReplicationController
if err := json.Unmarshal([]byte(response.PrevNode.Value), &controllerSpec); err != nil {
return nil, err
}
return &controllerSpec, nil
} else {
return nil, fmt.Errorf("previous node is null %#v", response)
}
}
return nil, nil
}