Skip to content

Commit

Permalink
Adds missing annotation lastAppliedHashKey in TektonInstaller Set f…
Browse files Browse the repository at this point in the history
…or Tekton Dashboard

  - This patch computes the hash of tektondashboard spec and store as an annotation,
    further reconciliation we compute hash of td spec and check with annotation, if
    they are same then we skip updating the object otherwise we update the manifest

Signed-off-by: Puneet Punamiya <[email protected]>
  • Loading branch information
PuneetPunamiya authored and tekton-robot committed Jan 5, 2022
1 parent 50c93dc commit a9b2343
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/reconciler/kubernetes/tektondashboard/tektondashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,17 @@ func (r *Reconciler) createInstallerSet(ctx context.Context, td *v1alpha1.Tekton
return nil, err
}

// compute the hash of tektondashboard spec and store as an annotation
// in further reconciliation we compute hash of td spec and check with
// annotation, if they are same then we skip updating the object
// otherwise we update the manifest
specHash, err := hash.Compute(td.Spec)
if err != nil {
return nil, err
}

// create installer set
tis := makeInstallerSet(td, manifest, r.releaseVersion)
tis := makeInstallerSet(td, manifest, specHash, r.releaseVersion)
createdIs, err := r.operatorClientSet.OperatorV1alpha1().TektonInstallerSets().
Create(ctx, tis, metav1.CreateOptions{})
if err != nil {
Expand All @@ -335,7 +344,7 @@ func (r *Reconciler) createInstallerSet(ctx context.Context, td *v1alpha1.Tekton
return createdIs, nil
}

func makeInstallerSet(td *v1alpha1.TektonDashboard, manifest mf.Manifest, releaseVersion string) *v1alpha1.TektonInstallerSet {
func makeInstallerSet(td *v1alpha1.TektonDashboard, manifest mf.Manifest, tdSpecHash, releaseVersion string) *v1alpha1.TektonInstallerSet {
ownerRef := *metav1.NewControllerRef(td, td.GetGroupVersionKind())
return &v1alpha1.TektonInstallerSet{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -346,6 +355,7 @@ func makeInstallerSet(td *v1alpha1.TektonDashboard, manifest mf.Manifest, releas
Annotations: map[string]string{
tektoninstallerset.ReleaseVersionKey: releaseVersion,
tektoninstallerset.TargetNamespaceKey: td.Spec.TargetNamespace,
tektoninstallerset.LastAppliedHashKey: tdSpecHash,
},
OwnerReferences: []metav1.OwnerReference{ownerRef},
},
Expand Down

0 comments on commit a9b2343

Please sign in to comment.