Skip to content

Fix invalid l5d-require-id for some tap requests#3210

Merged
siggy merged 1 commit intomasterfrom
siggy/require-id-ns-fix
Aug 8, 2019
Merged

Fix invalid l5d-require-id for some tap requests#3210
siggy merged 1 commit intomasterfrom
siggy/require-id-ns-fix

Conversation

@siggy
Copy link
Member

@siggy siggy commented Aug 8, 2019

PR #3154 introduced an l5d-require-id header to Tap requests. That
header string was constructed based on the TapByResourceRequest, which
includes 3 notable fields (type, name, namespace). For namespace-level
requests (via commands like linkerd tap ns linkerd), type ==
namespace, name == linkerd, and namespace == "". This special casing
for namespace-level requests yielded invalid l5d-require-id headers,
for example: pd-sa..serviceaccount.identity.linkerd.cluster.local.

Fix l5d-require-id string generation to account for namespace-level
requests. The bulk of this change is tap unit test updates to validate
the fix.

Signed-off-by: Andrew Seigner siggy@buoyant.io

PR #3154 introduced an `l5d-require-id` header to Tap requests. That
header string was constructed based on the TapByResourceRequest, which
includes 3 notable fields (type, name, namespace). For namespace-level
requests (via commands like `linkerd tap ns linkerd`), type ==
`namespace`, name == `linkerd`, and namespace == "". This special casing
for namespace-level requests yielded invalid `l5d-require-id` headers,
for example: `pd-sa..serviceaccount.identity.linkerd.cluster.local`.

Fix `l5d-require-id` string generation to account for namespace-level
requests. The bulk of this change is tap unit test updates to validate
the fix.

Signed-off-by: Andrew Seigner <siggy@buoyant.io>
@siggy siggy added the area/tap label Aug 8, 2019
@siggy siggy requested a review from kleimkuhler August 8, 2019 00:02
@siggy siggy self-assigned this Aug 8, 2019
ns := req.GetTarget().GetResource().GetNamespace()
ns := res.GetNamespace()
if res.GetType() == pkgK8s.Namespace {
ns = res.GetName()
Copy link
Member Author

Choose a reason for hiding this comment

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

this is the actual fix.

@l5d-bot
Copy link
Collaborator

l5d-bot commented Aug 8, 2019

Integration test results for 5d4a1ab: success 🎉
Log output: https://gist.github.com/2fe791cfaa7efbc87443c9cf35cd747c

Copy link
Contributor

@kleimkuhler kleimkuhler left a comment

Choose a reason for hiding this comment

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

This looks great! I'd like to be a little more familiar with the reflection going on in the tests, but have not had the chance to step through running this locally. However, the code changes look good and if this passes then 👍 from me for getting this in the edge tomorrow.

}

objects, err := s.k8sAPI.GetObjects(req.Target.Resource.Namespace, req.Target.Resource.Type, req.Target.Resource.Name)
objects, err := s.k8sAPI.GetObjects(res.GetNamespace(), res.GetType(), res.GetName())
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for switching these over!

k8sAPI.Sync()

err = fakeGrpcServer.TapByResource(&exp.req, &stream)
if !reflect.DeepEqual(err, exp.err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah this is good to see. Thanks for adding this

@siggy siggy merged commit f98bc27 into master Aug 8, 2019
@siggy siggy deleted the siggy/require-id-ns-fix branch August 8, 2019 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants