Create event only if creation of PVC failed.

This commit is contained in:
Anirudh 2016-07-12 23:34:28 -07:00
parent bea382c124
commit 467333cc40

View File

@ -231,7 +231,9 @@ func (p *apiServerPetClient) getPVC(pvcName, pvcNamespace string) (*api.Persiste
if errors.IsNotFound(err) {
found = false
}
if err != nil || !found {
if !found {
return nil, found, nil
} else if err != nil {
return nil, found, err
}
return pvc, true, nil
@ -249,7 +251,8 @@ func (p *apiServerPetClient) SyncPVCs(pet *pcb) error {
for i, pvc := range pet.pvcs {
_, exists, err := p.getPVC(pvc.Name, pet.parent.Namespace)
if !exists {
if err := p.createPVC(&pet.pvcs[i]); err != nil {
var err error
if err = p.createPVC(&pet.pvcs[i]); err != nil {
errMsg += fmt.Sprintf("Failed to create %v: %v", pvc.Name, err)
}
p.event(pet.parent, "Create", fmt.Sprintf("pvc: %v", pvc.Name), err)