Skip to content

Link container data regardless of kube talker - #395

Open
biscout42 wants to merge 11 commits into
oci-trees-go-bindingsfrom
fix-container-link
Open

biscout42 wants to merge 11 commits into
oci-trees-go-bindingsfrom
fix-container-link

Conversation

@biscout42

@biscout42 biscout42 commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

As we link container data from an external process there is no need to check kube talker.

That is a bit complex, because adds parsing cgroup to all events. I have added guards to reduce the performance footprint for non-k8s use case. It should behave like this:

  • An empty metadata tree causes no cgroup parse.
  • A non-container cgroup is parsed only once.
  • A container ID is built and allocated only once.
  • A failed metadata lookup still occurs for each event while the tree is nonempty.
  • A cgroup change clears the cached result.
  • Container metadata that arrives later can still match the cached ID.

Implications:

  • Initial metadata: all existing processes are linked in a full pass during a queue open.
  • Later asynchronous metadata: no immediate full pass; processes are linked opportunistically when they next produce an event.
  • A process that produces no subsequent event can remain unlinked until another linking pass or relevant event occurs.

Imho the last point is acceptable because no events meaning no messages to deliver from a queue.

TODO:

  • Backend-less test fixture. Link container data regardless of kube talker #395 adds a shared quark_queue_init_trees helper plus its own stub queue ops in the C tests, but does not consolidate the two fixtures from Exposed OCI trees and helpers to go-quark #383 or the copy in the Go cgo preamble. There are now four copies instead of three.
  • Explore alternative for dropping the quarktest tag. In this PR libquark exports quark_queue_init_trees in the header's "exported for testing only" section. With a one-line null guard on queue_ops in quark_queue_populate, matching the guard already in quark_queue_close, the stub ops become unnecessary. The Go helper then shrinks to a few lines that call calloc, call the init function, and set two fields, with no C preamble at all. It could sit unexported at the bottom of quark.go. That is test-only code in a production file, but it mirrors the precedent libquark already sets in its header. Precisely the same change also collapses the three hand-rolled C and Go fixtures, which is the fixture-duplication finding two items down the list.

@biscout42
biscout42 requested a review from a team as a code owner August 20, 2026 12:38
@biscout42
biscout42 changed the base branch from main to oci-trees-go-bindings August 20, 2026 12:38
@biscout42
biscout42 requested a review from Tacklebox August 20, 2026 12:40
@biscout42 biscout42 changed the title fix container link Link container data regardless of kube talker Aug 20, 2026
Comment thread quark.c Outdated
Comment thread quark.c
Comment thread quark.c Outdated
Comment thread quark.c
Comment thread quark.c Outdated
@biscout42
biscout42 force-pushed the fix-container-link branch 3 times, most recently from 21e8cce to 01e181d Compare September 16, 2026 16:05
@biscout42
biscout42 removed the request for review from Tacklebox September 16, 2026 17:06
@biscout42
biscout42 force-pushed the fix-container-link branch 3 times, most recently from 38628b7 to 736b875 Compare September 24, 2026 11:29
biscout42 and others added 11 commits September 25, 2026 19:17
Avoid using the lazy public lookup in internal event assembly.
Co-authored-by: Christos Kalkanis <christos.kalkanis@elastic.co>
…ue ops

Link existing processes at queue open only when a kube talker is present.
Without it the container tree is empty and the pass does nothing.

Return early from quark_queue_populate when queue_ops is NULL. This removes
the stub ops from the C and Go tests. Move the Go test queue helper into
quark.go and remove the quarktest build tag.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…backend-less queue

Do not unlink a process from its container when the new cgroup
does not name a different container. Do not call update_stats
when the queue has no backend. Use process_cache_get in the
mprotect event.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Install a queue_ops table that does nothing instead of a NULL
pointer. Remove the NULL checks from populate and get_stats.
Use the new function in all C and Go test fixtures.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ontainer

Put the flag in the hole after pid. This saves 8 bytes per cached
process. Replace three copies of the container unlink code with
one helper.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@christos68k

Copy link
Copy Markdown
Member

I opened a subsequent PR (set to merge into this one) to address a race condition / ordering issue between kube-talker and API when creating a container. See: #438

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants