-
Notifications
You must be signed in to change notification settings - Fork 182
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
Add condition to checkDependencies when SourceRef is the same #521
Conversation
@@ -490,6 +490,10 @@ func (r *KustomizationReconciler) checkDependencies(kustomization kustomizev1.Ku | |||
if !apimeta.IsStatusConditionTrue(k.Status.Conditions, meta.ReadyCondition) { | |||
return fmt.Errorf("dependency '%s' is not ready", dName) | |||
} | |||
|
|||
if len(k.Status.Conditions) == 0 || k.Spec.SourceRef.Name == kustomization.Spec.SourceRef.Name && k.Spec.SourceRef.Namespace == kustomization.Spec.SourceRef.Namespace && source.GetArtifact().Revision != k.Status.LastAppliedRevision { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for len(k.Status.Conditions) == 0
this is evaluated above. Another issue is that we only check the source name and namespace, but we really need to check the kind as well, as a GitRepository can have the same name as a Bucket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough i already thought about other specs to check but forgot the kind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the kind Check and remove the duplicated Conditions Check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run make fmt
commit the changes then squash all commits into one. Thanks!
…omizations with the same SourceRef Signed-off-by: Florian Fl Bauer <florian.fl.bauer@deutschebahn.com>
Hey, i performed a rebase on my branch and squashed all commits into one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @HardBrainer 🏅
As discussed in https://cloud-native.slack.com/archives/CLAJ40HV3/p1639665724208200 we identified a race condition in checkDependencies when using Receiver and both Kustomizations have the same SourceRef.
If triggered by the Receiver the checkDependencies is executed before the dependent Kustomization applied the latest Revision. To prevent this we check if the LastAppliedRevision is already the new Revision.
In this Case deployment-demoapp has an dependsOn to init-demoapp. This time deployment-demoapp waits untils init-demoapp applied the latest Revision: