Skip to content

Commit 49b6c51

Browse files
committed
KCP: Set MinItems=1 on ExternalEtcd.Endpoints
1 parent 7e6b3d8 commit 49b6c51

File tree

7 files changed

+10
-1
lines changed

7 files changed

+10
-1
lines changed

api/bootstrap/kubeadm/v1beta2/kubeadm_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ type LocalEtcd struct {
459459
type ExternalEtcd struct {
460460
// endpoints of etcd members. Required for ExternalEtcd.
461461
// +required
462+
// +kubebuilder:validation:MinItems=1
462463
// +kubebuilder:validation:MaxItems=50
463464
// +kubebuilder:validation:items:MinLength=1
464465
// +kubebuilder:validation:items:MaxLength=512

bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controlplane/kubeadm/internal/filters.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ func dropOmittableFields(spec *bootstrapv1.KubeadmConfigSpec) {
428428
}
429429
// NOTE: we are not dropping spec.ClusterConfiguration.Etcd.ExternalEtcd.Endpoints because this field
430430
// doesn't have omitempty, so [] array is different from nil when serialized.
431+
// But this field is also required and has MinItems=1, so it will
432+
// never actually be nil or an empty array so that difference also won't trigger any rollouts.
431433
if len(spec.ClusterConfiguration.APIServer.ExtraArgs) == 0 {
432434
spec.ClusterConfiguration.APIServer.ExtraArgs = nil
433435
}

controlplane/kubeadm/internal/filters_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,9 @@ func TestOmittableFieldsClusterConfiguration(t *testing.T) {
18961896
PeerCertSANs: nil,
18971897
},
18981898
External: &bootstrapv1.ExternalEtcd{
1899-
Endpoints: []string{}, // The field doesn't have omit empty.
1899+
// The field doesn't have omit empty. It also is required and has MinItems=1, so it will
1900+
// never actually be nil or an empty array so that difference also won't trigger any rollouts.
1901+
Endpoints: []string{},
19001902
},
19011903
},
19021904
APIServer: bootstrapv1.APIServer{

0 commit comments

Comments
 (0)