Skip to content

fix(kubernetes): emit each topology identity once per snapshot - #545

Draft
thbertoldi wants to merge 2 commits into
StackVista:stackstate-7.78.2from
thbertoldi:fix/kubernetes-topology-duplicates
Draft

thbertoldi wants to merge 2 commits into
StackVista:stackstate-7.78.2from
thbertoldi:fix/kubernetes-topology-duplicates

Conversation

@thbertoldi

Copy link
Copy Markdown

Kubernetes topology collectors can submit the same identity several times within one snapshot. For example, a Qdrant container mounting two files from one ConfigMap produces the same container-to-ConfigMap relation twice; shared ingress endpoints and host paths similarly repeat components. The backend retains one observation but reports duplicate-item synchronization errors.

Accept the first component and relation observation for each external ID in the snapshot using concurrent identity caches. Deduplicate relations before deciding whether to queue them, so a duplicate arriving after its endpoints cannot replace an earlier queued observation. Drain queued relations after correlation. Each new snapshot gets fresh caches, preserving subsequent updates, existing identifiers and missing-endpoint filtering. Existing ingress tests now expect one shared endpoint with the distinct ingress relations retained. Include a Cluster Agent release note.

Validation:

  • The new regression failed before the fix: 400 component submissions were emitted for 50 identities. Race-enabled coverage now checks concurrent duplicate submission, first-observation retention, deferred/direct relations, repeated correlation, distinct identities and subsequent snapshots.
  • The full topology collector package passed (33 top-level tests, 99 including subtests), along with four race-enabled kubeapi topology lifecycle/configuration tests, using Go 1.26.6. Changed-code lint passed with golangci-lint 2.9.0; the new release note passed the repository RST linter.
  • A private static test build 3.78.2-dedup.20261014, based on 13679eda6f with the exact implementation in 5a41036559, ran on two real Kubernetes clusters. Duplicate-item errors cleared; seven node IDs, two cluster IDs and the existing Qdrant mount relation ID were preserved. The latest check shows both Kubernetes synchronizations Running with empty active error details. Historical error counters were not reset.

The unfiltered kubeapi suite could not complete: TestProcessBundledEvents waits for an unavailable Kubernetes API client. Full-package lint reports preexisting issues; only changed-code lint is clean. Separate process/network synchronization errors remain outside this Kubernetes snapshot fix. The deployed binary is a private test override, not an official Agent release.

Target stackstate-7.78.2, the current StackVista default branch and deployed source baseline. Keep draft: this repository skips unit-test jobs for fork PRs and its aggregate gate requires those jobs, so maintainer-side CI is still needed. Discovered while validating SUSE AI StackPacks v2; the fix belongs in the native Agent.

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.

1 participant