From 7ed5fa753852032333d554d207e34e5610798e38 Mon Sep 17 00:00:00 2001 From: Eddie Torres Date: Tue, 18 Mar 2025 15:45:49 -0400 Subject: [PATCH] Implement KEP 4876 Mutable CSINode (#130007) * Implement KEP-4876 Mutable CSINode Allocatable Count Signed-off-by: torredil * Update TestGetNodeAllocatableUpdatePeriod Signed-off-by: torredil * Implement CSINodeUpdater Signed-off-by: torredil * Use sync.Once in csiNodeUpdater Signed-off-by: torredil * ImVerify driver is installed before running periodic updates Signed-off-by: torredil * Update NodeAllocatableUpdatePeriodSeconds type comment Signed-off-by: torredil * Leverage apivalidation.ValidateImmutableField in ValidateCSINodeUpdate Signed-off-by: torredil * Update strategy functions Signed-off-by: torredil * Run hack/update-openapi-spec.sh Signed-off-by: torredil * Update VolumeError.ErrorCode field Signed-off-by: torredil * CSINodeUpdater improvements Signed-off-by: torredil * Iron out concurrency in syncDriverUpdater Signed-off-by: torredil * Run hack/update-openapi-spec.sh Signed-off-by: torredil * Revise logging Signed-off-by: torredil * Revise log in VerifyExhaustedResource Signed-off-by: torredil * Update API validation Signed-off-by: torredil * Add more code coverage Signed-off-by: torredil * Fix pull-kubernetes-linter-hints Signed-off-by: torredil * Update API types documentation Signed-off-by: torredil * Update strategy and validation for new errorCode field Signed-off-by: torredil * Update validation tests after strategy changes Signed-off-by: torredil * Update VA status strategy Signed-off-by: torredil --------- Signed-off-by: torredil Kubernetes-commit: c766a52356a277da5e9f29f77aab5212f1b083c6 --- applyconfigurations/internal/internal.go | 15 +++++++++++ .../storage/v1/csidriverspec.go | 25 +++++++++++++------ applyconfigurations/storage/v1/volumeerror.go | 13 ++++++++-- .../storage/v1alpha1/volumeerror.go | 13 ++++++++-- .../storage/v1beta1/csidriverspec.go | 25 +++++++++++++------ .../storage/v1beta1/volumeerror.go | 13 ++++++++-- go.mod | 2 +- go.sum | 4 +-- 8 files changed, 85 insertions(+), 25 deletions(-) diff --git a/applyconfigurations/internal/internal.go b/applyconfigurations/internal/internal.go index 58011b8a..37489a76 100644 --- a/applyconfigurations/internal/internal.go +++ b/applyconfigurations/internal/internal.go @@ -13572,6 +13572,9 @@ var schemaYAML = typed.YAMLObject(`types: - name: fsGroupPolicy type: scalar: string + - name: nodeAllocatableUpdatePeriodSeconds + type: + scalar: numeric - name: podInfoOnMount type: scalar: boolean @@ -13789,6 +13792,9 @@ var schemaYAML = typed.YAMLObject(`types: - name: io.k8s.api.storage.v1.VolumeError map: fields: + - name: errorCode + type: + scalar: numeric - name: message type: scalar: string @@ -13915,6 +13921,9 @@ var schemaYAML = typed.YAMLObject(`types: - name: io.k8s.api.storage.v1alpha1.VolumeError map: fields: + - name: errorCode + type: + scalar: numeric - name: message type: scalar: string @@ -13947,6 +13956,9 @@ var schemaYAML = typed.YAMLObject(`types: - name: fsGroupPolicy type: scalar: string + - name: nodeAllocatableUpdatePeriodSeconds + type: + scalar: numeric - name: podInfoOnMount type: scalar: boolean @@ -14186,6 +14198,9 @@ var schemaYAML = typed.YAMLObject(`types: - name: io.k8s.api.storage.v1beta1.VolumeError map: fields: + - name: errorCode + type: + scalar: numeric - name: message type: scalar: string diff --git a/applyconfigurations/storage/v1/csidriverspec.go b/applyconfigurations/storage/v1/csidriverspec.go index 1b58c6db..fc6f2fbf 100644 --- a/applyconfigurations/storage/v1/csidriverspec.go +++ b/applyconfigurations/storage/v1/csidriverspec.go @@ -25,14 +25,15 @@ import ( // CSIDriverSpecApplyConfiguration represents a declarative configuration of the CSIDriverSpec type for use // with apply. type CSIDriverSpecApplyConfiguration struct { - AttachRequired *bool `json:"attachRequired,omitempty"` - PodInfoOnMount *bool `json:"podInfoOnMount,omitempty"` - VolumeLifecycleModes []storagev1.VolumeLifecycleMode `json:"volumeLifecycleModes,omitempty"` - StorageCapacity *bool `json:"storageCapacity,omitempty"` - FSGroupPolicy *storagev1.FSGroupPolicy `json:"fsGroupPolicy,omitempty"` - TokenRequests []TokenRequestApplyConfiguration `json:"tokenRequests,omitempty"` - RequiresRepublish *bool `json:"requiresRepublish,omitempty"` - SELinuxMount *bool `json:"seLinuxMount,omitempty"` + AttachRequired *bool `json:"attachRequired,omitempty"` + PodInfoOnMount *bool `json:"podInfoOnMount,omitempty"` + VolumeLifecycleModes []storagev1.VolumeLifecycleMode `json:"volumeLifecycleModes,omitempty"` + StorageCapacity *bool `json:"storageCapacity,omitempty"` + FSGroupPolicy *storagev1.FSGroupPolicy `json:"fsGroupPolicy,omitempty"` + TokenRequests []TokenRequestApplyConfiguration `json:"tokenRequests,omitempty"` + RequiresRepublish *bool `json:"requiresRepublish,omitempty"` + SELinuxMount *bool `json:"seLinuxMount,omitempty"` + NodeAllocatableUpdatePeriodSeconds *int64 `json:"nodeAllocatableUpdatePeriodSeconds,omitempty"` } // CSIDriverSpecApplyConfiguration constructs a declarative configuration of the CSIDriverSpec type for use with @@ -111,3 +112,11 @@ func (b *CSIDriverSpecApplyConfiguration) WithSELinuxMount(value bool) *CSIDrive b.SELinuxMount = &value return b } + +// WithNodeAllocatableUpdatePeriodSeconds sets the NodeAllocatableUpdatePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NodeAllocatableUpdatePeriodSeconds field is set to the value of the last call. +func (b *CSIDriverSpecApplyConfiguration) WithNodeAllocatableUpdatePeriodSeconds(value int64) *CSIDriverSpecApplyConfiguration { + b.NodeAllocatableUpdatePeriodSeconds = &value + return b +} diff --git a/applyconfigurations/storage/v1/volumeerror.go b/applyconfigurations/storage/v1/volumeerror.go index c16c5c3a..9becf772 100644 --- a/applyconfigurations/storage/v1/volumeerror.go +++ b/applyconfigurations/storage/v1/volumeerror.go @@ -25,8 +25,9 @@ import ( // VolumeErrorApplyConfiguration represents a declarative configuration of the VolumeError type for use // with apply. type VolumeErrorApplyConfiguration struct { - Time *metav1.Time `json:"time,omitempty"` - Message *string `json:"message,omitempty"` + Time *metav1.Time `json:"time,omitempty"` + Message *string `json:"message,omitempty"` + ErrorCode *int32 `json:"errorCode,omitempty"` } // VolumeErrorApplyConfiguration constructs a declarative configuration of the VolumeError type for use with @@ -50,3 +51,11 @@ func (b *VolumeErrorApplyConfiguration) WithMessage(value string) *VolumeErrorAp b.Message = &value return b } + +// WithErrorCode sets the ErrorCode field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ErrorCode field is set to the value of the last call. +func (b *VolumeErrorApplyConfiguration) WithErrorCode(value int32) *VolumeErrorApplyConfiguration { + b.ErrorCode = &value + return b +} diff --git a/applyconfigurations/storage/v1alpha1/volumeerror.go b/applyconfigurations/storage/v1alpha1/volumeerror.go index ef8f6bbe..19e52751 100644 --- a/applyconfigurations/storage/v1alpha1/volumeerror.go +++ b/applyconfigurations/storage/v1alpha1/volumeerror.go @@ -25,8 +25,9 @@ import ( // VolumeErrorApplyConfiguration represents a declarative configuration of the VolumeError type for use // with apply. type VolumeErrorApplyConfiguration struct { - Time *v1.Time `json:"time,omitempty"` - Message *string `json:"message,omitempty"` + Time *v1.Time `json:"time,omitempty"` + Message *string `json:"message,omitempty"` + ErrorCode *int32 `json:"errorCode,omitempty"` } // VolumeErrorApplyConfiguration constructs a declarative configuration of the VolumeError type for use with @@ -50,3 +51,11 @@ func (b *VolumeErrorApplyConfiguration) WithMessage(value string) *VolumeErrorAp b.Message = &value return b } + +// WithErrorCode sets the ErrorCode field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ErrorCode field is set to the value of the last call. +func (b *VolumeErrorApplyConfiguration) WithErrorCode(value int32) *VolumeErrorApplyConfiguration { + b.ErrorCode = &value + return b +} diff --git a/applyconfigurations/storage/v1beta1/csidriverspec.go b/applyconfigurations/storage/v1beta1/csidriverspec.go index e62fe588..b1c9ec6d 100644 --- a/applyconfigurations/storage/v1beta1/csidriverspec.go +++ b/applyconfigurations/storage/v1beta1/csidriverspec.go @@ -25,14 +25,15 @@ import ( // CSIDriverSpecApplyConfiguration represents a declarative configuration of the CSIDriverSpec type for use // with apply. type CSIDriverSpecApplyConfiguration struct { - AttachRequired *bool `json:"attachRequired,omitempty"` - PodInfoOnMount *bool `json:"podInfoOnMount,omitempty"` - VolumeLifecycleModes []storagev1beta1.VolumeLifecycleMode `json:"volumeLifecycleModes,omitempty"` - StorageCapacity *bool `json:"storageCapacity,omitempty"` - FSGroupPolicy *storagev1beta1.FSGroupPolicy `json:"fsGroupPolicy,omitempty"` - TokenRequests []TokenRequestApplyConfiguration `json:"tokenRequests,omitempty"` - RequiresRepublish *bool `json:"requiresRepublish,omitempty"` - SELinuxMount *bool `json:"seLinuxMount,omitempty"` + AttachRequired *bool `json:"attachRequired,omitempty"` + PodInfoOnMount *bool `json:"podInfoOnMount,omitempty"` + VolumeLifecycleModes []storagev1beta1.VolumeLifecycleMode `json:"volumeLifecycleModes,omitempty"` + StorageCapacity *bool `json:"storageCapacity,omitempty"` + FSGroupPolicy *storagev1beta1.FSGroupPolicy `json:"fsGroupPolicy,omitempty"` + TokenRequests []TokenRequestApplyConfiguration `json:"tokenRequests,omitempty"` + RequiresRepublish *bool `json:"requiresRepublish,omitempty"` + SELinuxMount *bool `json:"seLinuxMount,omitempty"` + NodeAllocatableUpdatePeriodSeconds *int64 `json:"nodeAllocatableUpdatePeriodSeconds,omitempty"` } // CSIDriverSpecApplyConfiguration constructs a declarative configuration of the CSIDriverSpec type for use with @@ -111,3 +112,11 @@ func (b *CSIDriverSpecApplyConfiguration) WithSELinuxMount(value bool) *CSIDrive b.SELinuxMount = &value return b } + +// WithNodeAllocatableUpdatePeriodSeconds sets the NodeAllocatableUpdatePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the NodeAllocatableUpdatePeriodSeconds field is set to the value of the last call. +func (b *CSIDriverSpecApplyConfiguration) WithNodeAllocatableUpdatePeriodSeconds(value int64) *CSIDriverSpecApplyConfiguration { + b.NodeAllocatableUpdatePeriodSeconds = &value + return b +} diff --git a/applyconfigurations/storage/v1beta1/volumeerror.go b/applyconfigurations/storage/v1beta1/volumeerror.go index fec1c9ad..015bcd86 100644 --- a/applyconfigurations/storage/v1beta1/volumeerror.go +++ b/applyconfigurations/storage/v1beta1/volumeerror.go @@ -25,8 +25,9 @@ import ( // VolumeErrorApplyConfiguration represents a declarative configuration of the VolumeError type for use // with apply. type VolumeErrorApplyConfiguration struct { - Time *v1.Time `json:"time,omitempty"` - Message *string `json:"message,omitempty"` + Time *v1.Time `json:"time,omitempty"` + Message *string `json:"message,omitempty"` + ErrorCode *int32 `json:"errorCode,omitempty"` } // VolumeErrorApplyConfiguration constructs a declarative configuration of the VolumeError type for use with @@ -50,3 +51,11 @@ func (b *VolumeErrorApplyConfiguration) WithMessage(value string) *VolumeErrorAp b.Message = &value return b } + +// WithErrorCode sets the ErrorCode field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ErrorCode field is set to the value of the last call. +func (b *VolumeErrorApplyConfiguration) WithErrorCode(value int32) *VolumeErrorApplyConfiguration { + b.ErrorCode = &value + return b +} diff --git a/go.mod b/go.mod index e05d1d81..99ef0199 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/time v0.9.0 google.golang.org/protobuf v1.36.5 gopkg.in/evanphx/json-patch.v4 v4.12.0 - k8s.io/api v0.0.0-20250318053045-472f333f329e + k8s.io/api v0.0.0-20250318194549-540078bf7d9c k8s.io/apimachinery v0.0.0-20250316224947-6ce776c88d38 k8s.io/klog/v2 v2.130.1 k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9 diff --git a/go.sum b/go.sum index d98d8652..153a4cf8 100644 --- a/go.sum +++ b/go.sum @@ -146,8 +146,8 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.0.0-20250318053045-472f333f329e h1:vBbFtW46XgHqhJnDZMKvXK7gT83X28FtmZQDyFWV43Y= -k8s.io/api v0.0.0-20250318053045-472f333f329e/go.mod h1:QVPe5QA1dSSd0GA9ar7uur23kVBq1V/YzRaqwLDm6e4= +k8s.io/api v0.0.0-20250318194549-540078bf7d9c h1:kcdfeVJHOXhQTgdBciYG191FsUgWmEao4n+rrd8JcpU= +k8s.io/api v0.0.0-20250318194549-540078bf7d9c/go.mod h1:QVPe5QA1dSSd0GA9ar7uur23kVBq1V/YzRaqwLDm6e4= k8s.io/apimachinery v0.0.0-20250316224947-6ce776c88d38 h1:FRtTvD6cz3EPDpIonDNShy6I5sB7LebdSb8/oEj5bkg= k8s.io/apimachinery v0.0.0-20250316224947-6ce776c88d38/go.mod h1:S2OIkExGqJOXYSYcAJwQ9zWcc6BkBUdTJUu4M7z0cvo= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=