Skip to content

Commit

Permalink
reduce the log outputs and fix clusterDeployment.Spec.ClusterMetadata…
Browse files Browse the repository at this point in the history
… could be nil (#465)

Signed-off-by: Zhiwei Yin <[email protected]>
  • Loading branch information
zhiweiyin318 authored Feb 7, 2025
1 parent a147ee4 commit 03b5029
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/bootstrap/bootstrapkubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ func autoDetectCAData(ctx context.Context, clientHolder *helpers.ClientHolder, k
}

// failed to get the ca from ocp, fallback to the kube-root-ca.crt configmap from the pod namespace.
klog.Info(fmt.Sprintf("No ca.crt was found, fallback to the %s/kube-root-ca.crt", caNamespace))
klog.V(5).Info(fmt.Sprintf("No ca.crt was found, fallback to the %s/kube-root-ca.crt", caNamespace))
return getKubeRootCABundle(ctx, clientHolder, caNamespace)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (r *ReconcileClusterDeployment) Reconcile(
return reconcile.Result{}, err
}

reqLogger.Info("Reconciling clusterdeployment")
reqLogger.V(5).Info("Reconciling clusterdeployment")

if !clusterDeployment.DeletionTimestamp.IsZero() {
// We do not set this finalizer anymore, but we still need to remove it for backward compatible
Expand Down Expand Up @@ -137,6 +137,11 @@ func (r *ReconcileClusterDeployment) Reconcile(
return reconcile.Result{}, err
}

if clusterDeployment.Spec.ClusterMetadata == nil {
reqLogger.Info("the clusterMetaData is not updated, skipped", "managedcluster", clusterName)
return reconcile.Result{}, nil
}

secretRefName := clusterDeployment.Spec.ClusterMetadata.AdminKubeconfigSecretRef.Name
hiveSecret, err := r.kubeClient.CoreV1().Secrets(clusterName).Get(ctx, secretRefName, metav1.GetOptions{})
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/clusternamespacedeletion/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (r *ReconcileClusterNamespaceDeletion) Reconcile(ctx context.Context, reque
return reconcile.Result{}, nil
}

reqLogger.Info("Reconciling the managed cluster namespace deletion")
reqLogger.V(5).Info("Reconciling the managed cluster namespace deletion")

managedCluster := &clusterv1.ManagedCluster{}
err = r.client.Get(ctx, types.NamespacedName{Name: request.Name}, managedCluster)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/csr/csr_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (r *ReconcileCSR) Reconcile(ctx context.Context, request reconcile.Request)
return reconcile.Result{}, nil
}

reqLogger.Info("Reconciling CSR")
reqLogger.V(5).Info("Reconciling CSR")

csr = csr.DeepCopy()
csr.Status.Conditions = append(csr.Status.Conditions, certificatesv1.CertificateSigningRequestCondition{
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/hosted/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (r *ReconcileHosted) Reconcile(ctx context.Context, request reconcile.Reque
return reconcile.Result{}, nil
}

reqLogger.Info("Reconciling the manifest works of the hosted mode managed cluster")
reqLogger.V(5).Info("Reconciling the manifest works of the hosted mode managed cluster")

if !managedCluster.DeletionTimestamp.IsZero() {
return r.cleanup(ctx, managedCluster)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/importconfig/importconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (r *ReconcileImportConfig) Reconcile(ctx context.Context, request reconcile
return reconcile.Result{}, err
}

reqLogger.Info("Reconciling managed cluster")
reqLogger.V(5).Info("Reconciling managed cluster")

mode := helpers.DetermineKlusterletMode(managedCluster)
if err := helpers.ValidateKlusterletMode(mode); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/managedcluster/managedcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (r *ReconcileManagedCluster) Reconcile(ctx context.Context, request reconci
return reconcile.Result{}, err
}

reqLogger.Info("Reconciling the managed cluster meta object")
reqLogger.V(5).Info("Reconciling the managed cluster meta object")

if managedCluster.DeletionTimestamp.IsZero() {
if err := r.ensureManagedClusterMetaObj(ctx, managedCluster); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/manifestwork/manifestwork_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (r *ReconcileManifestWork) Reconcile(ctx context.Context, request reconcile
return reconcile.Result{}, nil
}

reqLogger.Info("Reconciling the manifest works of the managed cluster")
reqLogger.V(5).Info("Reconciling the manifest works of the managed cluster")

if !managedCluster.DeletionTimestamp.IsZero() {
// use work client to list all works only when a managed cluster is deleting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (r *ReconcileLocalCluster) Reconcile(ctx context.Context, request reconcile
return reconcile.Result{}, nil
}

reqLogger.Info("Reconciling self managed cluster")
reqLogger.V(5).Info("Reconciling self managed cluster")

// if there is an auto import secret in the managed cluster namespace, we will use the auto import secret to import
// the cluster
Expand Down

0 comments on commit 03b5029

Please sign in to comment.