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

fix configmap reconciliation #42

Merged
merged 1 commit into from
Aug 25, 2022
Merged

fix configmap reconciliation #42

merged 1 commit into from
Aug 25, 2022

Conversation

eguzki
Copy link
Contributor

@eguzki eguzki commented Aug 25, 2022

what

  • Limits config map reconciliation was based on a hash computed from a yaml serialized string. This PR change the approach to reflect.DeepEqual comparing method. The hash computation is sensitive to the order of the limit object keys (variables, conditions, max_value, ...). reflect.DeepEqual is not sensible when checking maps equality. Both of approaches are sensitive to the order of the list objects, and that is still a small enhancement to be done.
  • In controller test, have a better sync of updated objects from the controller. The test will check object's fields when it is for sure they have been updated by the controller.

verification steps

run cluster

make local-setup

deploy limitador object

k apply -f config/samples/limitador_v1alpha1_limitador.yaml

Update limitador limits. Adding a new limit to the list.

kubectl patch limitador limitador-sample --type=json --patch='[{"op": "add", "path": "/spec/limits/-", "value": {"conditions": ["other == yes"], "max_value": 2, "namespace": "toystore-app", "seconds": 30, "variables": []} }]'

Check config map was updated

k get cm limits-config-limitador-sample -o yaml | yq_k8s_clean 
apiVersion: v1
data:
  limitador-config.yaml: |
    - conditions:
      - get-toy == yes
      max_value: 2
      namespace: toystore-app
      seconds: 30
      variables: []
    - conditions:
      - other == yes
      max_value: 2
      namespace: toystore-app
      seconds: 30
      variables: []
kind: ConfigMap
metadata:
  creationTimestamp: "2022-08-25T13:46:48Z"
  labels:
    app: limitador
  name: limits-config-limitador-sample
  namespace: default
  resourceVersion: "4169"
  uid: 7ece53b9-457c-44e8-857e-6891e12024ac

Copy link
Member

@didierofrivia didierofrivia left a comment

Choose a reason for hiding this comment

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

🎖️

@eguzki eguzki merged commit 36e7cd6 into main Aug 25, 2022
@eguzki eguzki deleted the fix-configmap-reconciliation branch August 25, 2022 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants