Skip to content

Commit

Permalink
Merge pull request #206 from ibuildthecloud/master
Browse files Browse the repository at this point in the history
After failing to remove finalizer refresh finalizer list
  • Loading branch information
ibuildthecloud authored Oct 15, 2018
2 parents ad48659 + 296fc76 commit 04cb04a
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions lifecycle/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,22 @@ func (o *objectLifecycleAdapter) finalize(metadata metav1.Object, obj runtime.Ob
}

func (o *objectLifecycleAdapter) removeFinalizer(name string, obj runtime.Object) error {
metadata, err := meta.Accessor(obj)
if err != nil {
return err
}
for i := 0; i < 3; i++ {
metadata, err := meta.Accessor(obj)
if err != nil {
return err
}

var finalizers []string
for _, finalizer := range metadata.GetFinalizers() {
if finalizer == name {
continue
var finalizers []string
for _, finalizer := range metadata.GetFinalizers() {
if finalizer == name {
continue
}
finalizers = append(finalizers, finalizer)
}
finalizers = append(finalizers, finalizer)
}
metadata.SetFinalizers(finalizers)
metadata.SetFinalizers(finalizers)

for i := 0; i < 3; i++ {
_, err := o.objectClient.Update(metadata.GetName(), obj)
_, err = o.objectClient.Update(metadata.GetName(), obj)
if err == nil {
return nil
}
Expand All @@ -121,16 +121,9 @@ func (o *objectLifecycleAdapter) removeFinalizer(name string, obj runtime.Object
if err != nil {
return err
}

metadata, err := meta.Accessor(obj)
if err != nil {
return err
}

metadata.SetFinalizers(finalizers)
}

return fmt.Errorf("failed to remove finalizer on %s:%s", metadata.GetNamespace(), metadata.GetName())
return fmt.Errorf("failed to remove finalizer on %s", name)
}

func (o *objectLifecycleAdapter) createKey() string {
Expand Down

0 comments on commit 04cb04a

Please sign in to comment.