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

Disk storage #96

Merged
merged 24 commits into from
Oct 2, 2023
Merged

Disk storage #96

merged 24 commits into from
Oct 2, 2023

Conversation

eguzki
Copy link
Contributor

@eguzki eguzki commented Sep 4, 2023

What

Deploy limitador with disk (persistent) storage.

Simplest deployment option for disk storage

apiVersion: limitador.kuadrant.io/v1alpha1
kind: Limitador
metadata:
  name: limitador-sample
spec:
  storage: 
    disk: {}

TODO:

  • Doc
  • Fix existing tests
  • Add new tests
  • Discuss about replicas

Verification Steps

Simplest deployment

dev setup

make local-setup

Deploy the limitador CR with storage set to disk

k apply -f - <<EOF
---
apiVersion: limitador.kuadrant.io/v1alpha1
kind: Limitador
metadata:
  name: limitador-sample
spec:
  storage: 
    disk: {}
EOF

Check deployment is correct

kubectl wait --timeout=300s --for=condition=Ready limitador limitador-sample

Should return

limitador.limitador.kuadrant.io/limitador-sample condition met

Check command line

kubectl get deployment/limitador-sample  -o yaml | yq '.spec.template.spec.containers[0].command'

should look like this

- limitador-server
- /home/limitador/etc/limitador-config.yaml
- disk
- /var/lib/limitador/data

By default, 1Gi persistent volume is booked for limitador

kubectl get pvc

Should get

NAME                         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
limitador-limitador-sample   Bound    pvc-3296fc91-8f2d-4f8a-b24b-3cba99304abe   1Gi        RWO            standard       28s

@eguzki eguzki requested review from didierofrivia and a team September 4, 2023 16:25
@eguzki eguzki changed the title Storage disk Disk storage Sep 4, 2023
@@ -317,18 +321,3 @@ func (s *LimitadorStatus) Equals(other *LimitadorStatus, logger logr.Logger) boo
func init() {
SchemeBuilder.Register(&Limitador{}, &LimitadorList{})
}

type PodDisruptionBudgetType struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moving this type to have func init() { as the last function in the file. Just personal taste.

@@ -248,16 +268,6 @@ func (r *LimitadorReconciler) reconcileLimitsConfigMap(ctx context.Context, limi
return nil
}

// SetupWithManager sets up the controller with the Manager.
func (r *LimitadorReconciler) SetupWithManager(mgr ctrl.Manager) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moving this function to the end of the file. Just personal taste.

pkg/limitador/k8s_objects.go Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Sep 8, 2023

Codecov Report

Merging #96 (5e81a02) into main (48f950c) will increase coverage by 14.82%.
The diff coverage is 91.22%.

@@             Coverage Diff             @@
##             main      #96       +/-   ##
===========================================
+ Coverage   53.97%   68.80%   +14.82%     
===========================================
  Files          12       14        +2     
  Lines         867      984      +117     
===========================================
+ Hits          468      677      +209     
+ Misses        363      267       -96     
- Partials       36       40        +4     
Flag Coverage Δ
integration 66.06% <70.17%> (+7.54%) ⬆️
unit 70.19% <97.07%> (+18.76%) ⬆️

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

Components Coverage Δ
api/v1alpha1 (u) 100.00% <ø> (ø)
pkg/helpers (u) ∅ <ø> (∅)
pkg/log (u) 31.81% <ø> (ø)
pkg/reconcilers (u) 44.19% <90.47%> (+17.59%) ⬆️
pkg/limitador (u) 88.46% <97.82%> (+16.44%) ⬆️
controllers (i) 66.06% <70.17%> (+7.54%) ⬆️
Files Coverage Δ
api/v1alpha1/limitador_types.go 100.00% <ø> (ø)
pkg/limitador/deployment_options.go 100.00% <100.00%> (ø)
pkg/limitador/disk_storage_options.go 100.00% <100.00%> (ø)
pkg/limitador/inmemory_storage_options.go 100.00% <100.00%> (ø)
pkg/limitador/redis_cache_storage_options.go 100.00% <100.00%> (ø)
pkg/reconcilers/deployment.go 66.30% <100.00%> (+44.38%) ⬆️
pkg/limitador/redis_storage_options.go 96.66% <96.66%> (ø)
pkg/reconcilers/base_reconciler.go 33.92% <0.00%> (-0.62%) ⬇️
pkg/limitador/k8s_objects.go 81.37% <94.23%> (+9.64%) ⬆️
controllers/limitador_controller.go 60.94% <70.17%> (+10.23%) ⬆️

... and 4 files with indirect coverage changes

@eguzki
Copy link
Contributor Author

eguzki commented Sep 19, 2023

ready for review @Kuadrant/engineering

PVC *PVCGenericSpec `json:"persistentVolumeClaim,omitempty"`

// +optional
Optimize *DiskOptimizeType `json:"optimize,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

maybe we can add
// +kubebuilder:default=throughput

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would rather rely on Limitador's own defaults. If optimize is not set in the CR, it would not go in the command line and defaults would be applied by Limitador, not Limitador Operator.

Copy link
Member

@adam-cattermole adam-cattermole left a comment

Choose a reason for hiding this comment

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

Took me a little while to go through all the changes here but I've run through the verification and the code. I think it looks good from my side but perhaps you'd prefer a second review. Either way I'll leave my approve, nice job!

@eguzki
Copy link
Contributor Author

eguzki commented Sep 28, 2023

Took me a little while to go through all the changes here but I've run through the verification and the code. I think it looks good from my side but perhaps you'd prefer a second review. Either way I'll leave my approve, nice job!

Thanks @adam-cattermole

Sorry for the "too big" PR. I refactored the options to have a cleaner deployment objects. I think that the outcome is a better code to extend and maintain.

There is no rush. Let's wait for the review from @didierofrivia

@eguzki
Copy link
Contributor Author

eguzki commented Oct 2, 2023

rebased to fix merge conflicts (in the CSV)

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.

Great work! I've also tried it with optimize: throughput and the command sent to the limitador container was as expected. Also, the validation works when a different value than thoughput or disk is set. 🥇

@eguzki eguzki merged commit c76af84 into main Oct 2, 2023
@eguzki eguzki deleted the storage-disk branch October 2, 2023 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: To test
Development

Successfully merging this pull request may close these issues.

6 participants