Skip to content

Commit

Permalink
fix: revert back the optimisation for sync to keep readability
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Chiesa <[email protected]>
  • Loading branch information
gchiesa committed Nov 23, 2023
1 parent d678dca commit 2b100d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions controllers/podlabels/abstract.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"

"github.com/go-logr/logr"
"github.com/pkg/errors"
"github.com/pkg/errors" //nolint:depguard
corev1 "k8s.io/api/core/v1"
apierr "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/fields"
Expand Down Expand Up @@ -55,12 +55,14 @@ func (r *podLabelsReconciler) Reconcile(ctx context.Context, request ctrl.Reques

return reconcile.Result{}, err
}

_, err = controllerutil.CreateOrUpdate(ctx, r.client, r.obj, func() (err error) {
r.obj.SetLabels(r.sync(r.obj.GetLabels(), tenant.Spec.PodOptions.AdditionalMetadata.Labels))
r.obj.SetAnnotations(r.sync(r.obj.GetAnnotations(), tenant.Spec.PodOptions.AdditionalMetadata.Annotations))

return nil
})

return reconcile.Result{}, err
}

Expand Down Expand Up @@ -91,7 +93,7 @@ func (r *podLabelsReconciler) getTenant(ctx context.Context, namespacedName type
func (r *podLabelsReconciler) sync(available map[string]string, tenantSpec map[string]string) map[string]string {
if tenantSpec != nil {
if available == nil {
return tenantSpec
available = tenantSpec
} else {
for key, value := range tenantSpec {
if available[key] != value {
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/pod_options.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020-2021 Clastix Labs
// Copyright 2020-2021 Project Capsule Authors.
// SPDX-License-Identifier: Apache-2.0

package api
Expand Down

0 comments on commit 2b100d0

Please sign in to comment.