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

Using Limitador CR condition ready #324

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions controllers/kuadrant_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

"github.com/go-logr/logr"
"golang.org/x/exp/slices"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
Expand All @@ -18,6 +17,7 @@
authorinov1beta1 "github.com/kuadrant/authorino-operator/api/v1beta1"
kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1"
"github.com/kuadrant/kuadrant-operator/pkg/common"
limitadorv1alpha1 "github.com/kuadrant/limitador-operator/api/v1alpha1"
)

const (
Expand Down Expand Up @@ -94,7 +94,7 @@
return cond, nil
}

reason, err := r.checkLimitadorAvailable(ctx, kObj)
reason, err := r.checkLimitadorReady(ctx, kObj)
if err != nil {
return nil, err
}
Expand All @@ -119,29 +119,27 @@
return cond, nil
}

func (r *KuadrantReconciler) checkLimitadorAvailable(ctx context.Context, kObj *kuadrantv1beta1.Kuadrant) (*string, error) {
// Should be implemented reading the Limitador CR's status conditions.
// Not implemented yet in the limitador's operator
deployment := &appsv1.Deployment{}
dKey := client.ObjectKey{Name: "limitador", Namespace: kObj.Namespace}
err := r.Client().Get(ctx, dKey, deployment)
func (r *KuadrantReconciler) checkLimitadorReady(ctx context.Context, kObj *kuadrantv1beta1.Kuadrant) (*string, error) {
limitadorObj := &limitadorv1alpha1.Limitador{}
limitadorKey := client.ObjectKey{Name: common.LimitadorName, Namespace: kObj.Namespace}

err := r.Client().Get(ctx, limitadorKey, limitadorObj)
if err != nil && !errors.IsNotFound(err) {
return nil, err
}

if err != nil && errors.IsNotFound(err) {
tmp := err.Error()
return &tmp, nil
if errors.IsNotFound(err) {
reason := "Limitador not found"
return &reason, nil

Check warning on line 133 in controllers/kuadrant_status.go

View check run for this annotation

Codecov / codecov/patch

controllers/kuadrant_status.go#L132-L133

Added lines #L132 - L133 were not covered by tests
}

availableCondition := common.FindDeploymentStatusCondition(deployment.Status.Conditions, "Available")
if availableCondition == nil {
tmp := "Available condition not found"
return &tmp, nil
statusConditionReady := meta.FindStatusCondition(limitadorObj.Status.Conditions, "Ready")
didierofrivia marked this conversation as resolved.
Show resolved Hide resolved
if statusConditionReady == nil {
reason := "Ready condition not found"
return &reason, nil
}

if availableCondition.Status != corev1.ConditionTrue {
return &availableCondition.Message, nil
if statusConditionReady.Status != metav1.ConditionTrue {
return &statusConditionReady.Message, nil
}

return nil, nil
Expand Down
Loading