Skip to content

Commit

Permalink
Don't replace service account with update-aws-node (#2459)
Browse files Browse the repository at this point in the history
* Don't replace service account with update-aws-node

* Slight refactor of UpdateAWSNode

* Add log message when skipping service account
  • Loading branch information
michaelbeaumont committed Jul 21, 2020
1 parent bcbc2f1 commit 08ebdc1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
28 changes: 20 additions & 8 deletions pkg/addons/default/aws_node.go
Expand Up @@ -45,7 +45,8 @@ func UpdateAWSNode(rawClient kubernetes.RawClientInterface, region string, plan
if err != nil {
return false, err
}
if resource.GVK.Kind == "DaemonSet" {
switch resource.GVK.Kind {
case "DaemonSet":
daemonSet, ok := resource.Info.Object.(*appsv1.DaemonSet)
if !ok {
return false, fmt.Errorf("expected type %T; got %T", &appsv1.Deployment{}, resource.Info.Object)
Expand All @@ -67,13 +68,24 @@ func UpdateAWSNode(rawClient kubernetes.RawClientInterface, region string, plan
if err != nil {
return false, err
}
}

if resource.GVK.Kind == "CustomResourceDefinition" && plan {
// eniconfigs.crd.k8s.amazonaws.com CRD is only partially defined in the
// manifest, and causes a range of issue in plan mode, we can skip it
logger.Info(resource.LogAction(plan, "replaced"))
continue
case "CustomResourceDefinition":
if plan {
// eniconfigs.crd.k8s.amazonaws.com CRD is only partially defined in the
// manifest, and causes a range of issue in plan mode, we can skip it
logger.Info(resource.LogAction(plan, "replaced"))
continue
}
case "ServiceAccount":
// Leave service account if it exists
// to avoid overwriting annotations
_, exists, err := resource.Get()
if err != nil {
return false, err
}
if exists {
logger.Info(resource.LogAction(plan, "skipped existing"))
continue
}
}

status, err := resource.CreateOrReplace(plan)
Expand Down
6 changes: 5 additions & 1 deletion pkg/addons/default/aws_node_test.go
Expand Up @@ -3,6 +3,7 @@ package defaultaddons_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gstruct"

. "github.com/weaveworks/eksctl/pkg/addons/default"

Expand Down Expand Up @@ -56,7 +57,10 @@ var _ = Describe("default addons - aws-node", func() {

_, err := UpdateAWSNode(rawClient, "eu-west-1", false)
Expect(err).ToNot(HaveOccurred())
Expect(rawClient.Collection.UpdatedItems()).To(HaveLen(4))
Expect(rawClient.Collection.UpdatedItems()).To(HaveLen(3))
Expect(rawClient.Collection.UpdatedItems()).ToNot(ContainElement(PointTo(MatchFields(IgnoreMissing|IgnoreExtras, Fields{
"TypeMeta": MatchFields(IgnoreMissing|IgnoreExtras, Fields{"Kind": Equal("ServiceAccount")}),
}))))
Expect(rawClient.Collection.CreatedItems()).To(HaveLen(10))

rawClient.ClientSetUseUpdatedObjects = true // for verification of updated objects
Expand Down

0 comments on commit 08ebdc1

Please sign in to comment.