From b75a3eaef3696416e7407b8819d8832e31c6b696 Mon Sep 17 00:00:00 2001 From: Avinash Patnala Date: Wed, 25 Sep 2024 18:25:35 +0000 Subject: [PATCH] address review comments Signed-off-by: Avinash Patnala --- apis/status/v1beta1/configpodstatus_types.go | 8 ++++++++ pkg/controller/config/config_controller.go | 2 +- pkg/controller/configstatus/configstatus_controller.go | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apis/status/v1beta1/configpodstatus_types.go b/apis/status/v1beta1/configpodstatus_types.go index 641bbfdd35c..014fa69739e 100644 --- a/apis/status/v1beta1/configpodstatus_types.go +++ b/apis/status/v1beta1/configpodstatus_types.go @@ -81,6 +81,14 @@ func NewConfigStatusForPod(pod *corev1.Pod, configNamespace string, configName s // KeyForConfig returns a unique status object name given the Pod ID and // a config object. +// The object name must satisfy RFC 1123 Label Names spec +// (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/) +// and Kubernetes validation rules for object names. +// +// It's possible that dash packing/unpacking would result in a name +// that exceeds the maximum length allowed, but for Config resources, +// the configName should always be "config", and namespace would be "gatekeeper-system", +// so this validation will hold. func KeyForConfig(id string, configNamespace string, configName string) (string, error) { return DashPacker(id, configNamespace, configName) } diff --git a/pkg/controller/config/config_controller.go b/pkg/controller/config/config_controller.go index d085493450c..afe0cd7adc7 100644 --- a/pkg/controller/config/config_controller.go +++ b/pkg/controller/config/config_controller.go @@ -223,7 +223,7 @@ func (r *ReconcileConfig) Reconcile(ctx context.Context, request reconcile.Reque if deleted { return reconcile.Result{}, r.deleteStatus(ctx, request.NamespacedName.Namespace, request.NamespacedName.Name) } - return reconcile.Result{}, r.updateOrCreatePodStatus(ctx, instance, err) + return reconcile.Result{}, r.updateOrCreatePodStatus(ctx, instance, nil) } func (r *ReconcileConfig) deleteStatus(ctx context.Context, cfgNamespace string, cfgName string) error { diff --git a/pkg/controller/configstatus/configstatus_controller.go b/pkg/controller/configstatus/configstatus_controller.go index 8e647d95d54..b0bae57e02a 100644 --- a/pkg/controller/configstatus/configstatus_controller.go +++ b/pkg/controller/configstatus/configstatus_controller.go @@ -104,7 +104,6 @@ func PodStatusToConfigMapper(selfOnly bool) handler.TypedMapFunc[*v1beta1.Config // Add creates a new config status Controller and adds it to the Manager. The Manager will set fields on the Controller // and Start it when the Manager is Started. func add(mgr manager.Manager, r reconcile.Reconciler) error { - // Create a new controller c, err := controller.New("config-status-controller", mgr, controller.Options{Reconciler: r}) if err != nil { return err @@ -125,7 +124,8 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { var _ reconcile.Reconciler = &ReconcileConfigStatus{} -// ReconcileConfigStatus reconciles an arbitrary config object described by Kind. +// ReconcileConfigStatus provides the dependencies required to reconcile +// the status of a Config resource. type ReconcileConfigStatus struct { reader client.Reader writer client.Writer