Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1898045: redeploy CSI Controller Deployment when secret changes #104

Merged
merged 2 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 11 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ go 1.14

require (
github.com/go-bindata/go-bindata v3.1.2+incompatible
github.com/openshift/api v0.0.0-20200827090112-c05698d102cf
github.com/openshift/build-machinery-go v0.0.0-20200819073603-48aa266c95f7
github.com/openshift/client-go v0.0.0-20200827190008-3062137373b5
github.com/openshift/library-go v0.0.0-20201006115306-ed636feadb9c
github.com/openshift/api v0.0.0-20201214114959-164a2fb63b5f
github.com/openshift/build-machinery-go v0.0.0-20200917070002-f171684f77ab
github.com/openshift/client-go v0.0.0-20201214125552-e615e336eb49
github.com/openshift/library-go v0.0.0-20210106214821-c4d0b9c8d55f
github.com/prometheus/client_golang v1.7.1
github.com/spf13/cobra v1.0.0
github.com/spf13/cobra v1.1.1
github.com/spf13/pflag v1.0.5
k8s.io/api v0.19.0
k8s.io/apimachinery v0.19.0
k8s.io/client-go v0.19.0
k8s.io/component-base v0.19.0
k8s.io/klog/v2 v2.3.0
github.com/ugorji/go v1.1.4 // indirect
k8s.io/api v0.20.0
k8s.io/apimachinery v0.20.0
k8s.io/client-go v0.20.0
k8s.io/component-base v0.20.0
k8s.io/klog/v2 v2.4.0
)
204 changes: 204 additions & 0 deletions go.sum

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions pkg/operator/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/openshift/library-go/pkg/controller/factory"
"github.com/openshift/library-go/pkg/operator/events"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubeclient "k8s.io/client-go/kubernetes"
Expand All @@ -21,6 +22,7 @@ import (
"github.com/openshift/library-go/pkg/controller/controllercmd"
"github.com/openshift/library-go/pkg/operator/csi/csicontrollerset"
goc "github.com/openshift/library-go/pkg/operator/genericoperatorclient"
"github.com/openshift/library-go/pkg/operator/resource/resourcehash"
"github.com/openshift/library-go/pkg/operator/resourcesynccontroller"
"github.com/openshift/library-go/pkg/operator/v1helpers"

Expand All @@ -33,6 +35,7 @@ const (
operatorName = "aws-ebs-csi-driver-operator"
operandName = "aws-ebs-csi-driver"
instanceName = "ebs.csi.aws.com"
secretName = "ebs-cloud-credentials"

cloudConfigNamespace = "openshift-config-managed"
cloudConfigName = "kube-cloud-config"
Expand Down Expand Up @@ -90,6 +93,7 @@ func RunOperator(ctx context.Context, controllerConfig *controllercmd.Controller
kubeClient,
kubeInformersForNamespaces.InformersFor(defaultNamespace),
configInformers,
withSecretHashAnnotation(kubeInformersForNamespaces, defaultNamespace, secretName),
).WithCSIDriverNodeService(
"AWSEBSDriverNodeServiceController",
generated.MustAsset,
Expand Down Expand Up @@ -196,3 +200,28 @@ func isCustomCABundleUsed(kubeClient kubeclient.Interface) (bool, error) {
_, exists := cloudConfigCM.Data[caBundleKey]
return exists, nil
}

func withSecretHashAnnotation(kubeInformersForNamespaces v1helpers.KubeInformersForNamespaces, namespace, secret string) func(*appsv1.Deployment) error {
return func(deployment *appsv1.Deployment) error {
inputHashes, err := resourcehash.MultipleObjectHashStringMapForObjectReferenceFromLister(
kubeInformersForNamespaces.InformersFor(namespace).Core().V1().ConfigMaps().Lister(),
kubeInformersForNamespaces.InformersFor(namespace).Core().V1().Secrets().Lister(),
resourcehash.NewObjectRef().ForSecret().InNamespace(namespace).Named(secret),
)
if err != nil {
return fmt.Errorf("invalid dependency reference: %w", err)
}
if deployment.Annotations == nil {
deployment.Annotations = map[string]string{}
}
if deployment.Spec.Template.Annotations == nil {
deployment.Spec.Template.Annotations = map[string]string{}
}
for k, v := range inputHashes {
annotationKey := fmt.Sprintf("operator.openshift.io/dep-%s", k)
deployment.Annotations[annotationKey] = v
deployment.Spec.Template.Annotations[annotationKey] = v
}
return nil
}
}
21 changes: 21 additions & 0 deletions vendor/github.com/blang/semver/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion vendor/github.com/blang/semver/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/blang/semver/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/golang/protobuf/proto/text_decode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 55 additions & 28 deletions vendor/github.com/google/go-cmp/cmp/compare.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/google/go-cmp/cmp/export_panic.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions vendor/github.com/google/go-cmp/cmp/export_unsafe.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion vendor/github.com/google/go-cmp/cmp/internal/diff/diff.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.