diff --git a/components/codeflare/codeflare.go b/components/codeflare/codeflare.go index 758b18d84dd..cd6a1839674 100644 --- a/components/codeflare/codeflare.go +++ b/components/codeflare/codeflare.go @@ -8,7 +8,6 @@ import ( "fmt" "path/filepath" - "github.com/go-logr/logr" operatorv1 "github.com/openshift/api/operator/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -17,6 +16,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/components" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" + logf "sigs.k8s.io/controller-runtime/pkg/log" ) var ( @@ -59,7 +59,6 @@ func (c *CodeFlare) GetComponentName() string { func (c *CodeFlare) ReconcileComponent(ctx context.Context, cli client.Client, - l logr.Logger, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, @@ -68,6 +67,7 @@ func (c *CodeFlare) ReconcileComponent(ctx context.Context, "codeflare-operator-controller-image": "RELATED_IMAGE_ODH_CODEFLARE_OPERATOR_IMAGE", // no need mcad, embedded in cfo } + l := logf.FromContext(ctx) enabled := c.GetManagementState() == operatorv1.Managed monitoringEnabled := dscispec.Monitoring.ManagementState == operatorv1.Managed diff --git a/components/component.go b/components/component.go index 7fe17d6c8c8..e42b400a318 100644 --- a/components/component.go +++ b/components/component.go @@ -77,7 +77,7 @@ type ManifestsConfig struct { } type ComponentInterface interface { - ReconcileComponent(ctx context.Context, cli client.Client, logger logr.Logger, + ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, DSCISpec *dsciv1.DSCInitializationSpec, platform cluster.Platform, currentComponentStatus bool) error Cleanup(ctx context.Context, cli client.Client, owner metav1.Object, DSCISpec *dsciv1.DSCInitializationSpec) error GetComponentName() string diff --git a/components/dashboard/dashboard.go b/components/dashboard/dashboard.go index 7ab0e73d2d1..089a64ec251 100644 --- a/components/dashboard/dashboard.go +++ b/components/dashboard/dashboard.go @@ -20,6 +20,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/components" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" + logf "sigs.k8s.io/controller-runtime/pkg/log" ) var ( @@ -62,12 +63,12 @@ func (d *Dashboard) GetComponentName() string { func (d *Dashboard) ReconcileComponent(ctx context.Context, cli client.Client, - l logr.Logger, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, currentComponentExist bool, ) error { + l := logf.FromContext(ctx) entryPath := map[cluster.Platform]string{ cluster.SelfManagedRhods: PathDownstream + "/onprem", cluster.ManagedRhods: PathDownstream + "/addon", diff --git a/components/datasciencepipelines/datasciencepipelines.go b/components/datasciencepipelines/datasciencepipelines.go index f7e1289b10f..74372335542 100644 --- a/components/datasciencepipelines/datasciencepipelines.go +++ b/components/datasciencepipelines/datasciencepipelines.go @@ -8,7 +8,6 @@ import ( "fmt" "path/filepath" - "github.com/go-logr/logr" operatorv1 "github.com/openshift/api/operator/v1" conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1" corev1 "k8s.io/api/core/v1" @@ -23,6 +22,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/metadata/labels" + logf "sigs.k8s.io/controller-runtime/pkg/log" ) var ( @@ -65,12 +65,12 @@ func (d *DataSciencePipelines) GetComponentName() string { func (d *DataSciencePipelines) ReconcileComponent(ctx context.Context, cli client.Client, - l logr.Logger, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool, ) error { + l := logf.FromContext(ctx) var imageParamMap = map[string]string{ // v1 "IMAGES_APISERVER": "RELATED_IMAGE_ODH_ML_PIPELINES_API_SERVER_IMAGE", diff --git a/components/kserve/kserve.go b/components/kserve/kserve.go index 03dd94a7e5d..301748816b2 100644 --- a/components/kserve/kserve.go +++ b/components/kserve/kserve.go @@ -8,7 +8,6 @@ import ( "path/filepath" "strings" - "github.com/go-logr/logr" operatorv1 "github.com/openshift/api/operator/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -18,6 +17,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/components" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" + logf "sigs.k8s.io/controller-runtime/pkg/log" ) var ( @@ -95,7 +95,8 @@ func (k *Kserve) GetComponentName() string { } func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client, - l logr.Logger, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error { + owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error { + l := logf.FromContext(ctx) // dependentParamMap for odh-model-controller to use. var dependentParamMap = map[string]string{ "odh-model-controller": "RELATED_IMAGE_ODH_MODEL_CONTROLLER_IMAGE", diff --git a/components/kueue/kueue.go b/components/kueue/kueue.go index 0d15ae2b6d3..a24a3f88783 100644 --- a/components/kueue/kueue.go +++ b/components/kueue/kueue.go @@ -6,7 +6,6 @@ import ( "fmt" "path/filepath" - "github.com/go-logr/logr" operatorv1 "github.com/openshift/api/operator/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -15,6 +14,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/components" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" + logf "sigs.k8s.io/controller-runtime/pkg/log" ) var ( @@ -53,8 +53,9 @@ func (k *Kueue) GetComponentName() string { return ComponentName } -func (k *Kueue) ReconcileComponent(ctx context.Context, cli client.Client, l logr.Logger, +func (k *Kueue) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error { + l := logf.FromContext(ctx) var imageParamMap = map[string]string{ "odh-kueue-controller-image": "RELATED_IMAGE_ODH_KUEUE_CONTROLLER_IMAGE", // new kueue image } diff --git a/components/modelmeshserving/modelmeshserving.go b/components/modelmeshserving/modelmeshserving.go index 9e343d1a9ce..2ccff4a25cc 100644 --- a/components/modelmeshserving/modelmeshserving.go +++ b/components/modelmeshserving/modelmeshserving.go @@ -8,7 +8,6 @@ import ( "path/filepath" "strings" - "github.com/go-logr/logr" operatorv1 "github.com/openshift/api/operator/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -17,6 +16,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/components" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" + logf "sigs.k8s.io/controller-runtime/pkg/log" ) var ( @@ -73,12 +73,12 @@ func (m *ModelMeshServing) GetComponentName() string { func (m *ModelMeshServing) ReconcileComponent(ctx context.Context, cli client.Client, - l logr.Logger, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool, ) error { + l := logf.FromContext(ctx) var imageParamMap = map[string]string{ "odh-mm-rest-proxy": "RELATED_IMAGE_ODH_MM_REST_PROXY_IMAGE", "odh-modelmesh-runtime-adapter": "RELATED_IMAGE_ODH_MODELMESH_RUNTIME_ADAPTER_IMAGE", diff --git a/components/modelregistry/modelregistry.go b/components/modelregistry/modelregistry.go index c58f6bb15dc..5750388e5e2 100644 --- a/components/modelregistry/modelregistry.go +++ b/components/modelregistry/modelregistry.go @@ -10,7 +10,6 @@ import ( "strings" "text/template" - "github.com/go-logr/logr" operatorv1 "github.com/openshift/api/operator/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -22,6 +21,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/conversion" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" + logf "sigs.k8s.io/controller-runtime/pkg/log" _ "embed" ) @@ -80,8 +80,9 @@ func (m *ModelRegistry) GetComponentName() string { return ComponentName } -func (m *ModelRegistry) ReconcileComponent(ctx context.Context, cli client.Client, l logr.Logger, +func (m *ModelRegistry) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error { + l := logf.FromContext(ctx) var imageParamMap = map[string]string{ "IMAGES_MODELREGISTRY_OPERATOR": "RELATED_IMAGE_ODH_MODEL_REGISTRY_OPERATOR_IMAGE", "IMAGES_GRPC_SERVICE": "RELATED_IMAGE_ODH_MLMD_GRPC_SERVER_IMAGE", diff --git a/components/ray/ray.go b/components/ray/ray.go index dd0dd18ed95..14fa7db5afd 100644 --- a/components/ray/ray.go +++ b/components/ray/ray.go @@ -8,7 +8,6 @@ import ( "fmt" "path/filepath" - "github.com/go-logr/logr" operatorv1 "github.com/openshift/api/operator/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -17,6 +16,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/components" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" + logf "sigs.k8s.io/controller-runtime/pkg/log" ) var ( @@ -55,8 +55,9 @@ func (r *Ray) GetComponentName() string { return ComponentName } -func (r *Ray) ReconcileComponent(ctx context.Context, cli client.Client, l logr.Logger, +func (r *Ray) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error { + l := logf.FromContext(ctx) var imageParamMap = map[string]string{ "odh-kuberay-operator-controller-image": "RELATED_IMAGE_ODH_KUBERAY_OPERATOR_CONTROLLER_IMAGE", } diff --git a/components/trainingoperator/trainingoperator.go b/components/trainingoperator/trainingoperator.go index 1e1de97679c..d750bd82368 100644 --- a/components/trainingoperator/trainingoperator.go +++ b/components/trainingoperator/trainingoperator.go @@ -8,7 +8,6 @@ import ( "fmt" "path/filepath" - "github.com/go-logr/logr" operatorv1 "github.com/openshift/api/operator/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -17,6 +16,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/components" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" + logf "sigs.k8s.io/controller-runtime/pkg/log" ) var ( @@ -55,8 +55,9 @@ func (r *TrainingOperator) GetComponentName() string { return ComponentName } -func (r *TrainingOperator) ReconcileComponent(ctx context.Context, cli client.Client, l logr.Logger, +func (r *TrainingOperator) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error { + l := logf.FromContext(ctx) var imageParamMap = map[string]string{ "odh-training-operator-controller-image": "RELATED_IMAGE_ODH_TRAINING_OPERATOR_IMAGE", } diff --git a/components/trustyai/trustyai.go b/components/trustyai/trustyai.go index 049b63b1d6c..349b9e4d010 100644 --- a/components/trustyai/trustyai.go +++ b/components/trustyai/trustyai.go @@ -7,7 +7,6 @@ import ( "fmt" "path/filepath" - "github.com/go-logr/logr" operatorv1 "github.com/openshift/api/operator/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -16,6 +15,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/components" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" + logf "sigs.k8s.io/controller-runtime/pkg/log" ) var ( @@ -56,8 +56,9 @@ func (t *TrustyAI) GetComponentName() string { return ComponentName } -func (t *TrustyAI) ReconcileComponent(ctx context.Context, cli client.Client, l logr.Logger, +func (t *TrustyAI) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error { + l := logf.FromContext(ctx) var imageParamMap = map[string]string{ "trustyaiServiceImage": "RELATED_IMAGE_ODH_TRUSTYAI_SERVICE_IMAGE", "trustyaiOperatorImage": "RELATED_IMAGE_ODH_TRUSTYAI_SERVICE_OPERATOR_IMAGE", diff --git a/components/workbenches/workbenches.go b/components/workbenches/workbenches.go index 3570cf096ac..901c4c5212f 100644 --- a/components/workbenches/workbenches.go +++ b/components/workbenches/workbenches.go @@ -8,7 +8,6 @@ import ( "path/filepath" "strings" - "github.com/go-logr/logr" operatorv1 "github.com/openshift/api/operator/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -18,6 +17,7 @@ import ( "github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/metadata/labels" + logf "sigs.k8s.io/controller-runtime/pkg/log" ) var ( @@ -90,8 +90,9 @@ func (w *Workbenches) GetComponentName() string { return ComponentName } -func (w *Workbenches) ReconcileComponent(ctx context.Context, cli client.Client, l logr.Logger, +func (w *Workbenches) ReconcileComponent(ctx context.Context, cli client.Client, owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error { + l := logf.FromContext(ctx) var imageParamMap = map[string]string{ "odh-notebook-controller-image": "RELATED_IMAGE_ODH_NOTEBOOK_CONTROLLER_IMAGE", "odh-kf-notebook-controller-image": "RELATED_IMAGE_ODH_KF_NOTEBOOK_CONTROLLER_IMAGE", diff --git a/controllers/datasciencecluster/datasciencecluster_controller.go b/controllers/datasciencecluster/datasciencecluster_controller.go index ce4f0209ec8..5d3052e1f98 100644 --- a/controllers/datasciencecluster/datasciencecluster_controller.go +++ b/controllers/datasciencecluster/datasciencecluster_controller.go @@ -313,8 +313,8 @@ func (r *DataScienceClusterReconciler) reconcileSubComponent(ctx context.Context } } // Reconcile component - componentLogger := log.WithName(componentName) - err := component.ReconcileComponent(ctx, r.Client, componentLogger, instance, r.DataScienceCluster.DSCISpec, platform, installedComponentValue) + componentCtx := logf.IntoContext(ctx, log.WithName(componentName)) + err := component.ReconcileComponent(componentCtx, r.Client, instance, r.DataScienceCluster.DSCISpec, platform, installedComponentValue) // TODO: replace this hack with a full refactor of component status in the future