-
Notifications
You must be signed in to change notification settings - Fork 783
[3.3] AutoOps: Ignore deprecated ES clusters (#9008) #9013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ import ( | |
| "github.com/elastic/cloud-on-k8s/v3/pkg/controller/association" | ||
| "github.com/elastic/cloud-on-k8s/v3/pkg/controller/common/deployment" | ||
| "github.com/elastic/cloud-on-k8s/v3/pkg/controller/common/reconciler" | ||
| "github.com/elastic/cloud-on-k8s/v3/pkg/controller/common/version" | ||
| "github.com/elastic/cloud-on-k8s/v3/pkg/utils/k8s" | ||
| ulog "github.com/elastic/cloud-on-k8s/v3/pkg/utils/log" | ||
| ) | ||
|
|
@@ -134,16 +135,31 @@ func (r *AgentPolicyReconciler) internalReconcile( | |
| for _, es := range accessibleClusters { | ||
| log := log.WithValues("es_namespace", es.Namespace, "es_name", es.Name) | ||
|
|
||
| esVersion, err := version.Parse(es.Spec.Version) | ||
| if err != nil { | ||
| log.Error(err, "while parsing ES version") | ||
| state.UpdateWithPhase(autoopsv1alpha1.ErrorPhase) | ||
| return results.WithError(err) | ||
| } | ||
|
|
||
| // No error means the version is within the deprecated range, so we skip the cluster. | ||
| // We do not adjust the status to indicate this issue at this time, as the status object | ||
| // does not currently support a status per-cluster. | ||
| if version.DeprecatedVersions.WithinRange(esVersion) == nil { | ||
| log.Info("Skipping ES cluster because of deprecated version", "version", es.Spec.Version) | ||
| continue | ||
| } | ||
|
Comment on lines
+145
to
+151
|
||
|
|
||
| if es.Status.Phase != esv1.ElasticsearchReadyPhase { | ||
| log.V(1).Info("Skipping ES cluster that is not ready", "es_namespace", es.Namespace, "es_name", es.Name) | ||
| log.V(1).Info("Skipping ES cluster that is not ready") | ||
| state.UpdateWithPhase(autoopsv1alpha1.ResourcesNotReadyPhase) | ||
| results = results.WithRequeue(reconciler.DefaultRequeue) | ||
| continue | ||
| } | ||
|
|
||
| if es.Spec.HTTP.TLS.Enabled() { | ||
| if err := r.reconcileAutoOpsESCASecret(ctx, policy, es); err != nil { | ||
| log.Error(err, "while reconciling AutoOps ES CA secret", "es_namespace", es.Namespace, "es_name", es.Name) | ||
| log.Error(err, "while reconciling AutoOps ES CA secret") | ||
| errorCount++ | ||
| state.UpdateWithPhase(autoopsv1alpha1.ErrorPhase) | ||
| results.WithError(err) | ||
|
|
@@ -153,7 +169,7 @@ func (r *AgentPolicyReconciler) internalReconcile( | |
|
|
||
| apiKeySecret, err := r.reconcileAutoOpsESAPIKey(ctx, policy, es) | ||
| if err != nil { | ||
| log.Error(err, "while reconciling AutoOps ES API key", "es_namespace", es.Namespace, "es_name", es.Name) | ||
| log.Error(err, "while reconciling AutoOps ES API key") | ||
| errorCount++ | ||
| state.UpdateWithPhase(autoopsv1alpha1.ErrorPhase) | ||
| results.WithError(err) | ||
|
|
@@ -162,7 +178,7 @@ func (r *AgentPolicyReconciler) internalReconcile( | |
|
|
||
| configMap, err := ReconcileAutoOpsESConfigMap(ctx, r.Client, policy, es) | ||
| if err != nil { | ||
| log.Error(err, "while reconciling AutoOps ES config map", "es_namespace", es.Namespace, "es_name", es.Name) | ||
| log.Error(err, "while reconciling AutoOps ES config map") | ||
| errorCount++ | ||
| state.UpdateWithPhase(autoopsv1alpha1.ErrorPhase) | ||
| results.WithError(err) | ||
|
|
@@ -171,7 +187,7 @@ func (r *AgentPolicyReconciler) internalReconcile( | |
|
|
||
| configHash, err := buildConfigHash(ctx, *configMap, *apiKeySecret, r.Client, policy) | ||
| if err != nil { | ||
| log.Error(err, "while building config hash", "es_namespace", es.Namespace, "es_name", es.Name) | ||
| log.Error(err, "while building config hash") | ||
| errorCount++ | ||
| state.UpdateWithPhase(autoopsv1alpha1.ErrorPhase) | ||
| results.WithError(err) | ||
|
|
@@ -180,7 +196,7 @@ func (r *AgentPolicyReconciler) internalReconcile( | |
|
|
||
| deploymentParams, err := r.buildDeployment(configHash, policy, es) | ||
| if err != nil { | ||
| log.Error(err, "while getting deployment params", "es_namespace", es.Namespace, "es_name", es.Name) | ||
| log.Error(err, "while getting deployment params") | ||
| errorCount++ | ||
| state.UpdateWithPhase(autoopsv1alpha1.ErrorPhase) | ||
| results.WithError(err) | ||
|
|
@@ -189,7 +205,7 @@ func (r *AgentPolicyReconciler) internalReconcile( | |
|
|
||
| reconciledDeployment, err := deployment.Reconcile(ctx, r.Client, deploymentParams, &policy) | ||
| if err != nil { | ||
| log.Error(err, "while reconciling deployment", "es_namespace", es.Namespace, "es_name", es.Name) | ||
| log.Error(err, "while reconciling deployment") | ||
| errorCount++ | ||
| state.UpdateWithPhase(autoopsv1alpha1.ErrorPhase) | ||
| results.WithError(err) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When all matching ES clusters are deprecated, the status is left with Resources counted but no Phase set. This creates an ambiguous state where Resources=1, Ready=0, Errors=0, but Phase="". Consider setting an appropriate phase (or documenting this as expected behavior) to make the status more meaningful to users. For comparison, when resources exist but are not ready, the phase is explicitly set to ResourcesNotReadyPhase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this issue will likely be addressed when the extended status reporting issue is resolved/tackled