-
Notifications
You must be signed in to change notification settings - Fork 34
Protects ensureNamespace() Against Race with Contour #19
Conversation
39188a9
to
e616e7c
Compare
e616e7c
to
ff6a443
Compare
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.
Can you please also add the commentary from the PR into the body of the commit message? This makes life easier for our future selves; we can see the rationale for the change directly without having to follow breadcrumbs back to the PR.
ff6a443
to
d70ed28
Compare
/lgtm |
On further thought... Were you consistently seeing the failure? It looks like a race condition, and I don't see how the code change avoids it (although the refactored code does look cleaner). I would be inclined to ignore "already exists" errors (just let the reconciler rerun, and the get should succeed the next time and result in a no-op), but you could check with |
controller/contour/namespace.go
Outdated
r.Log.Info("namespace exists; skipped adding", "name", ns.Name) | ||
return nil | ||
case errors.IsNotFound(err): | ||
if err := r.Client.Get(ctx, types.NamespacedName{Name: ns.Name}, ns); err != nil { |
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.
Is there still a remaining case where there's an error getting the namespace, but it's different than the IsNotFound(...)
method case?
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.
@stevesloka I reorganized the conditions for both ensure namespace functions, PTAL.
d70ed28
to
0c041d4
Compare
@Miciah thanks for the feedback in #19 (comment). You are correct, I was hitting a race condition between the Contour object being updated by |
0c041d4
to
9377428
Compare
@Miciah thanks for the review. Commit |
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 had a couple small suggestions for simplification but I don't consider them blocking and this can be merged as-is.
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
We can merge as-is like @skriss mentioned, or clean up the few nits in a new PR.
Signed-off-by: Daneyon Hansen <[email protected]>
9377428
to
66a9e56
Compare
@skriss commit |
Previously,
ensureNamespace()
was returning an error during the 2nd pass of contour object reconciliation. This is due to a race between the Contour object being updated by ensureFinalizer() and the namespace create operation. This PR updates the control flow of the function to fix the error case for create and delete operations.Before:
With this PR:
/cc @jpeach @Miciah