Skip to content

Commit

Permalink
update individual operators log usage
Browse files Browse the repository at this point in the history
  • Loading branch information
pinikomarov committed Jun 28, 2023
1 parent a164ffa commit 95a9728
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 30 deletions.
6 changes: 4 additions & 2 deletions pkg/openstack/cinder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 == "" {
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 4 additions & 2 deletions pkg/openstack/galera.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand All @@ -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 == "" {
Expand All @@ -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() {
Expand Down
7 changes: 5 additions & 2 deletions pkg/openstack/glance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
Expand All @@ -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 == "" {
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 4 additions & 2 deletions pkg/openstack/horizon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand All @@ -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())
Expand All @@ -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() {
Expand Down
6 changes: 4 additions & 2 deletions pkg/openstack/ironic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand All @@ -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())
Expand All @@ -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() {
Expand Down
7 changes: 5 additions & 2 deletions pkg/openstack/keystone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
Expand All @@ -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 == "" {
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 4 additions & 2 deletions pkg/openstack/manila.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand All @@ -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 == "" {
Expand Down Expand Up @@ -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() {
Expand Down
7 changes: 5 additions & 2 deletions pkg/openstack/memcached.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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())
Expand All @@ -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() {
Expand Down
6 changes: 4 additions & 2 deletions pkg/openstack/neutron.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand All @@ -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 == "" {
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 4 additions & 2 deletions pkg/openstack/nova.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
10 changes: 6 additions & 4 deletions pkg/openstack/openstackclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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,
Expand Down
Loading

0 comments on commit 95a9728

Please sign in to comment.