Skip to content

Commit

Permalink
reconcile components local deployment changes with installersets
Browse files Browse the repository at this point in the history
Signed-off-by: Jeeva Kandasamy <[email protected]>
  • Loading branch information
jkandasa authored and tekton-robot committed Aug 30, 2023
1 parent e0507dc commit 9a03455
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/reconciler/kubernetes/tektoninstallerset/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,9 @@ func (i *installer) ensureDeployment(expected *unstructured.Unstructured) error
if err != nil {
return err
}
existingHashValue, hashFound := existingAnnotations[v1alpha1.LastAppliedHashKey]

// if hash doesn't exist then update the deployment
if !hashFound {
if _, hashFound := existingAnnotations[v1alpha1.LastAppliedHashKey]; !hashFound {
doUpdateDeployment = true
}

Expand All @@ -323,6 +322,17 @@ func (i *installer) ensureDeployment(expected *unstructured.Unstructured) error
return fmt.Errorf("failed to compute hash value of expected deployment, name:%s, error: %v", expected.GetName(), err)
}

// get existing hash value: always compute the hash value from the deployment spec, do not care about the hash value from annotation
// computing hash value from the spec can indicate, if there is change found in the deployed deployment.spec
existingDeployment := &appsv1.Deployment{}
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(existing.Object, existingDeployment); err != nil {
return err
}
existingHashValue, err := hash.Compute(existingDeployment.Spec)
if err != nil {
return fmt.Errorf("failed to compute hash value of existing deployment, name:%s, error: %v", existing.GetName(), err)
}

// if both hashes are same, that means deployment on cluster is the same as when it was created
doUpdateDeployment = existingHashValue != expectedHashValue
}
Expand Down

0 comments on commit 9a03455

Please sign in to comment.