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

Update limitador to 0.9.0 #608

Merged
merged 7 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
14 changes: 12 additions & 2 deletions api/v1beta1/kuadrant_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,23 @@ type LimitadorSpec struct {
Replicas *int `json:"replicas,omitempty"`

// +optional
ResourceRequirements *corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`
Storage *limitadorv1alpha1.Storage `json:"storage,omitempty"`

// +optional
RateLimitHeaders *limitadorv1alpha1.RateLimitHeadersType `json:"rateLimitHeaders,omitempty"`

// +optional
Telemetry *limitadorv1alpha1.Telemetry `json:"telemetry,omitempty"`

// +optional
PodDisruptionBudget *limitadorv1alpha1.PodDisruptionBudgetType `json:"pdb,omitempty"`

// +optional
Storage *limitadorv1alpha1.Storage `json:"storage,omitempty"`
ResourceRequirements *corev1.ResourceRequirements `json:"resourceRequirements,omitempty"`

// Sets the level of verbosity
// +optional
Verbosity *limitadorv1alpha1.VerbosityLevel `json:"verbosity,omitempty"`
}

// KuadrantStatus defines the observed state of Kuadrant
Expand Down
27 changes: 21 additions & 6 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ metadata:
capabilities: Basic Install
categories: Integration & Delivery
containerImage: quay.io/kuadrant/kuadrant-operator:latest
createdAt: "2024-07-05T16:23:56Z"
createdAt: "2024-07-10T15:04:27Z"
operators.operatorframework.io/builder: operator-sdk-v1.32.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/Kuadrant/kuadrant-operator
Expand Down
33 changes: 26 additions & 7 deletions bundle/manifests/kuadrant.io_kuadrants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,13 @@ spec:
evictions by specifying "100%".
x-kubernetes-int-or-string: true
type: object
rateLimitHeaders:
description: RateLimitHeadersType defines the valid options for
the --rate-limit-headers arg
enum:
- NONE
- DRAFT_VERSION_03
type: string
replicas:
type: integer
resourceRequirements:
Expand Down Expand Up @@ -976,6 +983,10 @@ spec:
x-kubernetes-map-type: atomic
options:
properties:
batch-size:
description: 'BatchSize defines the size of entries
to flush in as single flush [default: 100]'
type: integer
flush-period:
description: 'FlushPeriod for counters in milliseconds
[default: 1000]'
Expand All @@ -984,17 +995,25 @@ spec:
description: 'MaxCached refers to the maximum amount
of counters cached [default: 10000]'
type: integer
ratio:
description: 'Ratio to apply to the TTL from Redis
on cached counters [default: 10]'
type: integer
ttl:
description: 'TTL for cached counters in milliseconds
[default: 5000]'
response-timeout:
description: 'ResponseTimeout defines the timeout
for Redis commands in milliseconds [default: 350]'
type: integer
type: object
type: object
type: object
telemetry:
description: Telemetry defines the level of metrics Limitador
will expose to the user
enum:
- basic
- exhaustive
type: string
verbosity:
description: Sets the level of verbosity
maximum: 4
minimum: 1
type: integer
type: object
type: object
status:
Expand Down
33 changes: 26 additions & 7 deletions config/crd/bases/kuadrant.io_kuadrants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,13 @@ spec:
evictions by specifying "100%".
x-kubernetes-int-or-string: true
type: object
rateLimitHeaders:
description: RateLimitHeadersType defines the valid options for
the --rate-limit-headers arg
enum:
- NONE
- DRAFT_VERSION_03
type: string
replicas:
type: integer
resourceRequirements:
Expand Down Expand Up @@ -974,6 +981,10 @@ spec:
x-kubernetes-map-type: atomic
options:
properties:
batch-size:
description: 'BatchSize defines the size of entries
to flush in as single flush [default: 100]'
type: integer
flush-period:
description: 'FlushPeriod for counters in milliseconds
[default: 1000]'
Expand All @@ -982,17 +993,25 @@ spec:
description: 'MaxCached refers to the maximum amount
of counters cached [default: 10000]'
type: integer
ratio:
description: 'Ratio to apply to the TTL from Redis
on cached counters [default: 10]'
type: integer
ttl:
description: 'TTL for cached counters in milliseconds
[default: 5000]'
response-timeout:
description: 'ResponseTimeout defines the timeout
for Redis commands in milliseconds [default: 350]'
type: integer
type: object
type: object
type: object
telemetry:
description: Telemetry defines the level of metrics Limitador
will expose to the user
enum:
- basic
- exhaustive
type: string
verbosity:
description: Sets the level of verbosity
maximum: 4
minimum: 1
type: integer
type: object
type: object
status:
Expand Down
88 changes: 49 additions & 39 deletions controllers/kuadrant_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,54 +408,64 @@
}

func (r *KuadrantReconciler) reconcileLimitador(ctx context.Context, kObj *kuadrantv1beta1.Kuadrant) error {
limitadorKey := client.ObjectKey{Name: common.LimitadorName, Namespace: kObj.Namespace}
limitador := &limitadorv1alpha1.Limitador{}
err := r.Client().Get(ctx, limitadorKey, limitador)
if err != nil {
if apierrors.IsNotFound(err) {
limitador = &limitadorv1alpha1.Limitador{
TypeMeta: metav1.TypeMeta{
Kind: "Limitador",
APIVersion: "limitador.kuadrant.io/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: common.LimitadorName,
Namespace: kObj.Namespace,
},
Spec: limitadorv1alpha1.LimitadorSpec{
RateLimitHeaders: &[]limitadorv1alpha1.RateLimitHeadersType{limitadorv1alpha1.RateLimitHeadersTypeDraft03}[0],
Telemetry: &[]limitadorv1alpha1.Telemetry{limitadorv1alpha1.TelemetryExhaustive}[0],
},
}
} else {
return err
}
limitador := &limitadorv1alpha1.Limitador{
TypeMeta: metav1.TypeMeta{
Kind: "Limitador",
APIVersion: "limitador.kuadrant.io/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: common.LimitadorName,
Namespace: kObj.Namespace,
},
Spec: limitadorv1alpha1.LimitadorSpec{},

Check warning on line 420 in controllers/kuadrant_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/kuadrant_controller.go#L411-L420

Added lines #L411 - L420 were not covered by tests
}

if kObj.Spec.Limitador != nil {
if kObj.Spec.Limitador.Affinity != nil {
limitador.Spec.Affinity = kObj.Spec.Limitador.Affinity
}
if kObj.Spec.Limitador.PodDisruptionBudget != nil {
limitador.Spec.PodDisruptionBudget = kObj.Spec.Limitador.PodDisruptionBudget
}
if kObj.Spec.Limitador.Replicas != nil {
limitador.Spec.Replicas = kObj.Spec.Limitador.Replicas
}
if kObj.Spec.Limitador.ResourceRequirements != nil {
limitador.Spec.ResourceRequirements = kObj.Spec.Limitador.ResourceRequirements
}
if kObj.Spec.Limitador.Storage != nil {
limitador.Spec.Storage = kObj.Spec.Limitador.Storage
}
limitador.Spec.Affinity = kObj.Spec.Limitador.Affinity
limitador.Spec.Replicas = kObj.Spec.Limitador.Replicas
limitador.Spec.Storage = kObj.Spec.Limitador.Storage
limitador.Spec.RateLimitHeaders = kObj.Spec.Limitador.RateLimitHeaders
limitador.Spec.Telemetry = kObj.Spec.Limitador.Telemetry
limitador.Spec.PodDisruptionBudget = kObj.Spec.Limitador.PodDisruptionBudget
limitador.Spec.ResourceRequirements = kObj.Spec.Limitador.ResourceRequirements
limitador.Spec.Verbosity = kObj.Spec.Limitador.Verbosity

Check warning on line 431 in controllers/kuadrant_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/kuadrant_controller.go#L424-L431

Added lines #L424 - L431 were not covered by tests
}

err = r.SetOwnerReference(kObj, limitador)
err := r.SetOwnerReference(kObj, limitador)

Check warning on line 434 in controllers/kuadrant_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/kuadrant_controller.go#L434

Added line #L434 was not covered by tests
if err != nil {
return err
}

return r.ReconcileResource(ctx, &limitadorv1alpha1.Limitador{}, limitador, kuadranttools.LimitadorMutator)
limitadorMutators := make([]kuadranttools.LimitadorMutateFn, 0)

Check warning on line 439 in controllers/kuadrant_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/kuadrant_controller.go#L439

Added line #L439 was not covered by tests

limitadorMutators = append(limitadorMutators, kuadranttools.LimitadorOwnerRefsMutator)

Check warning on line 441 in controllers/kuadrant_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/kuadrant_controller.go#L441

Added line #L441 was not covered by tests

if kObj.Spec.Limitador.Affinity != nil {
limitadorMutators = append(limitadorMutators, kuadranttools.LimitadorAffinityMutator)

Check warning on line 444 in controllers/kuadrant_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/kuadrant_controller.go#L443-L444

Added lines #L443 - L444 were not covered by tests
}
if kObj.Spec.Limitador.Replicas != nil {
limitadorMutators = append(limitadorMutators, kuadranttools.LimitadorReplicasMutator)

Check warning on line 447 in controllers/kuadrant_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/kuadrant_controller.go#L446-L447

Added lines #L446 - L447 were not covered by tests
}
if kObj.Spec.Limitador.Storage != nil {
limitadorMutators = append(limitadorMutators, kuadranttools.LimitadorStorageMutator)

Check warning on line 450 in controllers/kuadrant_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/kuadrant_controller.go#L449-L450

Added lines #L449 - L450 were not covered by tests
}
if kObj.Spec.Limitador.RateLimitHeaders != nil {
limitadorMutators = append(limitadorMutators, kuadranttools.LimitadorRateLimitHeadersMutator)

Check warning on line 453 in controllers/kuadrant_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/kuadrant_controller.go#L452-L453

Added lines #L452 - L453 were not covered by tests
}
if kObj.Spec.Limitador.Telemetry != nil {
limitadorMutators = append(limitadorMutators, kuadranttools.LimitadorTelemetryMutator)

Check warning on line 456 in controllers/kuadrant_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/kuadrant_controller.go#L455-L456

Added lines #L455 - L456 were not covered by tests
}
if kObj.Spec.Limitador.PodDisruptionBudget != nil {
limitadorMutators = append(limitadorMutators, kuadranttools.LimitadorPodDisruptionBudgetMutator)

Check warning on line 459 in controllers/kuadrant_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/kuadrant_controller.go#L458-L459

Added lines #L458 - L459 were not covered by tests
}
if kObj.Spec.Limitador.ResourceRequirements != nil {
limitadorMutators = append(limitadorMutators, kuadranttools.LimitadorResourceRequirementsMutator)

Check warning on line 462 in controllers/kuadrant_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/kuadrant_controller.go#L461-L462

Added lines #L461 - L462 were not covered by tests
}
if kObj.Spec.Limitador.Verbosity != nil {
limitadorMutators = append(limitadorMutators, kuadranttools.LimitadorVerbosityMutator)

Check warning on line 465 in controllers/kuadrant_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/kuadrant_controller.go#L464-L465

Added lines #L464 - L465 were not covered by tests
}

return r.ReconcileResource(ctx, &limitadorv1alpha1.Limitador{}, limitador, kuadranttools.LimitadorMutator(limitadorMutators...))

Check warning on line 468 in controllers/kuadrant_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/kuadrant_controller.go#L468

Added line #L468 was not covered by tests
}

func (r *KuadrantReconciler) reconcileAuthorino(ctx context.Context, kObj *kuadrantv1beta1.Kuadrant) error {
Expand Down
86 changes: 0 additions & 86 deletions controllers/suite_test.go

This file was deleted.

Loading
Loading