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

Update outbound policy watches when routes change parents #13315

Merged
merged 3 commits into from
Nov 14, 2024

Conversation

adleong
Copy link
Member

@adleong adleong commented Nov 13, 2024

Fixes #13280

When an xRoute resource is updated to change its parent_refs, the route may attach to new parents or become unattached to parents it was previously attached to. However, in the policy-controller, the xRoute update will only be sent to the parents on the new version of the route resource and any existing watches on parents that the route was unattached from will not be updated.

Unfortunately, the kube-rs watch interface only provides the new version of a resource when it is updated, and not the previous state. This means that we cannot know which parents the route might have been unattached to when it was updated. Therefore, we send the route update to all NamespaceIndexes and each one removes that route from each parent if that parent is not currently an accepted parent of the route.

We also add integration tests for this behavior.

This issue applies to all xRoutes: policy HttpRoute, gateway HttpRoute, GrpcRoute, TlsRoute, and TcpRoute.

Copy link
Member

@olix0r olix0r left a comment

Choose a reason for hiding this comment

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

lgtm! makes sense.

}

// We must send the route update to all namespace indexes in case this
// route's parent_refs have changed and this route must be removed be
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// route's parent_refs have changed and this route must be removed be
// route's parent_refs have changed and this route must be removed by

}

// We must send the route update to all namespace indexes in case this
// route's parent_refs have changed and this route must be removed be
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// route's parent_refs have changed and this route must be removed be
// route's parent_refs have changed and this route must be removed by

}

// We must send the route update to all namespace indexes in case this
// route's parent_refs have changed and this route must be removed be
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// route's parent_refs have changed and this route must be removed be
// route's parent_refs have changed and this route must be removed by

}

// We must send the route update to all namespace indexes in case this
// route's parent_refs have changed and this route must be removed be
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// route's parent_refs have changed and this route must be removed be
// route's parent_refs have changed and this route must be removed by

Comment on lines 1447 to 1450
let (kind, group) = match resource_port.kind {
ResourceKind::Service => ("Service", "core"),
ResourceKind::EgressNetwork => ("EgressNetwork", "policy.linkerd.io"),
};
Copy link
Member

Choose a reason for hiding this comment

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

It would be ideal to use the type-oriented helpers

Suggested change
let (kind, group) = match resource_port.kind {
ResourceKind::Service => ("Service", "core"),
ResourceKind::EgressNetwork => ("EgressNetwork", "policy.linkerd.io"),
};
let (kind, group) = match resource_port.kind {
ResourceKind::Service => (Service::kind(&()), Service::group(&())),
ResourceKind::EgressNetwork => (linkerd_k8s_api::EgressNetwork::kind(&()), linkerd_k8s_api::EgressNetwork::group(&())),
};

So that we have more typo-proof static checking.

Signed-off-by: Alex Leong <[email protected]>
Copy link
Member

@zaharidichev zaharidichev left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -217,6 +217,49 @@ pub async fn await_route_status(
route_status
}

// Waits until an HttpRoute with the given namespace and name has a status set
// on it, then returns the generic route status representation.
pub async fn await_gateway_route_status(
Copy link
Member

Choose a reason for hiding this comment

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

Question: Is this change directly related or have you introduced this method in order to minimize flakiness that you have observed. I am asking because I myself am experiencing some flakiness because of delay in status setting, especially when the status controller has some more work to do.

Copy link
Member Author

Choose a reason for hiding this comment

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

To resolve flakiness that was causing tests to fail. I don't think it's directly related to this change.

@adleong adleong merged commit 59be08e into main Nov 14, 2024
42 checks passed
@adleong adleong deleted the alex/route-adoption branch November 14, 2024 17:32
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.

Modifying existing HTTPRoute to invalid configuration does not deregister it
3 participants