Refactor to contextual logging (#1283)
Some checks failed
Scorecard supply-chain security / Scorecard analysis (push) Failing after 1m25s
Post / coverage (push) Failing after 36m59s
Post / images (amd64, addon-manager) (push) Failing after 7m34s
Post / images (amd64, placement) (push) Failing after 7m4s
Post / images (amd64, registration) (push) Failing after 7m8s
Post / images (amd64, registration-operator) (push) Failing after 7m3s
Post / images (amd64, work) (push) Failing after 6m59s
Post / images (arm64, addon-manager) (push) Failing after 7m0s
Post / images (arm64, placement) (push) Failing after 6m54s
Post / images (arm64, registration) (push) Failing after 6m55s
Post / images (arm64, registration-operator) (push) Failing after 6m55s
Post / images (arm64, work) (push) Failing after 7m16s
Post / image manifest (addon-manager) (push) Has been skipped
Post / image manifest (placement) (push) Has been skipped
Post / image manifest (registration) (push) Has been skipped
Post / image manifest (registration-operator) (push) Has been skipped
Post / image manifest (work) (push) Has been skipped
Post / trigger clusteradm e2e (push) Has been skipped

Signed-off-by: Jian Qiu <jqiu@redhat.com>
This commit is contained in:
Jian Qiu
2025-12-08 16:14:30 +08:00
committed by GitHub
parent 1d80709753
commit 99265f6113
29 changed files with 142 additions and 111 deletions

View File

@@ -207,7 +207,7 @@ func (i *Importer) reconcile(
return cluster, err
}
}
crdObjs, rawObjs, err := chart.RenderKlusterletChart(klusterletChartConfig, klusterletNamespace)
crdObjs, rawObjs, err := chart.RenderKlusterletChart(ctx, klusterletChartConfig, klusterletNamespace)
if err != nil {
return cluster, err
}

View File

@@ -2,6 +2,7 @@ package hub
import (
"context"
"os"
"time"
"github.com/openshift/library-go/pkg/controller/controllercmd"
@@ -12,6 +13,7 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/metadata"
"k8s.io/client-go/rest"
"k8s.io/klog/v2"
generate "k8s.io/kubectl/pkg/generate"
cpclientset "sigs.k8s.io/cluster-inventory-api/client/clientset/versioned"
cpinformerv1alpha1 "sigs.k8s.io/cluster-inventory-api/client/informers/externalversions"
@@ -111,6 +113,14 @@ func (m *HubManagerOptions) AddFlags(fs *pflag.FlagSet) {
// RunControllerManager starts the controllers on hub to manage spoke cluster registration.
func (m *HubManagerOptions) RunControllerManager(ctx context.Context, controllerContext *controllercmd.ControllerContext) error {
// setting up contextual logger
logger := klog.NewKlogr()
podName := os.Getenv("POD_NAME")
if podName != "" {
logger = logger.WithValues("podName", podName)
}
ctx = klog.NewContext(ctx, logger)
kubeClient, err := kubernetes.NewForConfig(controllerContext.KubeConfig)
if err != nil {
return err

View File

@@ -115,6 +115,14 @@ func (o *SpokeAgentConfig) HealthCheckers() []healthz.HealthChecker {
// - the client certificate referenced by the hub kubeconfig become expired (Return failure when
// checking the health of the agent);
func (o *SpokeAgentConfig) RunSpokeAgent(ctx context.Context, controllerContext *controllercmd.ControllerContext) error {
// setting up contextual logger
logger := klog.NewKlogr()
podName := os.Getenv("POD_NAME")
if podName != "" {
logger = logger.WithValues("podName", podName, "clusterName", o.agentOptions.SpokeClusterName)
}
ctx = klog.NewContext(ctx, logger)
kubeConfig := controllerContext.KubeConfig
// load spoke client config and create spoke clients,