rabbit-stalker
rabbit-stalker copied to clipboard
Integrate rollouts
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
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?
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 {
}
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 😊
@craftcodedev Hello there, are you still interested on this? if not, this issue will be closed as stale
Hello @achetronic, I opened a PR. Please, take a look at it.
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!
As promised, some suggestions in the kitchen :)
https://github.com/prosimcorp/rabbit-stalker/pull/5#issuecomment-2032566254
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 😄
Closing this issue due to lack of author interest
We will implement this feature in the next release
Implemented on v1.3.0 https://github.com/prosimcorp/rabbit-stalker/releases/tag/v1.3.0