Skip to content

Commit

Permalink
fix yurtappoverrider panic for handling normal deployments that has n…
Browse files Browse the repository at this point in the history
…o ownerreferences (#1730)
  • Loading branch information
rambohe-ch authored Oct 10, 2023
1 parent c4aac68 commit 08ae1c7
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,15 @@ func (r *ReconcileYurtAppOverrider) Reconcile(_ context.Context, request reconci
}

for _, deployment := range deployments.Items {
if deployment.OwnerReferences[0].Kind == instance.Subject.Kind && deployment.OwnerReferences[0].Name == instance.Subject.Name {
if deployment.Annotations == nil {
deployment.Annotations = make(map[string]string)
}
deployment.Annotations["LastOverrideTime"] = time.Now().String()
if err := r.Client.Update(context.TODO(), &deployment); err != nil {
return reconcile.Result{}, err
if len(deployment.OwnerReferences) != 0 {
if deployment.OwnerReferences[0].Kind == instance.Subject.Kind && deployment.OwnerReferences[0].Name == instance.Subject.Name {
if deployment.Annotations == nil {
deployment.Annotations = make(map[string]string)
}
deployment.Annotations["LastOverrideTime"] = time.Now().String()
if err := r.Client.Update(context.TODO(), &deployment); err != nil {
return reconcile.Result{}, err
}
}
}
}
Expand Down

0 comments on commit 08ae1c7

Please sign in to comment.