Skip to content

Commit 1e0dddc

Browse files
committed
Add namespace and DSPA name in Reconciler logs
1 parent c99a8ca commit 1e0dddc

File tree

9 files changed

+42
-26
lines changed

9 files changed

+42
-26
lines changed

controllers/apiserver.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package controllers
1717

1818
import (
1919
"context"
20+
2021
dspav1alpha1 "github.com/opendatahub-io/data-science-pipelines-operator/api/v1alpha1"
2122
v1 "github.com/openshift/api/route/v1"
2223
corev1 "k8s.io/api/core/v1"
@@ -48,13 +49,14 @@ var samplePipelineTemplates = map[string]string{
4849
}
4950

5051
func (r *DSPAReconciler) ReconcileAPIServer(ctx context.Context, dsp *dspav1alpha1.DataSciencePipelinesApplication, params *DSPAParams) error {
52+
log := r.Log.WithValues("namespace", dsp.Namespace).WithValues("dspa_name", dsp.Name)
5153

5254
if !dsp.Spec.APIServer.Deploy {
5355
r.Log.Info("Skipping Application of APIServer Resources")
5456
return nil
5557
}
5658

57-
r.Log.Info("Applying APIServer Resources")
59+
log.Info("Applying APIServer Resources")
5860

5961
for _, template := range apiServerTemplates {
6062
err := r.Apply(dsp, params, template)
@@ -93,6 +95,6 @@ func (r *DSPAReconciler) ReconcileAPIServer(ctx context.Context, dsp *dspav1alph
9395
}
9496
}
9597

96-
r.Log.Info("Finished applying APIServer Resources")
98+
log.Info("Finished applying APIServer Resources")
9799
return nil
98100
}

controllers/common.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ var commonTemplates = []string{
2626
const commonCusterRolebindingTemplate = "common/clusterrolebinding.yaml.tmpl"
2727

2828
func (r *DSPAReconciler) ReconcileCommon(dsp *dspav1alpha1.DataSciencePipelinesApplication, params *DSPAParams) error {
29-
r.Log.Info("Applying Common Resources")
29+
log := r.Log.WithValues("namespace", dsp.Namespace).WithValues("dspa_name", dsp.Name)
3030

31-
r.Log.Info("Applying Common Resources")
31+
log.Info("Applying Common Resources")
3232
for _, template := range commonTemplates {
3333
err := r.Apply(dsp, params, template)
3434
if err != nil {
@@ -41,7 +41,7 @@ func (r *DSPAReconciler) ReconcileCommon(dsp *dspav1alpha1.DataSciencePipelinesA
4141
return err
4242
}
4343

44-
r.Log.Info("Finished applying Common Resources")
44+
log.Info("Finished applying Common Resources")
4545
return nil
4646
}
4747

controllers/database.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package controllers
1717

1818
import (
1919
"context"
20+
2021
dspav1alpha1 "github.com/opendatahub-io/data-science-pipelines-operator/api/v1alpha1"
2122
)
2223

@@ -33,6 +34,8 @@ var dbTemplates = []string{
3334
func (r *DSPAReconciler) ReconcileDatabase(ctx context.Context, dsp *dspav1alpha1.DataSciencePipelinesApplication,
3435
params *DSPAParams) error {
3536

37+
log := r.Log.WithValues("namespace", dsp.Namespace).WithValues("dspa_name", dsp.Name)
38+
3639
databaseSpecified := dsp.Spec.Database != nil
3740
// DB field can be specified as an empty obj, confirm that subfields are also specified
3841
// By default if Database is empty, we deploy mariadb
@@ -42,15 +45,15 @@ func (r *DSPAReconciler) ReconcileDatabase(ctx context.Context, dsp *dspav1alpha
4245

4346
// If external db is specified, it takes precedence
4447
if externalDBSpecified {
45-
r.Log.Info("Deploying external db secret.")
48+
log.Info("Deploying external db secret.")
4649
// If using external DB, we just need to create the secret
4750
// for apiserver
4851
err := r.Apply(dsp, params, dbSecret)
4952
if err != nil {
5053
return err
5154
}
5255
} else if deployMariaDB {
53-
r.Log.Info("Applying mariaDB resources.")
56+
log.Info("Applying mariaDB resources.")
5457
for _, template := range dbTemplates {
5558
err := r.Apply(dsp, params, template)
5659
if err != nil {
@@ -69,11 +72,11 @@ func (r *DSPAReconciler) ReconcileDatabase(ctx context.Context, dsp *dspav1alpha
6972
}
7073
}
7174
} else {
72-
r.Log.Info("No externalDB detected, and mariaDB disabled. " +
75+
log.Info("No externalDB detected, and mariaDB disabled. " +
7376
"skipping Application of DB Resources")
7477
return nil
7578
}
76-
r.Log.Info("Finished applying Database Resources")
79+
log.Info("Finished applying Database Resources")
7780

7881
return nil
7982
}

controllers/dspipeline_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (r *DSPAReconciler) isDeploymentAvailable(ctx context.Context, dspa *dspav1
163163
//+kubebuilder:rbac:groups=monitoring.coreos.com,resources=servicemonitors,verbs=get;list;watch;create;update;patch;delete
164164

165165
func (r *DSPAReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
166-
log := r.Log.WithValues("namespace", req.Namespace)
166+
log := r.Log.WithValues("namespace", req.Namespace).WithValues("dspa_name", req.Name)
167167

168168
log.V(1).Info("DataSciencePipelinesApplication Reconciler called.")
169169

controllers/mlpipeline_ui.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,21 @@ var mlPipelineUITemplates = []string{
3434
func (r *DSPAReconciler) ReconcileUI(dsp *dspav1alpha1.DataSciencePipelinesApplication,
3535
params *DSPAParams) error {
3636

37+
log := r.Log.WithValues("namespace", dsp.Namespace).WithValues("dspa_name", dsp.Name)
38+
3739
if dsp.Spec.MlPipelineUI == nil || !dsp.Spec.MlPipelineUI.Deploy {
38-
r.Log.Info("Skipping Application of MlPipelineUI Resources")
40+
log.Info("Skipping Application of MlPipelineUI Resources")
3941
return nil
4042
}
4143

42-
r.Log.Info("Applying MlPipelineUI Resources")
44+
log.Info("Applying MlPipelineUI Resources")
4345
for _, template := range mlPipelineUITemplates {
4446
err := r.Apply(dsp, params, template)
4547
if err != nil {
4648
return err
4749
}
4850
}
4951

50-
r.Log.Info("Applying MlPipelineUI Resources")
52+
log.Info("Applying MlPipelineUI Resources")
5153
return nil
5254
}

controllers/persistence_agent.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ var persistenceAgentTemplates = []string{
3030
func (r *DSPAReconciler) ReconcilePersistenceAgent(dsp *dspav1alpha1.DataSciencePipelinesApplication,
3131
params *DSPAParams) error {
3232

33+
log := r.Log.WithValues("namespace", dsp.Namespace).WithValues("dspa_name", dsp.Name)
34+
3335
if !dsp.Spec.PersistenceAgent.Deploy {
34-
r.Log.Info("Skipping Application of PersistenceAgent Resources")
36+
log.Info("Skipping Application of PersistenceAgent Resources")
3537
return nil
3638
}
3739

38-
r.Log.Info("Applying PersistenceAgent Resources")
40+
log.Info("Applying PersistenceAgent Resources")
3941

4042
for _, template := range persistenceAgentTemplates {
4143
err := r.Apply(dsp, params, template)
@@ -44,6 +46,6 @@ func (r *DSPAReconciler) ReconcilePersistenceAgent(dsp *dspav1alpha1.DataScience
4446
}
4547
}
4648

47-
r.Log.Info("Finished applying PersistenceAgent Resources")
49+
log.Info("Finished applying PersistenceAgent Resources")
4850
return nil
4951
}

controllers/scheduled_workflow.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ var scheduledWorkflowTemplates = []string{
3232
func (r *DSPAReconciler) ReconcileScheduledWorkflow(dsp *dspav1alpha1.DataSciencePipelinesApplication,
3333
params *DSPAParams) error {
3434

35+
log := r.Log.WithValues("namespace", dsp.Namespace).WithValues("dspa_name", dsp.Name)
36+
3537
if !dsp.Spec.ScheduledWorkflow.Deploy {
36-
r.Log.Info("Skipping Application of ScheduledWorkflow Resources")
38+
log.Info("Skipping Application of ScheduledWorkflow Resources")
3739
return nil
3840
}
3941

40-
r.Log.Info("Applying ScheduledWorkflow Resources")
42+
log.Info("Applying ScheduledWorkflow Resources")
4143

4244
for _, template := range scheduledWorkflowTemplates {
4345
err := r.Apply(dsp, params, template)
@@ -46,6 +48,6 @@ func (r *DSPAReconciler) ReconcileScheduledWorkflow(dsp *dspav1alpha1.DataScienc
4648
}
4749
}
4850

49-
r.Log.Info("Finished applying ScheduledWorkflow Resources")
51+
log.Info("Finished applying ScheduledWorkflow Resources")
5052
return nil
5153
}

controllers/storage.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package controllers
1818

1919
import (
2020
"context"
21+
2122
dspav1alpha1 "github.com/opendatahub-io/data-science-pipelines-operator/api/v1alpha1"
2223
)
2324

@@ -34,6 +35,8 @@ var storageTemplates = []string{
3435
func (r *DSPAReconciler) ReconcileStorage(ctx context.Context, dsp *dspav1alpha1.DataSciencePipelinesApplication,
3536
params *DSPAParams) error {
3637

38+
log := r.Log.WithValues("namespace", dsp.Namespace).WithValues("dspa_name", dsp.Name)
39+
3740
storageSpecified := dsp.Spec.ObjectStorage != nil
3841
// Storage field can be specified as an empty obj, confirm that subfields are also specified
3942
externalStorageSpecified := params.UsingExternalStorage(dsp)
@@ -42,15 +45,15 @@ func (r *DSPAReconciler) ReconcileStorage(ctx context.Context, dsp *dspav1alpha1
4245

4346
// If external storage is specified, it takes precedence
4447
if externalStorageSpecified {
45-
r.Log.Info("Deploying external storage secret.")
48+
log.Info("Deploying external storage secret.")
4649
// If using external storage, we just need to create the secret
4750
// for apiserver
4851
err := r.Apply(dsp, params, storageSecret)
4952
if err != nil {
5053
return err
5154
}
5255
} else if deployMinio {
53-
r.Log.Info("Applying object storage resources.")
56+
log.Info("Applying object storage resources.")
5457
for _, template := range storageTemplates {
5558
err := r.Apply(dsp, params, template)
5659
if err != nil {
@@ -69,11 +72,11 @@ func (r *DSPAReconciler) ReconcileStorage(ctx context.Context, dsp *dspav1alpha1
6972
}
7073
}
7174
} else {
72-
r.Log.Info("No externalstorage detected, and minio disabled. " +
75+
log.Info("No externalstorage detected, and minio disabled. " +
7376
"skipping application of storage Resources")
7477
return nil
7578
}
76-
r.Log.Info("Finished applying storage Resources")
79+
log.Info("Finished applying storage Resources")
7780

7881
return nil
7982
}

controllers/viewer_crd.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ var viewerCRDTemplates = []string{
3030
func (r *DSPAReconciler) ReconcileViewerCRD(dsp *dspav1alpha1.DataSciencePipelinesApplication,
3131
params *DSPAParams) error {
3232

33+
log := r.Log.WithValues("namespace", dsp.Namespace).WithValues("dspa_name", dsp.Name)
34+
3335
if !dsp.Spec.ViewerCRD.Deploy {
34-
r.Log.Info("Skipping Application of ViewerCRD Resources")
36+
log.Info("Skipping Application of ViewerCRD Resources")
3537
return nil
3638
}
3739

38-
r.Log.Info("Applying ViewerCRD Resources")
40+
log.Info("Applying ViewerCRD Resources")
3941

4042
for _, template := range viewerCRDTemplates {
4143
err := r.Apply(dsp, params, template)
@@ -44,6 +46,6 @@ func (r *DSPAReconciler) ReconcileViewerCRD(dsp *dspav1alpha1.DataSciencePipelin
4446
}
4547
}
4648

47-
r.Log.Info("Finished applying ViewerCRD Resources")
49+
log.Info("Finished applying ViewerCRD Resources")
4850
return nil
4951
}

0 commit comments

Comments
 (0)