Skip to content

further prep for integration tests#145

Merged
awprice merged 1 commit into
masterfrom
aprice/prep-integration-tests-2
May 25, 2026
Merged

further prep for integration tests#145
awprice merged 1 commit into
masterfrom
aprice/prep-integration-tests-2

Conversation

@awprice

@awprice awprice commented May 19, 2026

Copy link
Copy Markdown
Collaborator

Further prep for integration tests

Follow-up to #144. Two production changes and their unit tests.

Changes

pkg/k8s — use merge patch for node annotations and labels

AddAnnotationToNode and AddLabelToNode previously used a JSON Patch
"add" operation. This fails at the apiserver when the node's
metadata.annotations / metadata.labels map is nil — something that
happens in envtest (no kubelet to initialise the map) and occasionally in
real clusters before a kubelet has written its own annotations.

Both functions now use a strategic merge patch via the new MergePatchNode
helper, which the apiserver handles correctly regardless of whether the map
exists. Behaviour in normal clusters is identical.

8 unit tests added in pkg/k8s/node_test.go, including an explicit
nil-annotations case that would have failed before this change.

pkg/manager — extract controller wiring into Run

cmd/manager/main.go used to inline scheme registration and all three
reconciler registrations. The integration test world package had to
duplicate that wiring, meaning any future change to controller setup could
silently diverge between production and tests.

pkg/manager.Run(ctx, mgr, deps) is now the single place that registers
the cyclops scheme, metrics, and all three controllers.
cmd/manager/main.go and the integration test suite both call it.

2 unit tests added in pkg/manager/manager_test.go.

Signed-off-by: Alex Price <aprice@atlassian.com>
@awprice awprice force-pushed the aprice/prep-integration-tests-2 branch from 569c326 to b967ee3 Compare May 20, 2026 00:18

@mwhittington21 mwhittington21 left a comment

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.

LGTM

@awprice awprice merged commit 09cddb2 into master May 25, 2026
6 checks passed
@awprice awprice deleted the aprice/prep-integration-tests-2 branch May 25, 2026 22:34
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