Skip to content

refactor: deduplicate PDB replica handling and test helpers#3506

Merged
sebrandon1 merged 1 commit intoredhat-best-practices-for-k8s:mainfrom
sebrandon1:simplify/deduplicate-pdb-and-test-helpers
Mar 6, 2026
Merged

refactor: deduplicate PDB replica handling and test helpers#3506
sebrandon1 merged 1 commit intoredhat-best-practices-for-k8s:mainfrom
sebrandon1:simplify/deduplicate-pdb-and-test-helpers

Conversation

@sebrandon1
Copy link
Member

Summary

  • Extract replicaCountOrDefault helper in tests/observability/pdb/pdb.go to eliminate duplicate nil-check logic between CheckPDBIsValid and CheckPDBIsZoneAware
  • Collapse nested if into single conditional in isZoneAwareForDraining for cleaner idiomatic Go
  • Hoist duplicated generateStatefulSet closure to a shared package-level function in tests/lifecycle/scaling/statefulset_scaling_test.go

Test plan

  • go test ./tests/observability/pdb/ — all 18 PDB test cases pass
  • go test ./tests/lifecycle/scaling/ — all scaling test cases pass
  • go build ./tests/observability/pdb/ ./tests/lifecycle/scaling/ — compiles cleanly

…ec G120

Extract replicaCountOrDefault helper to eliminate duplicate nil-check
logic in CheckPDBIsValid and CheckPDBIsZoneAware. Collapse nested if
in isZoneAwareForDraining. Hoist duplicated generateStatefulSet closure
to a shared package-level function in statefulset_scaling_test.go.

Add http.MaxBytesReader to webserver runHandler to prevent potential
memory exhaustion from unbounded form data parsing (gosec G120).
@sebrandon1 sebrandon1 force-pushed the simplify/deduplicate-pdb-and-test-helpers branch from 3d9a7ba to 82ec785 Compare March 6, 2026 16:33
@dcibot
Copy link
Collaborator

dcibot commented Mar 6, 2026

@sebrandon1 sebrandon1 merged commit 3f8217c into redhat-best-practices-for-k8s:main Mar 6, 2026
45 checks passed
@dcibot
Copy link
Collaborator

dcibot commented Mar 6, 2026

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.

2 participants