feat: kubectl ate logs filter container supervisor#311
feat: kubectl ate logs filter container supervisor#311Mayowa Fajobi (MayorFaj) wants to merge 3 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Signed-off-by: MayorFaj <mayorfaj@gmail.com>
Signed-off-by: MayorFaj <mayorfaj@gmail.com>
7e57fbc to
f0dd7c3
Compare
| // Read actor_id and container_name from the same (first actor-identifying) | ||
| // label map so a line's source is never split across the two keys. | ||
| var actorID, containerName string | ||
| for _, labelKey := range logActorLabelKeys { |
There was a problem hiding this comment.
Instead of iterating over all label keys, how about having a method that takes the log entry map (i.e. m) and returns labels. It iterates on the possible keys and probes them, and return the first one that matches. That simplifies the control flow at the caller.
There was a problem hiding this comment.
Done, extracted it into a helper so the caller no longer iterates the keys inline. Based on follow-up review it ended up as actorSource(m) returning - actorID, containerName - (reads both from the first map carrying ate.dev/actor_id), which keeps the same-map guarantee and drops the loop at the call site. Thanks for the nudge!
…to a separate function
| func init() { | ||
| logsActorsCmd.Flags().BoolVarP(&followLogs, "follow", "f", false, "Specify if the logs should be streamed.") | ||
| logsActorsCmd.Flags().StringVarP(&containerFlag, "container", "c", "", "Show logs only from the named container within the actor. Mutually exclusive with --supervisor.") | ||
| logsActorsCmd.Flags().BoolVar(&supervisorFlag, "supervisor", false, "Show only the ateom supervisor (lifecycle) logs. Mutually exclusive with --container.") |
There was a problem hiding this comment.
Why making --container and supervisor mutually exclusive? They seem orthogonal to me.
I was expecting:
--supervisor(boolean, defaults to false): whether to include supervisor logs or not--container(string, default to ""): if set, restricts to the logs of this container.
WDYT?
Fixes #294
Summary
Implements
kubectl ate logs actors <id>can now filter by source:-c, --container <name>— only that container's logs--supervisor— only ateom lifecycle logs (Actor restoring/restored/…)--containerand--supervisorare mutually exclusive. After #290 everyforwarded container line carries an
ate.dev/container_namelabel andsupervisor lifecycle lines carry none, so this is implemented client-side.
What changed
CLI (
cmd/kubectl-ate)--container/-cand--supervisorflags.logLineFilter+matchesSource()encode the selection rules.filterAndDisplayLogLinereadsactor_idandcontainer_nameatomicallyfrom the first recognized label key, and returns the zero time for any
non-displayed line so follow mode's resume cursor only advances on lines the
user actually sees (a reconnect can't skip wanted lines).
validateLogFilterFlagsenforces mutual exclusion, called from the cobracommand and from
LogsActorRunner.Run(fail-fast for direct construction).ateom log wrapper (
cmd/ateom-gvisor) — security hardeningWrapContainerLogsstrips application-providedate.dev/*labels from bothrecognized label keys before injecting Substrate metadata, so an app cannot
spoof another actor's
actor_id/container_nameunder the key a consumertreats as authoritative.
Docs
cmd/kubectl-ate/README.mdanddocs/observability.mddocument the flags andmutual exclusivity; examples use the required
kubectl ate logs actorsform.Design notes
MarkFlagsMutuallyExclusive, which keys offflag.Changedand would wronglyreject
--container x --supervisor=false.Testing
atomicity, foreign-actor),
validateLogFilterFlags,Runfail-fast,follow-mode resume-cursor regression, and
TestWrapContainerLogs_CrossKeyLabelSpoofing.make testgreen;gofmt/go vetclean.-c counter,--supervisor,and the mutual-exclusion error all behave as expected.