mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Merge pull request #28909 from foxish/foxish-issue-28785
Automatic merge from submit-queue Create event only if creation of PVC failed. Fixes #28785. We should report an event only if the petset can't find a PVC and can't create it either. []()
This commit is contained in:
commit
835ee70c45
@ -231,7 +231,9 @@ func (p *apiServerPetClient) getPVC(pvcName, pvcNamespace string) (*api.Persiste
|
|||||||
if errors.IsNotFound(err) {
|
if errors.IsNotFound(err) {
|
||||||
found = false
|
found = false
|
||||||
}
|
}
|
||||||
if err != nil || !found {
|
if !found {
|
||||||
|
return nil, found, nil
|
||||||
|
} else if err != nil {
|
||||||
return nil, found, err
|
return nil, found, err
|
||||||
}
|
}
|
||||||
return pvc, true, nil
|
return pvc, true, nil
|
||||||
@ -249,7 +251,8 @@ func (p *apiServerPetClient) SyncPVCs(pet *pcb) error {
|
|||||||
for i, pvc := range pet.pvcs {
|
for i, pvc := range pet.pvcs {
|
||||||
_, exists, err := p.getPVC(pvc.Name, pet.parent.Namespace)
|
_, exists, err := p.getPVC(pvc.Name, pet.parent.Namespace)
|
||||||
if !exists {
|
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)
|
errMsg += fmt.Sprintf("Failed to create %v: %v", pvc.Name, err)
|
||||||
}
|
}
|
||||||
p.event(pet.parent, "Create", fmt.Sprintf("pvc: %v", pvc.Name), err)
|
p.event(pet.parent, "Create", fmt.Sprintf("pvc: %v", pvc.Name), err)
|
||||||
|
Loading…
Reference in New Issue
Block a user