Skip to content
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

Feat/ready condition early #3077

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const (
errNamespaces = "could not get namespaces from selector"
errGetExistingES = "could not get existing ExternalSecret"
errNamespacesFailed = "one or more namespaces failed"
errNamespaceNotFound = "no namespace matches"
)

func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
Expand Down Expand Up @@ -179,7 +178,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
provisionedNamespaces = append(provisionedNamespaces, namespace.Name)
}

condition := NewClusterExternalSecretCondition(failedNamespaces, &namespaceList)
condition := NewClusterExternalSecretCondition(failedNamespaces)
SetClusterExternalSecretCondition(&clusterExternalSecret, *condition)

clusterExternalSecret.Status.FailedNamespaces = toNamespaceFailures(failedNamespaces)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ var _ = Describe("ClusterExternalSecret controller", func() {
}
},
}),
Entry("Should not be ready if no namespace matches", testCase{
Entry("Should be ready if no namespace matches", testCase{
namespaces: []v1.Namespace{
{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -659,9 +659,8 @@ var _ = Describe("ClusterExternalSecret controller", func() {
ExternalSecretName: created.Name,
Conditions: []esv1beta1.ClusterExternalSecretStatusCondition{
{
Type: esv1beta1.ClusterExternalSecretReady,
Status: v1.ConditionFalse,
Message: errNamespaceNotFound,
Type: esv1beta1.ClusterExternalSecretReady,
Status: v1.ConditionTrue,
},
},
},
Expand Down
7 changes: 2 additions & 5 deletions pkg/controllers/clusterexternalsecret/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"github.com/external-secrets/external-secrets/pkg/controllers/clusterexternalsecret/cesmetrics"
)

func NewClusterExternalSecretCondition(failedNamespaces map[string]error, namespaceList *v1.NamespaceList) *esv1beta1.ClusterExternalSecretStatusCondition {
if len(namespaceList.Items) > 0 && len(failedNamespaces) == 0 {
func NewClusterExternalSecretCondition(failedNamespaces map[string]error) *esv1beta1.ClusterExternalSecretStatusCondition {
if len(failedNamespaces) == 0 {
return &esv1beta1.ClusterExternalSecretStatusCondition{
Type: esv1beta1.ClusterExternalSecretReady,
Status: v1.ConditionTrue,
Expand All @@ -34,9 +34,6 @@ func NewClusterExternalSecretCondition(failedNamespaces map[string]error, namesp
Status: v1.ConditionFalse,
Message: errNamespacesFailed,
}
if len(failedNamespaces) == 0 {
condition.Message = errNamespaceNotFound
}

return condition
}
Expand Down