Skip to content

Commit

Permalink
feat: add feature flag for inline volume support
Browse files Browse the repository at this point in the history
  • Loading branch information
andyzhangx committed Jan 13, 2025
1 parent 8105a9d commit 0e4e10c
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 2 deletions.
Binary file modified charts/latest/csi-driver-smb-v0.0.0.tgz
Binary file not shown.
2 changes: 2 additions & 0 deletions charts/latest/csi-driver-smb/templates/csi-smb-driver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ spec:
podInfoOnMount: true
volumeLifecycleModes:
- Persistent
{{- if .Values.feature.enableInlineVolume }}
- Ephemeral
{{- end }}
3 changes: 2 additions & 1 deletion charts/latest/csi-driver-smb/templates/rbac-csi-smb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ roleRef:
name: {{ .Values.rbac.name }}-external-resizer-role
apiGroup: rbac.authorization.k8s.io
---
{{- if .Values.feature.enableInlineVolume }}
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand All @@ -107,7 +108,6 @@ rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get"]

---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
Expand All @@ -122,4 +122,5 @@ roleRef:
kind: ClusterRole
name: csi-{{ .Values.rbac.name }}-node-secret-role
apiGroup: rbac.authorization.k8s.io
{{- end }}
{{ end }}
1 change: 1 addition & 0 deletions charts/latest/csi-driver-smb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ driver:

feature:
enableGetVolumeStats: true
enableInlineVolume: true

controller:
name: csi-smb-controller
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/dynamic_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,12 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {
})

ginkgo.It("should create an CSI inline volume", func(ctx ginkgo.SpecContext) {
secretName := "smbcreds"
ginkgo.By(fmt.Sprintf("creating secret %s in namespace %s", secretName, ns.Name))
tsecret := testsuites.CopyTestSecret(ctx, cs, "default", ns, defaultSmbSecretName)
tsecret.Create(ctx)
defer tsecret.Cleanup(ctx)

pods := []testsuites.PodDetails{
{
Cmd: convertToPowershellCommandIfNecessary("echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data"),
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const (
defaultSmbSource = "//smb-server.default.svc.cluster.local/share"
defaultSmbSecretName = "smbcreds"
defaultSmbSecretNamespace = "default"
accountNameForTest = "YW5keXNzZGZpbGUK"
)

var (
Expand Down Expand Up @@ -173,7 +174,7 @@ var _ = ginkgo.BeforeSuite(func() {
}

if isWindowsHostProcessDeployment {
decodedBytes, err := base64.StdEncoding.DecodeString("YW5keXNzZGZpbGUK")
decodedBytes, err := base64.StdEncoding.DecodeString(accountNameForTest)
if err != nil {
log.Printf("Error decoding base64 string: %v\n", err)
return
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/testsuites/testsuites.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,17 @@ func NewTestSecret(c clientset.Interface, ns *v1.Namespace, name string, data ma
}
}

func CopyTestSecret(ctx context.Context, c clientset.Interface, sourceNamespace string, targetNamespace *v1.Namespace, secretName string) *TestSecret {
secret, err := c.CoreV1().Secrets(sourceNamespace).Get(ctx, secretName, metav1.GetOptions{})
framework.ExpectNoError(err)

return &TestSecret{
client: c,
namespace: targetNamespace,
secret: secret,
}
}

func (t *TestSecret) Create(ctx context.Context) {
var err error
t.secret, err = t.client.CoreV1().Secrets(t.namespace.Name).Create(ctx, t.secret, metav1.CreateOptions{})
Expand Down

0 comments on commit 0e4e10c

Please sign in to comment.