rabbit-stalker icon indicating copy to clipboard operation
rabbit-stalker copied to clipboard

Integrate rollouts

Open craftcodedev opened this issue 1 year ago • 7 comments

Problem: I am using ArgoCD rollouts for auto rollback when the analysis fails. The rollouts are executed for each new replicaset. Therefore, we are having a lot of rollouts as a new replicaset is created when a deployment is restarted by the rabbit-stalker operator.

Solution: I want to include rollouts in rabbit-stalker to be able to reset rollouts instead of deployment.

@achetronic @sebastocorp

craftcodedev avatar Feb 29 '24 19:02 craftcodedev

Hey @craftcodedev thanks for rising this issue!

This use case is interesting. As far as I know, to reset a Rollout you need to change the spec.restartedAt field

https://argo-rollouts.readthedocs.io/en/stable/features/restart/#scheduled-restarts

Is this a solution for your use case? Could you open a PR for that?

achetronic avatar Feb 29 '24 21:02 achetronic

Hey @achetronic thanks for your answer.

Sure I will, could you give me permissions? I was taking a look at the code and I think the SetWorkloadRestartAnnotation should be modified adding the rollout kind (ResourceKindRollout) and the proper annotation (.spec.restartAt). Could you give me an example to add in the pr how should be the condition modifying the annotation? Something like:

if kind == ResourceKindRollout {

}

craftcodedev avatar Mar 01 '24 07:03 craftcodedev

Hey, about permissions for making contributions the process starts forking the repository, creating the changes in another branch, and then opening a PR to this project, then it will be accepted by @sebastocorp or me

About the code, you are dealing with Rollout, which is a custom resource. This process is usually a bit different than the process needed for core resources (Daemonset, Deployment, etc)

When storing a Custom Resource into a variable after retrieval from API server, you need to store it into a unstructured.Unstructured{} type and not into a core type

Remember that Go is a strong typed language, and Kubernetes core resources are well known, so you can craft a Struct for a core resource, which has some adventages

Different resources than core ones are treated as unstructured as, from Golang point of view, you don't know how to do the Struct previously, and this forces to store it into a map[string]interface{}, which are harder to deal. But kubebuilder give us a better approach with the unstructured.Unstructured{} type, adding some useful methods over the map I mentioned

This being said, you are right. Only needed some small pieces of code for the changes, but you have to take care with the difference between core resources and custom ones 😊

achetronic avatar Mar 01 '24 08:03 achetronic

@craftcodedev Hello there, are you still interested on this? if not, this issue will be closed as stale

achetronic avatar Mar 18 '24 11:03 achetronic

Hello @achetronic, I opened a PR. Please, take a look at it.

craftcodedev avatar Mar 22 '24 20:03 craftcodedev

Hello @craftcodedev thanks for your contribution! I will review it deeper during next days 😊

By the moment I have reviewed it on bird view, and I have detected some little incosistencies with our code quality that will have to be fixed. I will suggest some little changes on the PR. Keep in touch!

achetronic avatar Mar 24 '24 10:03 achetronic

As promised, some suggestions in the kitchen :)

https://github.com/prosimcorp/rabbit-stalker/pull/5#issuecomment-2032566254

achetronic avatar Apr 02 '24 16:04 achetronic

Hey @blasshak sorry for the long wait. We have heard you so we are merging some changes to make this work better. The changes are already in master branch

Thanks to these changes, you should be able to create a function that return a patch and it's type. Basically this is all you need now to extend our operator :)

basically, you only need to create a function like this one, but specialized on Argo Rollouts patch:

https://github.com/prosimcorp/rabbit-stalker/blob/main/controllers/workloadaction_sync.go#L309C1-L321C2

Moreover, you need to register your function here: https://github.com/prosimcorp/rabbit-stalker/blob/main/controllers/workloadaction_sync.go#L344-L348

And add your constant for Argo Rollout here: https://github.com/prosimcorp/rabbit-stalker/blob/main/controllers/workloadaction_sync.go#L57-L59

Something like ResourceKindArgoRollout = "Rollout" will be enough


With these changes from your side, if you find the time to open the PR, we can test and release a new version if tests pass, and everything will be fixed now 😄

achetronic avatar May 16 '24 12:05 achetronic

Closing this issue due to lack of author interest

We will implement this feature in the next release

achetronic avatar Jul 10 '24 22:07 achetronic

Implemented on v1.3.0 https://github.com/prosimcorp/rabbit-stalker/releases/tag/v1.3.0

achetronic avatar Aug 13 '24 13:08 achetronic