Skip to content
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

Merged
merged 1 commit into from
Jan 10, 2022

Conversation

derbauer97
Copy link

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:

image

@@ -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 {
Copy link
Member

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.

Copy link
Author

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.

Copy link
Author

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

Copy link
Member

@stefanprodan stefanprodan left a 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>
@derbauer97
Copy link
Author

Hey,

i performed a rebase on my branch and squashed all commits into one. make fmt did not create any new changes.

Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks @HardBrainer 🏅

@stefanprodan stefanprodan merged commit 748120f into fluxcd:main Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants