Skip to content

kubectl-ate: add update egress-policy - #1813

Merged
Tim Hockin (thockin) merged 3 commits into
agent-substrate:mainfrom
ygao-g:kubectl-ate-egress-update
Sep 24, 2026
Merged

Tim Hockin (thockin) merged 3 commits into
agent-substrate:mainfrom
ygao-g:kubectl-ate-egress-update

Conversation

@ygao-g

Copy link
Copy Markdown
Collaborator

Part of #1550.

Adds kubectl ate update egress-policy <actor-name> -a <atespace> -f <manifest>, which replaces an actor's egress policy and prints the result. To prevent an edit from overwriting a change made since the read, the server rejects a manifest with metadata.uid and metadata.version that mismatch stored ones. On NotFound the command says whether the actor or the policy is missing; on Aborted (due to uid/version mismatch) it points back at get -o yaml.

Testing

go test -race ./cmd/kubectl-ate/..., go vet, gofmt. On kind: get, edit, update round trip; stale version, missing uid and version, atespace mismatch, and update with no policy all exit 1 with the policy unchanged.

🤖 This PR was developed with AI assistance. I have reviewed and tested all changes.

@ygao-g Yuan Gao (ygao-g) added kind/feature An enhancement / feature request or implementation area/cli area/network labels Sep 23, 2026
@haiyanmeng haiyanmeng added this to the M3 milestone Sep 23, 2026
@ygao-g
Yuan Gao (ygao-g) force-pushed the kubectl-ate-egress-update branch 5 times, most recently from f61b0f6 to d7d4b34 Compare September 23, 2026 22:07
@@ -37,6 +37,8 @@ var (

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

in the future, you might want to consider doing this

var (
  egressPolicyFlags struct {
    atespace string
    filename string
  }
)

Having separate flag vars for each independent use seems to be overkill.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we may also want to just put this in its own package

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in the first commit as you suggested for the commands to share the variables for flag values. However, actor.go and actortemplate.go still keep per-verb vars.

we may also want to just put this in its own package
Do you mean putting flags for all commands in a separate package, or one package per resource type? I can address this in a follow-up so this PR stays about update.

Comment thread cmd/kubectl-ate/README.md Resolved
Comment thread cmd/kubectl-ate/README.md Resolved
Comment thread cmd/kubectl-ate/README.md Resolved
@bowei

Copy link
Copy Markdown
Collaborator

As a follow up, I think we should have a --force flag for update that ignores uid and version.

get and create each declared their own atespace and filename flag vars,
though a process only ever runs one verb. One egressPolicyFlags struct
now backs both, and the update verb registers onto it next.
Reading and parsing the -f manifest into an EgressPolicy moves out of
create into loadEgressPolicyManifest so the update verb can share it.
`kubectl ate update egress-policy <actor-name> -a <atespace> -f <manifest>`
replaces an actor's egress policy with the manifest and prints the result.
The manifest must carry the metadata.uid and metadata.version, and the
server rejects them when they no longer match the stored ones, so the
command never overwrites a change made since the read.
@ygao-g

Copy link
Copy Markdown
Collaborator Author

As a follow up, I think we should have a --force flag for update that ignores uid and version.

Agreed as a follow-up, tracked in #1861. --force would read the stored policy and copy them, as the server rejects an update without uid and version .

@bowei
Bowei Du (bowei) added this pull request to the merge queue Sep 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 24, 2026
@thockin
Tim Hockin (thockin) added this pull request to the merge queue Sep 24, 2026
Merged via the queue into agent-substrate:main with commit d7d7042 Sep 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli area/network kind/feature An enhancement / feature request or implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants