Skip to content

[wip]Set annotations for the operator Deployment created via the ClusterServiceVersion #3339

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

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pkg/controller/install/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func NewStrategyDeploymentInstaller(strategyClient wrappers.InstallStrategyDeplo

func (i *StrategyDeploymentInstaller) installDeployments(deps []v1alpha1.StrategyDeploymentSpec) error {
for _, d := range deps {
deployment, _, err := i.deploymentForSpec(d.Name, d.Spec, d.Label)
deployment, _, err := i.deploymentForSpec(d.Name, d.Spec, d.Label, d.Annotations)
if err != nil {
return err
}
Expand Down Expand Up @@ -134,11 +134,14 @@ func (i *StrategyDeploymentInstaller) createOrUpdateCertResourcesForDeployment()
return nil
}

func (i *StrategyDeploymentInstaller) deploymentForSpec(name string, spec appsv1.DeploymentSpec, specLabels k8slabels.Set) (deployment *appsv1.Deployment, hash string, err error) {
func (i *StrategyDeploymentInstaller) deploymentForSpec(name string, spec appsv1.DeploymentSpec, specLabels k8slabels.Set, specAnnotations map[string]string) (deployment *appsv1.Deployment, hash string, err error) {
dep := &appsv1.Deployment{Spec: spec}
dep.SetName(name)
dep.SetNamespace(i.owner.GetNamespace())

// Set custom annotations
dep.SetAnnotations(specAnnotations)

// Merge annotations (to avoid losing info from pod template)
annotations := map[string]string{}
for k, v := range dep.Spec.Template.GetAnnotations() {
Expand Down Expand Up @@ -282,7 +285,7 @@ func (i *StrategyDeploymentInstaller) checkForDeployments(deploymentSpecs []v1al
return StrategyError{Reason: StrategyErrDeploymentUpdated, Message: fmt.Sprintf("deployment %s doesn't have a spec hash, update it", dep.Name)}
}

_, calculatedDeploymentHash, err := i.deploymentForSpec(spec.Name, spec.Spec, labels)
_, calculatedDeploymentHash, err := i.deploymentForSpec(spec.Name, spec.Spec, labels, dep.GetAnnotations())
if err != nil {
return StrategyError{Reason: StrategyErrDeploymentUpdated, Message: fmt.Sprintf("couldn't calculate deployment spec hash: %v", err)}
}
Expand Down