mirror of
https://github.com/external-secrets/external-secrets.git
synced 2024-12-14 11:57:59 +00:00
Gc/fix clusterexternalsecret metrics (#4170)
* fix: not ready metrics for some edge case conditions on ces Signed-off-by: Gustavo Carvalho <gusfcarvalho@gmail.com> * fix: failure conditions with no metrics Signed-off-by: Gustavo Carvalho <gusfcarvalho@gmail.com> --------- Signed-off-by: Gustavo Carvalho <gusfcarvalho@gmail.com> Co-authored-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
This commit is contained in:
parent
c00c491a0e
commit
71e44c929f
1 changed files with 16 additions and 1 deletions
|
@ -102,18 +102,33 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
|
||||||
}
|
}
|
||||||
if prevName := clusterExternalSecret.Status.ExternalSecretName; prevName != esName {
|
if prevName := clusterExternalSecret.Status.ExternalSecretName; prevName != esName {
|
||||||
// ExternalSecretName has changed, so remove the old ones
|
// ExternalSecretName has changed, so remove the old ones
|
||||||
|
failedNamespaces := map[string]error{}
|
||||||
for _, ns := range clusterExternalSecret.Status.ProvisionedNamespaces {
|
for _, ns := range clusterExternalSecret.Status.ProvisionedNamespaces {
|
||||||
if err := r.deleteExternalSecret(ctx, prevName, clusterExternalSecret.Name, ns); err != nil {
|
if err := r.deleteExternalSecret(ctx, prevName, clusterExternalSecret.Name, ns); err != nil {
|
||||||
log.Error(err, "could not delete ExternalSecret")
|
log.Error(err, "could not delete ExternalSecret")
|
||||||
return ctrl.Result{}, err
|
failedNamespaces[ns] = err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(failedNamespaces) > 0 {
|
||||||
|
condition := NewClusterExternalSecretCondition(failedNamespaces)
|
||||||
|
SetClusterExternalSecretCondition(&clusterExternalSecret, *condition)
|
||||||
|
clusterExternalSecret.Status.FailedNamespaces = toNamespaceFailures(failedNamespaces)
|
||||||
|
return ctrl.Result{}, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
clusterExternalSecret.Status.ExternalSecretName = esName
|
clusterExternalSecret.Status.ExternalSecretName = esName
|
||||||
|
|
||||||
namespaces, err := r.getTargetNamespaces(ctx, &clusterExternalSecret)
|
namespaces, err := r.getTargetNamespaces(ctx, &clusterExternalSecret)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err, "failed to get target Namespaces")
|
log.Error(err, "failed to get target Namespaces")
|
||||||
|
failedNamespaces := map[string]error{
|
||||||
|
"unknown": err,
|
||||||
|
}
|
||||||
|
condition := NewClusterExternalSecretCondition(failedNamespaces)
|
||||||
|
SetClusterExternalSecretCondition(&clusterExternalSecret, *condition)
|
||||||
|
|
||||||
|
clusterExternalSecret.Status.FailedNamespaces = toNamespaceFailures(failedNamespaces)
|
||||||
|
|
||||||
return ctrl.Result{}, err
|
return ctrl.Result{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue