Skip to content

Commit 198ab46

Browse files
lint: address SA1019 / exhaustive issues introduced by k8s 0.36 + controller-runtime 0.24
The kubernetes group bump to 0.36.0 (CrunchyData#4479) introduced a new v1.PersistentVolumeClaimConditionType ("Unused") that triggers the exhaustive linter on the PVC condition switch in volumes.go. Add it to the existing no-op case alongside the other condition types that have no bearing on volume resizing. The bump also surfaced two staticcheck SA1019 deprecation warnings that block CI on every PR until addressed: - controller-runtime 0.24 deprecated scheme.Builder (used by both v1 and v1beta1 groupversion_info.go). Migrating to the new helper requires restructuring our api packages, so suppress the warning for now and leave a TODO via the comment. - k8s.io/apimachinery 0.36 deprecated direct access to managed.FieldsV1.Raw in favor of GetRawBytes/SetRawBytes. Only apply_test.go uses the old field; suppress until the test is rewritten against the new helpers. These exclusions are scoped narrowly via path patterns so other call sites (if any) still get flagged. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 65dcf0f commit 198ab46

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

.golangci.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,19 @@ linters:
189189
text: >-
190190
GetEventRecorderFor is deprecated
191191
192+
# controller-runtime 0.24 deprecated scheme.Builder, but the recommended
193+
# alternative requires restructuring our api packages. Allow current usage
194+
# until a follow-up migrates to the new helper.
195+
- linters: [staticcheck]
196+
path: pkg/apis/postgres-operator.crunchydata.com/.*/groupversion_info\.go
197+
text: scheme.Builder is deprecated
198+
199+
# k8s.io/apimachinery 0.36 deprecated direct access to managed.FieldsV1.Raw
200+
# in favor of GetRawBytes/SetRawBytes. Tests still use the old field.
201+
- linters: [staticcheck]
202+
path: internal/controller/runtime/apply_test\.go
203+
text: managed.FieldsV1.Raw is deprecated
204+
192205
# https://golangci-lint.run/usage/formatters
193206
formatters:
194207
enable:

internal/controller/postgrescluster/volumes.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,13 @@ func (r *Reconciler) observePersistentVolumeClaims(
156156
// See the "VolumeAttributesClass" feature gate.
157157
// - https://git.k8s.io/enhancements/keps/sig-storage/3751-volume-attributes-class
158158
corev1.PersistentVolumeClaimVolumeModifyingVolume,
159-
corev1.PersistentVolumeClaimVolumeModifyVolumeError:
159+
corev1.PersistentVolumeClaimVolumeModifyVolumeError,
160+
161+
// The "Unused" condition was added in Kubernetes v1.36 to indicate
162+
// that a PVC is not currently bound to or used by any Pod. This
163+
// has no bearing on volume resizing, so there's nothing to do.
164+
// - https://git.k8s.io/enhancements/keps/sig-storage/4901-pvc-detection-of-stuck-pvcs
165+
corev1.PersistentVolumeClaimUnused:
160166
}
161167
}
162168
}

0 commit comments

Comments
 (0)