Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add controller expand secret ref to PV #301

Merged
Merged
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: 3 additions & 3 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
# because of the lack of semantic versioning in Kubernetes. Therefore we
# have to pick a certain release, otherwise we (more or less randomly) end
# up with something older or master.
[[override]]
name = "k8s.io/api"
Copy link
Collaborator

Choose a reason for hiding this comment

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

i'm surprised client-go didn't need to be updated?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I found this override block makes it possible. It's more of a temporary fix until all other dependencies update to k8s.io/api 1.15.
https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md#override

branch = "release-1.15"

[[constraint]]
name = "k8s.io/apiserver"
version = "kubernetes-1.14.1"
Expand Down
19 changes: 15 additions & 4 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ const (
prefixedNodePublishSecretNameKey = csiParameterPrefix + "node-publish-secret-name"
prefixedNodePublishSecretNamespaceKey = csiParameterPrefix + "node-publish-secret-namespace"

prefixedResizerSecretNameKey = csiParameterPrefix + "resizer-secret-name"
prefixedResizerSecretNamespaceKey = csiParameterPrefix + "resizer-secret-namespace"
prefixedControllerExpandSecretNameKey = csiParameterPrefix + "controller-expand-secret-name"
prefixedControllerExpandSecretNamespaceKey = csiParameterPrefix + "controller-expand-secret-namespace"

// [Deprecated] CSI Parameters that are put into fields but
// NOT stripped from the parameters passed to CreateVolume
Expand Down Expand Up @@ -145,6 +145,12 @@ var (
secretNameKey: prefixedNodeStageSecretNameKey,
secretNamespaceKey: prefixedNodeStageSecretNamespaceKey,
}

controllerExpandSecretParams = secretParamsMap{
name: "ControllerExpand",
secretNameKey: prefixedControllerExpandSecretNameKey,
secretNamespaceKey: prefixedControllerExpandSecretNamespaceKey,
}
)

// requiredCapabilities provides a set of extra capabilities required for special/optional features provided by a plugin
Expand Down Expand Up @@ -495,6 +501,10 @@ func (p *csiProvisioner) Provision(options controller.ProvisionOptions) (*v1.Per
if err != nil {
return nil, err
}
controllerExpandSecretRef, err := getSecretReference(controllerExpandSecretParams, options.StorageClass.Parameters, pvName, options.PVC)
if err != nil {
return nil, err
}

req.Parameters, err = removePrefixedParameters(options.StorageClass.Parameters)
if err != nil {
Expand Down Expand Up @@ -551,6 +561,7 @@ func (p *csiProvisioner) Provision(options controller.ProvisionOptions) (*v1.Per
ControllerPublishSecretRef: controllerPublishSecretRef,
NodeStageSecretRef: nodeStageSecretRef,
NodePublishSecretRef: nodePublishSecretRef,
ControllerExpandSecretRef: controllerExpandSecretRef,
},
},
},
Expand Down Expand Up @@ -607,8 +618,8 @@ func removePrefixedParameters(param map[string]string) (map[string]string, error
case prefixedNodeStageSecretNamespaceKey:
case prefixedNodePublishSecretNameKey:
case prefixedNodePublishSecretNamespaceKey:
case prefixedResizerSecretNameKey:
case prefixedResizerSecretNamespaceKey:
case prefixedControllerExpandSecretNameKey:
case prefixedControllerExpandSecretNamespaceKey:
default:
return map[string]string{}, fmt.Errorf("found unknown parameter key \"%s\" with reserved namespace %s", k, csiParameterPrefix)
}
Expand Down
15 changes: 13 additions & 2 deletions pkg/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ func TestStripPrefixedCSIParams(t *testing.T) {
prefixedNodeStageSecretNamespaceKey: "csiBar",
prefixedNodePublishSecretNameKey: "csiBar",
prefixedNodePublishSecretNamespaceKey: "csiBar",
prefixedResizerSecretNameKey: "csiBar",
prefixedResizerSecretNamespaceKey: "csiBar",
prefixedControllerExpandSecretNameKey: "csiBar",
prefixedControllerExpandSecretNamespaceKey: "csiBar",
},
expectedParams: map[string]string{},
},
Expand Down Expand Up @@ -1097,6 +1097,10 @@ func TestProvision(t *testing.T) {
Name: "nodepublishsecret",
Namespace: "default",
},
ControllerExpandSecretRef: &v1.SecretReference{
Name: "controllerexpandsecret",
Namespace: "default",
},
},
},
},
Expand Down Expand Up @@ -1324,6 +1328,11 @@ func runProvisionTest(t *testing.T, k string, tc provisioningTestcase, requested
Name: "nodepublishsecret",
Namespace: "default",
},
}, &v1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "controllerexpandsecret",
Namespace: "default",
},
})
} else {
clientSet = fakeclientset.NewSimpleClientset()
Expand All @@ -1346,6 +1355,8 @@ func runProvisionTest(t *testing.T, k string, tc provisioningTestcase, requested
tc.volOpts.StorageClass.Parameters[nodeStageSecretNamespaceKey] = "default"
tc.volOpts.StorageClass.Parameters[nodePublishSecretNameKey] = "nodepublishsecret"
tc.volOpts.StorageClass.Parameters[nodePublishSecretNamespaceKey] = "default"
tc.volOpts.StorageClass.Parameters[prefixedControllerExpandSecretNameKey] = "controllerexpandsecret"
tc.volOpts.StorageClass.Parameters[prefixedControllerExpandSecretNamespaceKey] = "default"
}

if tc.notNilSelector {
Expand Down
Loading