Commit Graph

14 Commits

Author SHA1 Message Date
Francesco Giudici fda53de0e2
Kubebuilder: fix MachineRegistration search during registration (#280)
* operator: fix MachineSelector controller log

* operator: fix MachineRegistration search in registration

Fixes #279

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-12-02 16:13:34 +01:00
Francesco Giudici 5fc15fa0d6
operator: don't try to patch an empty MachineInventory (#274)
just skip and update the status to show we are waiting for the
inventory.

Fixes #273

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-12-01 19:04:12 +01:00
Alexander Demicev 087bdbd14f
Backport minor fixes (#271) 2022-12-01 18:42:52 +01:00
Alexander Demicev 9c212ea32a
Merge all main logic in one file (#270) 2022-12-01 14:59:11 +01:00
Francesco Giudici 5df274078b
[controller_runtime] operator/registration: switch to Kubebuilder client (#256)
* operator/registration: switch to Kubebuilder client

Fixes #239

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* operator/registration: adapt tests to Kubebuilder client

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* unit-tests: vendor controller-runtime fake client

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* operator: add yaml annotations for correct marshalling

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* operator/RBAC: add "get" verb to ServiceAccount resources

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* operator: generate rbac

make generate-manifests
make build-rbac

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* Add elementalcli package

Create a separate package to deal with elemental-cli installation.
This brings the elemental-cli functions declared in the config package
to a new package that just parses a map[string]interface argument.

This is a step to enable usage of the elemental-cli functions with the
new elementalv1.Config.Elemental.Install type.

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* register: switch to Kubebuilder api

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* register: add mapstructure annotations for correct marshalling

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* register: reduce complexity of the run function

Make linter happy:
"cyclomatic complexity 16 of func `run` is high (> 15) (gocyclo)"

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* register: drop io/ioutil in favor of os package

io/ioutil is deprecated

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-11-28 17:34:47 +01:00
David Cassany Viladomat 5757f2d82f
Add a rate limiter to managedosversionchannel reconciler (#260)
This commit adds a rate limiter to the ManagedOSVersionChannel controller to prevent
stacking reconcile loops over the same resource in fast rates (doesn't make sense for a
ManagedOSVersionChannel). By default the controller runtime already includes an
equivalent rate limiter, but starts in the range of milliseconds, starting the exponential
rate limiter in the range of seconds is more than enough in this context.

In addition it drops the failures counter in the resource. This counter was supposed to
be used to limit the number attempts to sync in case of failure. This was a bad design,
status should not keep a counter like this as any change in status triggers a new
immediate reconcile loop, hence the counter was reaching the maximum as fast as the
controller runtime was executing reconcile loops without any rate limiter (rate limiter
applies only when there are no changes including status).

For now I think we can just live without the setting any maxium for failures. If we ever
need it I believe it should be coded and tracked within the controller itself, not in each
resource as this prevents the reconcile loop of being idempotent. Alternatively we could
prevent triggering the reconcile loop on status changes, however this prevents
reconciling if any third party (or user from the kubectl client) changes a resource status.

Fixes #257
Part of #240

Signed-off-by: David Cassany <dcassany@suse.com>
2022-11-22 15:40:15 +01:00
David Cassany Viladomat c18f66d8b8
Drop requeuer, not needed anymore (#255)
* Drop requeuer, not needed anymore
* Improve logging

Signed-off-by: David Cassany <dcassany@suse.com>
2022-11-21 12:37:14 +01:00
David Cassany Viladomat 5b68534515
Improve syncer (#252)
This commit adds few changes on the syncer logic:

* Makes use of ManagedOSVersionChannel status reason to track if there
  is an on going synchronization rather than polling for the existence of a synchronization pod or not.

* Adds a logic to stop trying to synchronize after 4 consecutive attempts.
  If it exceeds the maximum it just programs the next re-sync after the given sync
  interval instead of immediately retrying.

* Adds some logging and comments here and there.

Signed-off-by: David Cassany <dcassany@suse.com>
2022-11-18 14:33:12 +01:00
David Cassany Viladomat ed268ce451
New syncer logic (#245)
* Implement syncer logic as part of the ManagedOSVersionChannel controller

  This commit adds the logic to synchronize managedosversionchannels
  within the already existing controller.

* make generate
* make build-manifests
* Update chart
* update e2e tests

Signed-off-by: David Cassany <dcassany@suse.com>
2022-11-16 18:38:23 +01:00
Francesco Giudici 7b3a13dd7a
controller: add Secret name reference to the ServiceAccount (#247)
Otherwise we will have no Secrets in the ServiceAccount for kubernetes
clusters >= 1.24

Fixes: #246

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-11-15 11:04:45 +01:00
Alexander Demicev db7d0dd68e
Add remaining controllers (#232)
* Update vendor

* Run generation tasks

* Minor fixes in Makefile

* Remove old code

* Add remaning controllers

* Minor e2e tests improvements

* Switch osversionchannel syncer to controll runtime

* Minor fixes in controllers

* Fix unit tests
2022-11-10 11:26:34 +01:00
Alexander Demicev d553a0883d Kubebuilder: Add machine inventory selector controller (#224)
* Add machine inventory selector controller

* Remove old machine inventory selector code
2022-10-27 12:30:03 +02:00
Alexander Demicev 3d5da19c60 Kubebuilder: Add machine inventory controller (#221)
* Add machine inventory controller

* Remove old code

* Add managed label to created secret
2022-10-27 12:29:24 +02:00
Alexander Demicev 0fde15069d Kubebuilder: Add machine registration controller (#206)
* Add new package to Dockerfile

* Update dependencies

* Add unit test helpers

* Add new machine registration controller

* Remove old machine registration controller

* Add rbac tag for secrets

* Fix container argument in chart

* Add labels to all created resources
2022-10-27 12:28:55 +02:00