Implement KEP 4876 Mutable CSINode (#130007)

* Implement KEP-4876 Mutable CSINode Allocatable Count

Signed-off-by: torredil <torredil@amazon.com>

* Update TestGetNodeAllocatableUpdatePeriod

Signed-off-by: torredil <torredil@amazon.com>

* Implement CSINodeUpdater

Signed-off-by: torredil <torredil@amazon.com>

* Use sync.Once in csiNodeUpdater

Signed-off-by: torredil <torredil@amazon.com>

* ImVerify driver is installed before running periodic updates

Signed-off-by: torredil <torredil@amazon.com>

* Update NodeAllocatableUpdatePeriodSeconds type comment

Signed-off-by: torredil <torredil@amazon.com>

* Leverage apivalidation.ValidateImmutableField in ValidateCSINodeUpdate

Signed-off-by: torredil <torredil@amazon.com>

* Update strategy functions

Signed-off-by: torredil <torredil@amazon.com>

* Run hack/update-openapi-spec.sh

Signed-off-by: torredil <torredil@amazon.com>

* Update VolumeError.ErrorCode field

Signed-off-by: torredil <torredil@amazon.com>

* CSINodeUpdater improvements

Signed-off-by: torredil <torredil@amazon.com>

* Iron out concurrency in syncDriverUpdater

Signed-off-by: torredil <torredil@amazon.com>

* Run hack/update-openapi-spec.sh

Signed-off-by: torredil <torredil@amazon.com>

* Revise logging

Signed-off-by: torredil <torredil@amazon.com>

* Revise log in VerifyExhaustedResource

Signed-off-by: torredil <torredil@amazon.com>

* Update API validation

Signed-off-by: torredil <torredil@amazon.com>

* Add more code coverage

Signed-off-by: torredil <torredil@amazon.com>

* Fix pull-kubernetes-linter-hints

Signed-off-by: torredil <torredil@amazon.com>

* Update API types documentation

Signed-off-by: torredil <torredil@amazon.com>

* Update strategy and validation for new errorCode field

Signed-off-by: torredil <torredil@amazon.com>

* Update validation tests after strategy changes

Signed-off-by: torredil <torredil@amazon.com>

* Update VA status strategy

Signed-off-by: torredil <torredil@amazon.com>

---------

Signed-off-by: torredil <torredil@amazon.com>

Kubernetes-commit: c766a52356a277da5e9f29f77aab5212f1b083c6
This commit is contained in:
Eddie Torres 2025-03-18 15:45:49 -04:00 committed by Kubernetes Publisher
parent c5b5caed20
commit 7ed5fa7538
8 changed files with 85 additions and 25 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

2
go.mod
View File

@ -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

4
go.sum
View File

@ -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=