Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions assets/overlays/aws-ebs/base/csidriver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ spec:
seLinuxMount: true
volumeLifecycleModes:
- Persistent
# We set the field even though the field is not available by default.
# The API server will clear the field if the field is not enabled.
# It would be complicated to add the field conditionally in the operator
# by our usual ${xxx} replacement, because yaml fields cannot start with '$'.
# And StaticResourceController does not allow any programmatic hooks.
nodeAllocatableUpdatePeriodSeconds: 600
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ metadata:
spec:
attachRequired: true
fsGroupPolicy: File
nodeAllocatableUpdatePeriodSeconds: 600
podInfoOnMount: false
requiresRepublish: false
seLinuxMount: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ metadata:
spec:
attachRequired: true
fsGroupPolicy: File
nodeAllocatableUpdatePeriodSeconds: 600
podInfoOnMount: false
requiresRepublish: false
seLinuxMount: true
Expand Down
28 changes: 28 additions & 0 deletions pkg/driver/aws-ebs/aws_ebs.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ func GetAWSEBSOperatorControllerConfig(ctx context.Context, flavour generator.Cl
if featureGates.Enabled(configv1.FeatureGateName("VolumeAttributesClass")) {
cfg.AddDeploymentHookBuilders(c, withVolumeAttributesClassHook)
}
if featureGates.Enabled(configv1.FeatureGateName("MutableCSINodeAllocatableCount")) {
cfg.AddDeploymentHookBuilders(c, withMutableCSINodeAllocatableCount)
}

cfg.AddDaemonSetHookBuilders(c, withCABundleDaemonSetHook)
cfg.AddStorageClassHookBuilders(c, withKMSKeyHook)
Expand All @@ -208,6 +211,14 @@ func GetAWSEBSOperatorControllerConfig(ctx context.Context, flavour generator.Cl
cfg.ExtraControlPlaneControllers = append(cfg.ExtraControlPlaneControllers, ctrl)
}

cfg.ExtraReplacementsFunc = func() []string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jsafrane , I did some tests for enable nodeAllocatableUpdatePeriodSeconds in ebs csi driver and found that we still needs openshift/csi-external-attacher#89 which contains(kubernetes-csi/external-attacher@462cd54 we needed for MutableCSINodeAllocatableCount featuregate args in external attacher). In addition it seems the cfg.ExtraReplacementsFunc only do the replace the first time in cluster install when I enable the TechPreviewNoUpgrade it does not update the csidriver, I needs to delete the csidriver trigger the resource reconcile and update it with nodeAllocatableUpdatePeriodSeconds: 600. This should be an issue when upgrade/enable featuregate. Could you help check when you get a chance? Thank you! ^^

# After enable the TechPreviewNoUpgrade the csidriver does not update
$ oc get csidriver ebs.csi.aws.com -oyaml
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
  annotations:
    csi.openshift.io/managed: "true"
    operator.openshift.io/spec-hash: d37d616b853448c2d019d19e3987ebfb751f3da09de52be009406f4d8f8fd7d6
  creationTimestamp: "2025-10-23T06:09:33Z"
  name: ebs.csi.aws.com
  resourceVersion: "86418"
  uid: 8ac66b43-1f14-4be7-9d4b-1e65f29ed14a
spec:
  attachRequired: true
  fsGroupPolicy: File
  podInfoOnMount: false
  requiresRepublish: false
  seLinuxMount: true
  storageCapacity: false
  volumeLifecycleModes:
  - Persistent

# delete the csidriver trigger reconcile
$ oc delete csidriver ebs.csi.aws.com
csidriver.storage.k8s.io "ebs.csi.aws.com" deleted
$ oc get csidriver ebs.csi.aws.com -oyaml
apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
  annotations:
    csi.openshift.io/managed: "true"
    operator.openshift.io/spec-hash: d37d616b853448c2d019d19e3987ebfb751f3da09de52be009406f4d8f8fd7d6
  creationTimestamp: "2025-10-23T07:01:02Z"
  name: ebs.csi.aws.com
  resourceVersion: "116117"
  uid: 84d59f30-7b5f-4059-9cb5-a02089c2093b
spec:
  attachRequired: true
  fsGroupPolicy: File
  nodeAllocatableUpdatePeriodSeconds: 600
  podInfoOnMount: false
  requiresRepublish: false
  seLinuxMount: true
  storageCapacity: false
  volumeLifecycleModes:
  - Persistent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, the external-attacher rebase is necessary too.

it seems the cfg.ExtraReplacementsFunc only do the replace the first time in cluster install when I enable the TechPreviewNoUpgrade it does not update the csidriver

I'll look into this. The operator should restart when something changes FeatureGates...

if featureGates.Enabled(configv1.FeatureGateName("MutableCSINodeAllocatableCount")) {
return nil
}
// CLEAR the field when the feature gate is disabled
return []string{"nodeAllocatableUpdatePeriodSeconds: 600", ""}
}

if flavour == generator.FlavourHyperShift {
volumeTagController := NewEBSVolumeTagsController(cfg.GetControllerName("EBSVolumeTagsController"), c, c.EventRecorder)
cfg.ExtraControlPlaneControllers = append(cfg.ExtraControlPlaneControllers, volumeTagController)
Expand Down Expand Up @@ -500,3 +511,20 @@ func withVolumeAttributesClassHook(c *clients.Clients) (dc.DeploymentHookFunc, [
}
return hook, nil
}

// withMutableCSINodeAllocatableCount enables the MutableCSINodeAllocatableCount feature gate in the external attacher
// TODO: remove when MutableCSINodeAllocatableCount is GA
func withMutableCSINodeAllocatableCount(c *clients.Clients) (dc.DeploymentHookFunc, []factory.Informer) {
hook := func(spec *opv1.OperatorSpec, deployment *appsv1.Deployment) error {
fgArgument := "--feature-gates=MutableCSINodeAllocatableCount=true"
for i := range deployment.Spec.Template.Spec.Containers {
container := &deployment.Spec.Template.Spec.Containers[i]
if container.Name != "csi-attacher" {
continue
}
container.Args = append(container.Args, fgArgument)
}
return nil
}
return hook, nil
}
37 changes: 37 additions & 0 deletions pkg/driver/aws-ebs/aws_ebs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,40 @@ func Test_WithKMSKeyHook(t *testing.T) {
})
}
}

func Test_WithMutableCSINodeAllocatableCount(t *testing.T) {
cr := clients.GetFakeOperatorCR()
c := clients.NewFakeClients("clusters-test", cr)

hook, _ := withMutableCSINodeAllocatableCount(c)
deployment := getTestDeployment()
// Arrange - inject custom infrastructure

// Act
err := hook(&cr.Spec.OperatorSpec, deployment)
if err != nil {
t.Fatalf("unexpected hook error: %v", err)
}

// Assert
found := false
expectedFeatureGatesArg := "--feature-gates=MutableCSINodeAllocatableCount=true"
for _, container := range deployment.Spec.Template.Spec.Containers {
if container.Name == "csi-attacher" {
found = true
// Collect env vars from struct EnvVar to map[string]string
featureGatesArg := ""
for _, arg := range container.Args {
if strings.HasPrefix(arg, "--feature-gates") {
featureGatesArg = arg
}
}
if featureGatesArg != expectedFeatureGatesArg {
t.Errorf("expected csi-driver feature gates argument %s, got %s", expectedFeatureGatesArg, featureGatesArg)
}
}
}
if !found {
t.Errorf("container csi-attacher not found")
}
}