diff --git a/pkg/openstack/cinder.go b/pkg/openstack/cinder.go index 01f5daccc..3b8118661 100644 --- a/pkg/openstack/cinder.go +++ b/pkg/openstack/cinder.go @@ -11,6 +11,7 @@ import ( cinderv1 "github.com/openstack-k8s-operators/cinder-operator/api/v1beta1" corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + "github.com/openstack-k8s-operators/openstack-operator/controllers/core" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" ) @@ -31,8 +32,9 @@ func ReconcileCinder(ctx context.Context, instance *corev1beta1.OpenStackControl instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneCinderReadyCondition) return ctrl.Result{}, nil } + l := core.GetLog(ctx) - helper.GetLogger().Info("Reconciling Cinder", "Cinder.Namespace", instance.Namespace, "Cinder.Name", "cinder") + l.Info("Reconciling Cinder", "Cinder.Namespace", instance.Namespace, "Cinder.Name", "cinder") op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), cinder, func() error { instance.Spec.Cinder.Template.DeepCopyInto(&cinder.Spec) if cinder.Spec.Secret == "" { @@ -77,7 +79,7 @@ func ReconcileCinder(ctx context.Context, instance *corev1beta1.OpenStackControl return ctrl.Result{}, err } if op != controllerutil.OperationResultNone { - helper.GetLogger().Info(fmt.Sprintf("Cinder %s - %s", cinder.Name, op)) + l.Info(fmt.Sprintf("Cinder %s - %s", cinder.Name, op)) } if cinder.IsReady() { diff --git a/pkg/openstack/galera.go b/pkg/openstack/galera.go index b83240524..c987ce0fa 100644 --- a/pkg/openstack/galera.go +++ b/pkg/openstack/galera.go @@ -12,6 +12,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + "github.com/openstack-k8s-operators/openstack-operator/controllers/core" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" ) @@ -93,6 +94,7 @@ func reconcileGalera( Namespace: instance.Namespace, }, } + l := core.GetLog(ctx) if !instance.Spec.Galera.Enabled { if _, err := EnsureDeleted(ctx, helper, galera); err != nil { @@ -102,7 +104,7 @@ func reconcileGalera( return galeraReady, nil } - helper.GetLogger().Info("Reconciling Galera", "Galera.Namespace", instance.Namespace, "Galera.Name", name) + l.Info("Reconciling Galera", "Galera.Namespace", instance.Namespace, "Galera.Name", name) op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), galera, func() error { spec.DeepCopyInto(&galera.Spec) if galera.Spec.Secret == "" { @@ -123,7 +125,7 @@ func reconcileGalera( return galeraFailed, err } if op != controllerutil.OperationResultNone { - helper.GetLogger().Info(fmt.Sprintf("Galera %s - %s", galera.Name, op)) + l.Info(fmt.Sprintf("Galera %s - %s", galera.Name, op)) } if galera.IsReady() { diff --git a/pkg/openstack/glance.go b/pkg/openstack/glance.go index 5decc025b..dade955d0 100644 --- a/pkg/openstack/glance.go +++ b/pkg/openstack/glance.go @@ -11,6 +11,7 @@ import ( glancev1 "github.com/openstack-k8s-operators/glance-operator/api/v1beta1" corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + "github.com/openstack-k8s-operators/openstack-operator/controllers/core" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" ) @@ -24,6 +25,8 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl }, } + l := core.GetLog(ctx) + if !instance.Spec.Glance.Enabled { if res, err := EnsureDeleted(ctx, helper, glance); err != nil { return res, err @@ -32,7 +35,7 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl return ctrl.Result{}, nil } - helper.GetLogger().Info("Reconciling Glance", "Glance.Namespace", instance.Namespace, "Glance.Name", "glance") + l.Info("Reconciling Glance", "Glance.Namespace", instance.Namespace, "Glance.Name", "glance") op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), glance, func() error { instance.Spec.Glance.Template.DeepCopyInto(&glance.Spec) if glance.Spec.Secret == "" { @@ -76,7 +79,7 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl return ctrl.Result{}, err } if op != controllerutil.OperationResultNone { - helper.GetLogger().Info(fmt.Sprintf("glance %s - %s", glance.Name, op)) + l.Info(fmt.Sprintf("glance %s - %s", glance.Name, op)) } if glance.IsReady() { diff --git a/pkg/openstack/horizon.go b/pkg/openstack/horizon.go index 84f7a6ed8..4e8b08ab9 100644 --- a/pkg/openstack/horizon.go +++ b/pkg/openstack/horizon.go @@ -11,6 +11,7 @@ import ( horizonv1 "github.com/openstack-k8s-operators/horizon-operator/api/v1beta1" corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + "github.com/openstack-k8s-operators/openstack-operator/controllers/core" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" ) @@ -23,6 +24,7 @@ func ReconcileHorizon(ctx context.Context, instance *corev1beta1.OpenStackContro Namespace: instance.Namespace, }, } + l := core.GetLog(ctx) if !instance.Spec.Horizon.Enabled { if res, err := EnsureDeleted(ctx, helper, horizon); err != nil { @@ -31,7 +33,7 @@ func ReconcileHorizon(ctx context.Context, instance *corev1beta1.OpenStackContro instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneHorizonReadyCondition) return ctrl.Result{}, nil } - helper.GetLogger().Info("Reconcile Horizon", "horizon.Namespace", instance.Namespace, "horizon.Name", "horizon") + l.Info("Reconcile Horizon", "horizon.Namespace", instance.Namespace, "horizon.Name", "horizon") op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), horizon, func() error { instance.Spec.Horizon.Template.DeepCopyInto(&horizon.Spec) err := controllerutil.SetControllerReference(helper.GetBeforeObject(), horizon, helper.GetScheme()) @@ -51,7 +53,7 @@ func ReconcileHorizon(ctx context.Context, instance *corev1beta1.OpenStackContro return ctrl.Result{}, err } if op != controllerutil.OperationResultNone { - helper.GetLogger().Info(fmt.Sprintf("Horizon %s - %s", horizon.Name, op)) + l.Info(fmt.Sprintf("Horizon %s - %s", horizon.Name, op)) } if horizon.IsReady() { diff --git a/pkg/openstack/ironic.go b/pkg/openstack/ironic.go index d207ccb5e..ec144c812 100644 --- a/pkg/openstack/ironic.go +++ b/pkg/openstack/ironic.go @@ -11,6 +11,7 @@ import ( ironicv1 "github.com/openstack-k8s-operators/ironic-operator/api/v1beta1" corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + "github.com/openstack-k8s-operators/openstack-operator/controllers/core" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" ) @@ -23,6 +24,7 @@ func ReconcileIronic(ctx context.Context, instance *corev1beta1.OpenStackControl Namespace: instance.Namespace, }, } + l := core.GetLog(ctx) if !instance.Spec.Ironic.Enabled { if res, err := EnsureDeleted(ctx, helper, ironic); err != nil { @@ -32,7 +34,7 @@ func ReconcileIronic(ctx context.Context, instance *corev1beta1.OpenStackControl return ctrl.Result{}, nil } - helper.GetLogger().Info("Reconciling Ironic", "Ironic.Namespace", instance.Namespace, "Ironic.Name", "ironic") + l.Info("Reconciling Ironic", "Ironic.Namespace", instance.Namespace, "Ironic.Name", "ironic") op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), ironic, func() error { instance.Spec.Ironic.Template.DeepCopyInto(&ironic.Spec) err := controllerutil.SetControllerReference(helper.GetBeforeObject(), ironic, helper.GetScheme()) @@ -52,7 +54,7 @@ func ReconcileIronic(ctx context.Context, instance *corev1beta1.OpenStackControl return ctrl.Result{}, err } if op != controllerutil.OperationResultNone { - helper.GetLogger().Info(fmt.Sprintf("ironic %s - %s", ironic.Name, op)) + l.Info(fmt.Sprintf("ironic %s - %s", ironic.Name, op)) } if ironic.IsReady() { diff --git a/pkg/openstack/keystone.go b/pkg/openstack/keystone.go index b84846c9b..a2f6698b3 100644 --- a/pkg/openstack/keystone.go +++ b/pkg/openstack/keystone.go @@ -11,6 +11,7 @@ import ( keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1" corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + "github.com/openstack-k8s-operators/openstack-operator/controllers/core" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" ) @@ -24,6 +25,8 @@ func ReconcileKeystoneAPI(ctx context.Context, instance *corev1beta1.OpenStackCo }, } + l := core.GetLog(ctx) + if !instance.Spec.Keystone.Enabled { if res, err := EnsureDeleted(ctx, helper, keystoneAPI); err != nil { return res, err @@ -32,7 +35,7 @@ func ReconcileKeystoneAPI(ctx context.Context, instance *corev1beta1.OpenStackCo return ctrl.Result{}, nil } - helper.GetLogger().Info("Reconciling KeystoneAPI", "KeystoneAPI.Namespace", instance.Namespace, "KeystoneAPI.Name", "keystone") + l.Info("Reconciling KeystoneAPI", "KeystoneAPI.Namespace", instance.Namespace, "KeystoneAPI.Name", "keystone") op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), keystoneAPI, func() error { instance.Spec.Keystone.Template.DeepCopyInto(&keystoneAPI.Spec) if keystoneAPI.Spec.Secret == "" { @@ -62,7 +65,7 @@ func ReconcileKeystoneAPI(ctx context.Context, instance *corev1beta1.OpenStackCo return ctrl.Result{}, err } if op != controllerutil.OperationResultNone { - helper.GetLogger().Info(fmt.Sprintf("KeystoneAPI %s - %s", keystoneAPI.Name, op)) + l.Info(fmt.Sprintf("KeystoneAPI %s - %s", keystoneAPI.Name, op)) } if keystoneAPI.IsReady() { diff --git a/pkg/openstack/manila.go b/pkg/openstack/manila.go index a32cd7b8f..de05cbc19 100644 --- a/pkg/openstack/manila.go +++ b/pkg/openstack/manila.go @@ -11,6 +11,7 @@ import ( manilav1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1" corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + "github.com/openstack-k8s-operators/openstack-operator/controllers/core" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" ) @@ -23,6 +24,7 @@ func ReconcileManila(ctx context.Context, instance *corev1beta1.OpenStackControl Namespace: instance.Namespace, }, } + l := core.GetLog(ctx) if !instance.Spec.Manila.Enabled { if res, err := EnsureDeleted(ctx, helper, manila); err != nil { @@ -32,7 +34,7 @@ func ReconcileManila(ctx context.Context, instance *corev1beta1.OpenStackControl return ctrl.Result{}, nil } - helper.GetLogger().Info("Reconciling Manila", "Manila.Namespace", instance.Namespace, "Manila.Name", "manila") + l.Info("Reconciling Manila", "Manila.Namespace", instance.Namespace, "Manila.Name", "manila") op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), manila, func() error { instance.Spec.Manila.Template.DeepCopyInto(&manila.Spec) if manila.Spec.Secret == "" { @@ -77,7 +79,7 @@ func ReconcileManila(ctx context.Context, instance *corev1beta1.OpenStackControl return ctrl.Result{}, err } if op != controllerutil.OperationResultNone { - helper.GetLogger().Info(fmt.Sprintf("Manila %s - %s", manila.Name, op)) + l.Info(fmt.Sprintf("Manila %s - %s", manila.Name, op)) } if manila.IsReady() { diff --git a/pkg/openstack/memcached.go b/pkg/openstack/memcached.go index 1e039d6ae..c933a7673 100644 --- a/pkg/openstack/memcached.go +++ b/pkg/openstack/memcached.go @@ -12,6 +12,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + "github.com/openstack-k8s-operators/openstack-operator/controllers/core" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -138,6 +139,8 @@ func reconcileMemcached( }, } + l := core.GetLog(ctx) + if !instance.Spec.Memcached.Enabled { if _, err := EnsureDeleted(ctx, helper, memcached); err != nil { return memcachedFailed, err @@ -146,7 +149,7 @@ func reconcileMemcached( return memcachedReady, nil } - helper.GetLogger().Info("Reconciling Memcached", "Memcached.Namespace", instance.Namespace, "Memcached.Name", name) + l.Info("Reconciling Memcached", "Memcached.Namespace", instance.Namespace, "Memcached.Name", name) op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), memcached, func() error { spec.DeepCopyInto(&memcached.Spec) err := controllerutil.SetControllerReference(helper.GetBeforeObject(), memcached, helper.GetScheme()) @@ -161,7 +164,7 @@ func reconcileMemcached( return memcachedFailed, err } if op != controllerutil.OperationResultNone { - helper.GetLogger().Info(fmt.Sprintf("Memcached %s - %s", memcached.Name, op)) + l.Info(fmt.Sprintf("Memcached %s - %s", memcached.Name, op)) } if memcached.IsReady() { diff --git a/pkg/openstack/neutron.go b/pkg/openstack/neutron.go index 6cb439642..2a1ab36ea 100644 --- a/pkg/openstack/neutron.go +++ b/pkg/openstack/neutron.go @@ -11,6 +11,7 @@ import ( neutronv1 "github.com/openstack-k8s-operators/neutron-operator/api/v1beta1" corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + "github.com/openstack-k8s-operators/openstack-operator/controllers/core" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" ) @@ -23,6 +24,7 @@ func ReconcileNeutron(ctx context.Context, instance *corev1beta1.OpenStackContro Namespace: instance.Namespace, }, } + l := core.GetLog(ctx) if !instance.Spec.Neutron.Enabled { if res, err := EnsureDeleted(ctx, helper, neutronAPI); err != nil { @@ -32,7 +34,7 @@ func ReconcileNeutron(ctx context.Context, instance *corev1beta1.OpenStackContro return ctrl.Result{}, nil } - helper.GetLogger().Info("Reconciling NeutronAPI", "NeutronAPI.Namespace", instance.Namespace, "NeutronAPI.Name", "neutron") + l.Info("Reconciling NeutronAPI", "NeutronAPI.Namespace", instance.Namespace, "NeutronAPI.Name", "neutron") op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), neutronAPI, func() error { instance.Spec.Neutron.Template.DeepCopyInto(&neutronAPI.Spec) if neutronAPI.Spec.Secret == "" { @@ -77,7 +79,7 @@ func ReconcileNeutron(ctx context.Context, instance *corev1beta1.OpenStackContro return ctrl.Result{}, err } if op != controllerutil.OperationResultNone { - helper.GetLogger().Info(fmt.Sprintf("neutronAPI %s - %s", neutronAPI.Name, op)) + l.Info(fmt.Sprintf("neutronAPI %s - %s", neutronAPI.Name, op)) } if neutronAPI.IsReady() { diff --git a/pkg/openstack/nova.go b/pkg/openstack/nova.go index 6ff791b9d..3cc140f47 100644 --- a/pkg/openstack/nova.go +++ b/pkg/openstack/nova.go @@ -27,6 +27,7 @@ import ( novav1 "github.com/openstack-k8s-operators/nova-operator/api/v1beta1" corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + "github.com/openstack-k8s-operators/openstack-operator/controllers/core" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" ) @@ -39,6 +40,7 @@ func ReconcileNova(ctx context.Context, instance *corev1beta1.OpenStackControlPl Namespace: instance.Namespace, }, } + l := core.GetLog(ctx) if !instance.Spec.Nova.Enabled { if res, err := EnsureDeleted(ctx, helper, nova); err != nil { @@ -48,7 +50,7 @@ func ReconcileNova(ctx context.Context, instance *corev1beta1.OpenStackControlPl return ctrl.Result{}, nil } - helper.GetLogger().Info("Reconciling Nova", "Nova.Namespace", instance.Namespace, "Nova.Name", nova.Name) + l.Info("Reconciling Nova", "Nova.Namespace", instance.Namespace, "Nova.Name", nova.Name) op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), nova, func() error { // 1) // Nova.Spec.APIDatabaseInstance and each NovaCell.CellDatabaseInstance @@ -85,7 +87,7 @@ func ReconcileNova(ctx context.Context, instance *corev1beta1.OpenStackControlPl return ctrl.Result{}, err } if op != controllerutil.OperationResultNone { - helper.GetLogger().Info(fmt.Sprintf("Nova %s - %s", nova.Name, op)) + l.Info(fmt.Sprintf("Nova %s - %s", nova.Name, op)) } if nova.IsReady() { diff --git a/pkg/openstack/openstackclient.go b/pkg/openstack/openstackclient.go index 5a870287f..984d186d2 100644 --- a/pkg/openstack/openstackclient.go +++ b/pkg/openstack/openstackclient.go @@ -23,6 +23,7 @@ import ( condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" "github.com/openstack-k8s-operators/lib-common/modules/common/helper" corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + "github.com/openstack-k8s-operators/openstack-operator/controllers/core" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -43,8 +44,9 @@ func ReconcileOpenStackClient(ctx context.Context, instance *corev1beta1.OpenSta Namespace: instance.Namespace, }, } + l := core.GetLog(ctx) - helper.GetLogger().Info("Reconciling OpenStackClient", "OpenStackClient.Namespace", instance.Namespace, "OpenStackClient.Name", openstackclient.Name) + l.Info("Reconciling OpenStackClient", "OpenStackClient.Namespace", instance.Namespace, "OpenStackClient.Name", openstackclient.Name) op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), openstackclient, func() error { // the following are created/owned by keystoneclient openstackclient.Spec.OpenStackConfigMap = "openstack-config" @@ -68,14 +70,14 @@ func ReconcileOpenStackClient(ctx context.Context, instance *corev1beta1.OpenSta return ctrl.Result{}, err } if op != controllerutil.OperationResultNone { - helper.GetLogger().Info(fmt.Sprintf("OpenStackClient %s - %s", openstackclient.Name, op)) + l.Info(fmt.Sprintf("OpenStackClient %s - %s", openstackclient.Name, op)) } if openstackclient.Status.Conditions.IsTrue(clientv1beta1.OpenStackClientReadyCondition) { - helper.GetLogger().Info("OpenStackClient ready condition is true") + l.Info("OpenStackClient ready condition is true") instance.Status.Conditions.MarkTrue(corev1beta1.OpenStackControlPlaneClientReadyCondition, corev1beta1.OpenStackControlPlaneClientReadyMessage) } else { - helper.GetLogger().Info("OpenStackClient ready condition is false") + l.Info("OpenStackClient ready condition is false") instance.Status.Conditions.Set(condition.FalseCondition( corev1beta1.OpenStackControlPlaneClientReadyCondition, condition.RequestedReason, diff --git a/pkg/openstack/ovn.go b/pkg/openstack/ovn.go index fa9226549..2226c2e28 100644 --- a/pkg/openstack/ovn.go +++ b/pkg/openstack/ovn.go @@ -10,6 +10,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + "github.com/openstack-k8s-operators/openstack-operator/controllers/core" ovnv1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" @@ -25,6 +26,7 @@ func ReconcileOVN(ctx context.Context, instance *corev1beta1.OpenStackControlPla Namespace: instance.Namespace, }, } + l := core.GetLog(ctx) if !instance.Spec.Ovn.Enabled { if res, err := EnsureDeleted(ctx, helper, OVNDBCluster); err != nil { @@ -34,7 +36,7 @@ func ReconcileOVN(ctx context.Context, instance *corev1beta1.OpenStackControlPla continue } - helper.GetLogger().Info("Reconciling OVNDBCluster", "OVNDBCluster.Namespace", instance.Namespace, "OVNDBCluster.Name", name) + l.Info("Reconciling OVNDBCluster", "OVNDBCluster.Namespace", instance.Namespace, "OVNDBCluster.Name", name) op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), OVNDBCluster, func() error { dbcluster.DeepCopyInto(&OVNDBCluster.Spec) @@ -63,7 +65,7 @@ func ReconcileOVN(ctx context.Context, instance *corev1beta1.OpenStackControlPla return ctrl.Result{}, err } if op != controllerutil.OperationResultNone { - helper.GetLogger().Info(fmt.Sprintf("OVNDBCluster %s - %s", OVNDBCluster.Name, op)) + l.Info(fmt.Sprintf("OVNDBCluster %s - %s", OVNDBCluster.Name, op)) } OVNDBClustersReady = OVNDBClustersReady && OVNDBCluster.IsReady() } @@ -83,7 +85,7 @@ func ReconcileOVN(ctx context.Context, instance *corev1beta1.OpenStackControlPla return ctrl.Result{}, nil } - helper.GetLogger().Info("Reconciling OVNNorthd", "OVNNorthd.Namespace", instance.Namespace, "OVNNorthd.Name", "ovnnorthd") + l.Info("Reconciling OVNNorthd", "OVNNorthd.Namespace", instance.Namespace, "OVNNorthd.Name", "ovnnorthd") op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), OVNNorthd, func() error { instance.Spec.Ovn.Template.OVNNorthd.DeepCopyInto(&OVNNorthd.Spec) @@ -109,7 +111,7 @@ func ReconcileOVN(ctx context.Context, instance *corev1beta1.OpenStackControlPla return ctrl.Result{}, err } if op != controllerutil.OperationResultNone { - helper.GetLogger().Info(fmt.Sprintf("OVNNorthd %s - %s", OVNNorthd.Name, op)) + l.Info(fmt.Sprintf("OVNNorthd %s - %s", OVNNorthd.Name, op)) } OVNController := &ovnv1.OVNController{ diff --git a/pkg/openstack/placement.go b/pkg/openstack/placement.go index 398a052c1..de91a5d03 100644 --- a/pkg/openstack/placement.go +++ b/pkg/openstack/placement.go @@ -10,6 +10,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + "github.com/openstack-k8s-operators/openstack-operator/controllers/core" placementv1 "github.com/openstack-k8s-operators/placement-operator/api/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrl "sigs.k8s.io/controller-runtime" @@ -23,6 +24,7 @@ func ReconcilePlacementAPI(ctx context.Context, instance *corev1beta1.OpenStackC Namespace: instance.Namespace, }, } + l := core.GetLog(ctx) if !instance.Spec.Placement.Enabled { if res, err := EnsureDeleted(ctx, helper, placementAPI); err != nil { @@ -32,7 +34,7 @@ func ReconcilePlacementAPI(ctx context.Context, instance *corev1beta1.OpenStackC return ctrl.Result{}, nil } - helper.GetLogger().Info("Reconciling PlacementAPI", "PlacementAPI.Namespace", instance.Namespace, "PlacementAPI.Name", "placement") + l.Info("Reconciling PlacementAPI", "PlacementAPI.Namespace", instance.Namespace, "PlacementAPI.Name", "placement") op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), placementAPI, func() error { instance.Spec.Placement.Template.DeepCopyInto(&placementAPI.Spec) if placementAPI.Spec.Secret == "" { @@ -61,7 +63,7 @@ func ReconcilePlacementAPI(ctx context.Context, instance *corev1beta1.OpenStackC return ctrl.Result{}, err } if op != controllerutil.OperationResultNone { - helper.GetLogger().Info(fmt.Sprintf("placementAPI %s - %s", placementAPI.Name, op)) + l.Info(fmt.Sprintf("placementAPI %s - %s", placementAPI.Name, op)) } if placementAPI.IsReady() {