serving icon indicating copy to clipboard operation
serving copied to clipboard

Service lets you point traffic at revisions it does not own

Open dprotaso opened this issue 4 years ago • 7 comments

What version of Knative?

Repro'd with 0.25.1

Expected Behavior

Update the traffic rules of a Service to point to another revision should fail

Actual Behavior

The traffic rule is realized and hitting Service A will route traffic to a revision owned by a different Service

Steps to Reproduce the Problem

$ kn service create aaa --image gcr.io/knative-samples/helloworld-go --env TARGET=A
...
$ kn service create bbb --image gcr.io/knative-samples/helloworld-go --env TARGET=B
...
$ curl aaa.default
Hello A!
$ curl bbb.default
Hello B!
$  kn service update aaa --traffic bbb-00001=100
$ curl aaa.default
Hello B!

dprotaso avatar Sep 03 '21 13:09 dprotaso

@dprotaso I guess we can retrieve the traffic targets and see if they are owned by the service at the webhook validation side. Otherwise to keep validation light we can fail when we try to configure traffic for the route during route reconciliation. WDYTH?

skonto avatar Sep 07 '21 09:09 skonto

I don't think we can reliably do that without any false positives. A more lightweight approach might be to allow setting ConfigurationName and RevisionName at the same time (I think it's disallowed right now) and then always force ConfigurationName = ServiceName in the Service API, so cross-references would be impossible.

markusthoemmes avatar Sep 07 '21 09:09 markusthoemmes

We still have an issue of how to link a revision to a configuration name in here in any case: https://github.com/knative/serving/blob/main/pkg/reconciler/route/route.go#L271. Ownerref may help here but may not be ideal (as we discussed offline).

skonto avatar Sep 07 '21 10:09 skonto

I think doing it as part of reconciliation would be the cheapest as the objects would be in the informer cache

dprotaso avatar Sep 08 '21 20:09 dprotaso

This issue is stale because it has been open for 90 days with no activity. It will automatically close after 30 more days of inactivity. Reopen the issue with /reopen. Mark the issue as fresh by adding the comment /remove-lifecycle stale.

github-actions[bot] avatar Dec 08 '21 01:12 github-actions[bot]

/lifecycle frozen /triage accepted

dprotaso avatar Dec 08 '21 14:12 dprotaso

/assign

linkvt avatar Dec 05 '25 13:12 linkvt