Skip to content

Commit

Permalink
deleting the workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
Ram Lavi authored and RamLavi committed Dec 11, 2019
1 parent 5edc766 commit d3c2981
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions pkg/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"log"
"strings"

"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/api/equality"
Expand Down Expand Up @@ -55,24 +54,6 @@ func ApplyObject(ctx context.Context, client k8sclient.Client, obj *uns.Unstruct
}
if !equality.Semantic.DeepEqual(existing, obj) {
if err := client.Update(ctx, obj); err != nil {
// In older versions of the operator, we used daemon sets of type 'extensions/v1beta1', later we
// changed that to 'apps/v1'. Because of this change, we are not able to seamlessly upgrade using
// only Update methods. Following code handles this exception by deleting the old daemon set and
// creating a new one.
// TODO: Upgrade transaction should be handled by each component module separately. Once we make
// that possible, this exception should be dropped.
bridgeMarkerDaemonSetUpdateError := "DaemonSet.apps \"bridge-marker\" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{\"name\":\"bridge-marker\"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable"
if strings.Contains(err.Error(), bridgeMarkerDaemonSetUpdateError) {
log.Print("update failed due to change in DaemonSet API group; removing original object and recreating")
if err := client.Delete(ctx, existing); err != nil {
return errors.Wrapf(err, "could not delete %s", objDesc)
}
if err := client.Create(ctx, obj); err != nil {
return errors.Wrapf(err, "could not create %s", objDesc)
}
log.Print("update of conflicting DaemonSet was successful")
}

return errors.Wrapf(err, "could not update object %s", objDesc)
} else {
log.Print("update was successful")
Expand Down

0 comments on commit d3c2981

Please sign in to comment.