-
Notifications
You must be signed in to change notification settings - Fork 112
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
Build controller should watch referenced secrets #466
Comments
@SaschaSchwarze0 can u add more context in here around the extra fixes this card will provide us, bitte? |
Sure, these scenarios should be:
Going forward, once we also validate the content of the secret (correct secret type, registry push permission), we will need to extend this reconciliation:
But that's probably a second step in a separate issue. But regarding this issue, a question I have is if we want to specifically watch referenced secrets are referenced objects in general which will also include the build strategy? |
Just to answer your question.
I will initially say no, because an strategy once applied should be immutable. Is an immutable object because in theory this is a resource controlled by the admin entities, not regular users. A Build that references an strategy can assume that such strategy will not change its contents, and that any change on the strategy should end-up as a new strategy with a new name. |
We need to care about the namespace scope and secret event type to make sure the performance is good. |
The objective is to be able to declare the |
@sbose78 yes, by ensuring that the Build validation not only happens during a creation event, but also if a secret gets deleted. Concrete use case is:
Based on the above, we should "re-validate" a Build when an event(deletion) takes place on the referenced secret. |
@sbose78 any concerns on this? or things important to keep in mind |
My understanding is that the controller-runtime client uses a previously-populated cache for reading secrets, and therefore this should be good! @gabemontero , thoughts on this ? :) |
@qu1queee @zhangtbj @sbose78 @SaschaSchwarze0 Because I plan to take this issue, I go through above discussions, just want to confirm, this issue will focus on below two cases, right?
|
About the second case:
We already support this case. I don't understand the scenario which @SaschaSchwarze0 mentioned well:
I think it is a default behavior from kube, what can we do to improve in this issue? |
Our current code uses an error driven reconciliation loop. This is not ideal for two reasons:
In short: by reconciling the build on secret creation, we improve efficiency and user experience. |
+1 on @SaschaSchwarze0 and @zhangtbj thanks for asking (very valid question) . In a nutshell, by watching the secret those long frequencies will not be a concern anymore, whenever the secret gets deleted/created. I pinged @xiujuan95 offline, I will be pairing with her on this card, to save some comments on this issue. If @SaschaSchwarze0 or @zhangtbj wants to join us, let us know. |
Pls go ahead. My only question is about:
First of all, I think, in our current logic, our build controller will always keep reconciling if the secret doesn't exit. So although we add secret creation event, it just make ONE reconciliation faster once the secret is created, but before that, such as ONE DAY without the secret, the build controller will still keep reconciling and also cost CPU and Memory.
And I think error reconciling should not take minutes, should be just several seconds So I think it is better that we just care about the secret |
It might not have been made clear, but, once we reconcile on secret creation, we also will stop returning an error in the build reconciliation when it determines a missing secret. So, we will not keep reconciling on such a build. This saves resources in our controller. The reconciliation indeed only needs seconds. But, what - with the current implementation - can take minutes, is the time between secret creation and build reconciliation. If our controller returns an error, it is out of our control on when the next reconciliation happens. This will be addressed in this issue - by reconciling the build when a secret is created. |
The biggest challenge with this feature is that the build controller (or another controller therein) would need to do the following:
Doing this with what we have today would result in a Cartesian explosion - for a given namespace, every secret N would need to check M Build objects. This can't scale. OwnerRefs is probably not the way to go, since a secret could be referenced by multiple Build objects. It also risks a secret being deleted accidentally if the parent Build object is deleted. The inverse is also true (don't want to delete a Build because it is owner-refed by all Secrets). Perhaps we add annotations to referenced Secrets when the Build object is created/updated? And similarly remove/update annotations if the Build object is deleted? |
@adambkaplan agree. I started on this today together with @xiujuan95 and I have exactly the same concern, see todo comment . One important thing is that the controller-runtime should be getting resources from the cache( see discussion, but still is an expensive call |
During the implementation, I met a problem, when delete secrets event happens, I can't recognize which build is referencing this secret. So according to current logic, it will alway reconcile a build called this secret's name, this is not expected.
Below is an example, I have a secret called
So maybe I also agree with @adambkaplan to add
Once the referenced secret is deleted, then all builds ("build-0", "build-1", ''build-2") are referencing this secret will be reconciled. And I think this way also can improve controller's performance, because we don't need to reconcile all builds when a secret is deleted. |
Approach looks fine to me. Implementation note:
|
Adding to that: Controller-runtime client uses a cache for reading and it populates the cache by watching any resources that were requested. Are there general scale concerns around watching all secrets here ? |
@sbose78 I do prefer to do #466 (comment) , two levels of filtering via predicates and the watcher. Asking for your input around who will define the annotation. I think in a nutshell there are two options:
we have been discussing this today @xiujuan95 @SaschaSchwarze0 and myself, what are ur thoughts? |
From #457
Idea:
Currently a Build validation (see comment for more information) takes place only during events on the Build (e.g. create, update).
Referenced secrets on a Build definition might not longer be present during runtime of a BuildRun(creation event), leading to unwanted experiences for users during the BuildRun execution.
Because a BuildRun already have a "basic" mechanism for preventing that the building starts, if the Build validations fail, we should enhance the Build reconciles and also validate when particular events on the reference secrets take place.
Acceptance_Criteria:
Some thoughts on the implementation:
The text was updated successfully, but these errors were encountered: