Skip to content

Commit

Permalink
[ACM-10272] Added warning logs for deprecated spec field usage (#632)
Browse files Browse the repository at this point in the history
* Added warning logs for deprecated spec field usage

Signed-off-by: Disaiah Bennett <[email protected]>

* fixed comment

Signed-off-by: Disaiah Bennett <[email protected]>

---------

Signed-off-by: Disaiah Bennett <[email protected]>
  • Loading branch information
dislbenn authored Mar 7, 2024
1 parent 7da3c88 commit 9149799
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions controllers/backplaneconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ import (

// MultiClusterEngineReconciler reconciles a MultiClusterEngine object
type MultiClusterEngineReconciler struct {
Client client.Client
UncachedClient client.Client
CacheSpec CacheSpec
Scheme *runtime.Scheme
Images map[string]string
StatusManager *status.StatusTracker
Log logr.Logger
UpgradeableCond utils.Condition
Client client.Client
UncachedClient client.Client
CacheSpec CacheSpec
Scheme *runtime.Scheme
Images map[string]string
StatusManager *status.StatusTracker
Log logr.Logger
UpgradeableCond utils.Condition
DeprecatedSpecFields map[string]bool
}

const (
Expand Down Expand Up @@ -182,6 +183,9 @@ func (r *MultiClusterEngineReconciler) Reconcile(ctx context.Context, req ctrl.R
backplaneConfig.Status.Conditions = status.FilterOutConditionWithSubString(backplaneConfig.Status.Conditions,
backplanev1.MultiClusterEngineComponentFailure)

// Check if any deprecated fields are present within the backplaneConfig spec.
r.CheckDeprecatedFieldUsage(backplaneConfig)

// reset status manager
r.StatusManager.Reset("")
for _, c := range backplaneConfig.Status.Conditions {
Expand Down Expand Up @@ -1655,6 +1659,24 @@ func (r *MultiClusterEngineReconciler) StopScheduleOperatorControllerResync() {
}
}

func (r *MultiClusterEngineReconciler) CheckDeprecatedFieldUsage(m *backplanev1.MultiClusterEngine) {
deprecatedSpecFields := []struct {
name string
isPresent bool
}{}

if r.DeprecatedSpecFields == nil {
r.DeprecatedSpecFields = make(map[string]bool)
}

for _, f := range deprecatedSpecFields {
if f.isPresent && !r.DeprecatedSpecFields[f.name] {
r.Log.Info(fmt.Sprintf("Warning: %s field usage is deprecated in operator.", f.name))
r.DeprecatedSpecFields[f.name] = true
}
}
}

func ensureCRD(ctx context.Context, c client.Client, crd *unstructured.Unstructured) error {
existingCRD := &unstructured.Unstructured{}
existingCRD.SetGroupVersionKind(crd.GroupVersionKind())
Expand Down

0 comments on commit 9149799

Please sign in to comment.