Skip to content

ateapi: egress policy RPCs cannot distinguish a missing actor from an actor without a policy #1703

Open

Description

@ygao-g

Filed per the discussion #1659 (comment).

GetActorEgressPolicy maps every store miss to NotFound "EgressPolicy not found". The store query behind it is a single SELECT on actor_egress_policies by (atespace, actor_name) with no actor lookup, so the RPC answers identically whether the actor does not exist or exists and simply has no policy:

GetActorEgressPolicy{atespace: team-a, actor: no-such-actor}   -> NotFound: EgressPolicy not found
GetActorEgressPolicy{atespace: team-a, actor: exists-no-policy} -> NotFound: EgressPolicy not found

UpdateActorEgressPolicy and DeleteActorEgressPolicy go through the same NotFound arm. CreateActorEgressPolicy already tells the two apart: a missing parent surfaces as FailedPrecondition "parent Actor does not exist".

Desired behavior, and where the CLI stands

The user must always learn which of the two happened. kubectl ate delivers that today, and this is the behavior to keep:

To get there the CLI issues a second GetActor whenever the policy RPC answers NotFound (get, delete). That is a workaround, not the end state: one extra round trip on every miss, repeated in every client that needs the distinction.

Behavior as of d277088.

Activity

  1. added theissue type on Sep 17, 2026
  2. changed the title [-]GetActorEgressPolicy returns the same NotFound for a missing actor and for an actor without a policy[/-] [+]ateapi: egress policy RPCs cannot distinguish a missing actor from an actor without a policy[/+] on Sep 23, 2026
  3. ygao-g commented on Sep 23, 2026

    @ygao-g
    CollaboratorAuthor

    Proposed fix

    Keep the NotFound code for both cases so existing callers such as the atenet policy cache are unaffected, and make the server say which resource is missing:

    • The store reads the actor with the policy (actors LEFT JOIN actor_egress_policies for Get and Update; an actor existence check after an empty DELETE ... RETURNING for Delete) and returns a distinct parent-not-found error.
    • The RPC layer attaches a google.rpc.ResourceInfo detail (resource_type Actor or EgressPolicy, resource_name <atespace>/<name>) and names the actor in the message.
    • Clients branch on the detail and drop the second GetActor. The CLI behavior above does not change.

    CreateActorEgressPolicy keeps FailedPrecondition for a missing parent. A change covering all three RPCs is drafted as ygao-g#39 and will be filed here.

  4. ygao-g commented on Sep 23, 2026

    @ygao-g
    CollaboratorAuthor

    Discussed with Julian Gutierrez Oschmann (@juli4n) privately. Their concerns are that we make common cases more expensive (e.g. (actors LEFT JOIN actor_egress_policies, or a second query on the not found path), trading the performance just to avoid an extra read in one CLI tool, on the uncommon cases.

    The suggestion is to have the workaround on the CLI side, e.g., try fetching the actor if encountering a NotFound error, as client CLI tools usually orchestrate calls like this, is fairly common.

    Bowei Du (@bowei) , haiyanmeng WDYT?

  5. haiyanmeng commented on Sep 23, 2026

    @haiyanmeng
    Collaborator

    Did some digging, the issue was filed per the discussion #1659 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area/apiUser-facing API changesarea/networkkind/bugSomething isn't working / bugfixes

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions