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: immediate limits sync to pod via annotation #127

Merged
merged 4 commits into from
Apr 8, 2024

Conversation

KevFan
Copy link
Contributor

@KevFan KevFan commented Mar 15, 2024

Description

Part of Kuadrant/kuadrant-operator#414

This PR adds a feature to annotate Limitador pods with the limits config map resource version. This change ensures that modifications to the limits will promptly trigger a reload or synchronization of the limit configuration to Limitador pods. Consequently, it ensures that pod limits are always immediately up to date.

This enhancement will enable us to utilize the Limitador CR Ready condition as a way of naively assuming that limits are enforced.

Other additions include

  • Updating kind to v0.22.0
  • Refactor integration tests to use context to timeout tests and algin primarily use Gomega for assertions

Verification

The following have already been verified in the included integration test but if you want to verify manually:

  • Checkout this branch
  • Create local cluster
 make local-setup
  • Watch for limitador pod annotations
watch "kubectl get pods -o yaml | yq '.items[].metadata.annotations'"
  • Deploy limitador CR
kubectl apply -f -<<EOF                                          
apiVersion: limitador.kuadrant.io/v1alpha1
kind: Limitador
metadata:
  name: limitador-sample
spec:
  replicas: 2
  limits:
    - conditions: ["get_toy == 'yes'"]
      max_value: 10
      namespace: toystore-app
      seconds: 30
      variables: []
EOF
  • Verify annotation is added to the pods
  • Watch limits in a limitador pod
watch "kubectl exec $(kubectl get pods -l app=limitador -o yaml | yq '.items[0].metadata.name') -c limitador -- cat /home/limitador/etc/limitador-config.yaml"
  • Update limits
kubectl apply -f -<<EOF                                          
apiVersion: limitador.kuadrant.io/v1alpha1
kind: Limitador
metadata:
  name: limitador-sample
spec:
  replicas: 2
  limits:
    - conditions: ["get_toy == 'yes'"]
      max_value: 20
      namespace: toystore-app
      seconds: 60
      variables: []
EOF
  • Verify annotation of config map resource version is updated
  • Verify config map in pod is immediately updated / synced to new value once annotation is updated

@codecov-commenter
Copy link

codecov-commenter commented Mar 15, 2024

Codecov Report

Merging #127 (f0b39d5) into main (e9207fb) will increase coverage by 0.14%.
The diff coverage is 60.97%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #127      +/-   ##
==========================================
+ Coverage   68.19%   68.34%   +0.14%     
==========================================
  Files          16       16              
  Lines        1154     1191      +37     
==========================================
+ Hits          787      814      +27     
- Misses        325      334       +9     
- Partials       42       43       +1     
Flag Coverage Δ
integration 73.69% <68.57%> (+1.12%) ⬆️
unit 65.79% <16.66%> (-0.50%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
api/v1alpha1 (u) 90.00% <0.00%> (-10.00%) ⬇️
pkg/helpers (u) ∅ <ø> (∅)
pkg/log (u) 31.81% <ø> (ø)
pkg/reconcilers (u) 36.76% <ø> (ø)
pkg/limitador (u) 88.06% <100.00%> (-0.07%) ⬇️
controllers (i) 73.69% <68.57%> (+1.12%) ⬆️
Files Coverage Δ
pkg/limitador/k8s_objects.go 80.18% <100.00%> (-0.19%) ⬇️
api/v1alpha1/limitador_types.go 90.00% <0.00%> (-10.00%) ⬇️
controllers/limitador_controller.go 70.07% <68.57%> (+2.07%) ⬆️

@KevFan KevFan force-pushed the limits-hash-pod-annotation branch 4 times, most recently from 48db34f to 15ca71f Compare March 19, 2024 15:25
@KevFan KevFan changed the title [wip] feat: immediate limits sync to pod via annotation feat: immediate limits sync to pod via annotation Mar 19, 2024
@KevFan KevFan force-pushed the limits-hash-pod-annotation branch from 15ca71f to 827692e Compare March 19, 2024 15:53
@KevFan KevFan requested review from a team and eguzki March 19, 2024 16:11
@KevFan KevFan self-assigned this Mar 20, 2024
@KevFan KevFan added kind/enhancement New feature or request size/medium labels Mar 20, 2024
@KevFan KevFan force-pushed the limits-hash-pod-annotation branch 3 times, most recently from 61ea8eb to 2ead948 Compare March 21, 2024 11:05
@eguzki
Copy link
Contributor

eguzki commented Apr 4, 2024

Verification steps working like a charm

nice that the steps create two replicas.

Copy link
Contributor

@eguzki eguzki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments and one "bigger" one I would like to discuss pros and cons.

go.mod Outdated Show resolved Hide resolved
controllers/limitador_controller.go Outdated Show resolved Hide resolved
controllers/limitador_controller.go Outdated Show resolved Hide resolved
controllers/limitador_controller.go Outdated Show resolved Hide resolved
@KevFan KevFan force-pushed the limits-hash-pod-annotation branch from 1e12524 to f0b39d5 Compare April 5, 2024 12:31
@KevFan
Copy link
Contributor Author

KevFan commented Apr 5, 2024

Resolved comments and rebased with main

@KevFan KevFan requested a review from eguzki April 5, 2024 12:36
Copy link
Contributor

@eguzki eguzki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and the verification steps work with the resource version of the configmap

@KevFan KevFan merged commit c4802c5 into Kuadrant:main Apr 8, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request size/medium
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants