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

Changed update pod label to use patch #175

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 5 additions & 4 deletions src/operator/controllers/tls_pod/tls_pod_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,17 @@ func (r *PodReconciler) updatePodLabel(ctx context.Context, pod *corev1.Pod, lab

log.Info("updating pod label")

updatedPod := pod.DeepCopy()
if pod.Labels == nil {
pod.Labels = map[string]string{}
updatedPod.Labels = map[string]string{}
}

pod.Labels[labelKey] = labelValue
updatedPod.Labels[labelKey] = labelValue

if err := r.Update(ctx, pod); err != nil {
if err := r.Patch(ctx, updatedPod, client.MergeFrom(pod)); err != nil {
if apierrors.IsConflict(err) || apierrors.IsNotFound(err) || apierrors.IsForbidden(err) {
// The Pod has been updated since we read it.
// Requeue the Pod to try to reconciliate again.
// Requeue the Pod to try to reconcile again.
return ctrl.Result{Requeue: true}, nil
}
if apierrors.IsNotFound(err) {
Expand Down
Loading