diff --git a/api/v1/passboltsecret_types.go b/api/v1/passboltsecret_types.go index de63b5e5..54c26030 100644 --- a/api/v1/passboltsecret_types.go +++ b/api/v1/passboltsecret_types.go @@ -112,6 +112,11 @@ type PassboltSecretStatus struct { LastSync metav1.Time `json:"lastSync"` // SyncErrors is a list of errors that occurred during the last sync. SyncErrors []SyncError `json:"syncErrors,omitempty"` + // FailureCount is the number of times the secret failed to sync. + // This is used to determine if the secret should be retried. + // +kubebuilder:validation:Optional + // +kubebuilder:default=0 + FailureCount int `json:"failureCount,omitempty"` } //+kubebuilder:object:root=true diff --git a/config/crd/bases/passbolt.tagesspiegel.de_passboltsecrets.yaml b/config/crd/bases/passbolt.tagesspiegel.de_passboltsecrets.yaml index ee80ece8..fe5a88cc 100644 --- a/config/crd/bases/passbolt.tagesspiegel.de_passboltsecrets.yaml +++ b/config/crd/bases/passbolt.tagesspiegel.de_passboltsecrets.yaml @@ -96,6 +96,11 @@ spec: status: description: PassboltSecretStatus defines the observed state of PassboltSecret properties: + failureCount: + default: 0 + description: FailureCount is the number of times the secret failed + to sync. This is used to determine if the secret should be retried. + type: integer lastSync: description: LastSync is the last time the secret was synced from passbolt. diff --git a/e2e/lib.sh b/e2e/lib.sh index edd94651..e1a2766b 100644 --- a/e2e/lib.sh +++ b/e2e/lib.sh @@ -143,3 +143,25 @@ EOF )" sleep 5 } + +# createPassboltSecretV1 +function createPassboltSecretV1WithSecretNotFound() { + createPassboltSecret "$(cat <= 3 { + // if the secret failed to sync more than 3 times, we stop trying + logr.Info("secret failed to sync more than 3 times. stopping sync", "name", secret.GetName(), "namespace", secret.GetNamespace()) + return ctrl.Result{}, nil + } if snErr, ok := err.(passboltv1.SyncError); ok { secret.Status.SyncStatus = passboltv1.SyncStatusError + secret.Status.FailureCount++ secret.Status.SyncErrors = append(secret.Status.SyncErrors, snErr) if err := r.Client.Status().Update(ctx, secret); err != nil { return errResult, err @@ -128,6 +139,8 @@ func (r *PassboltSecretReconciler) Reconcile(ctx context.Context, req ctrl.Reque } return errResult, err } + // reset failure counter to 0 + secret.Status.FailureCount = 0 // if the secret was not changed and the status is already success, we can skip the update if opRslt == controllerutil.OperationResultNone && secret.Status.SyncStatus == passboltv1.SyncStatusSuccess {