Skip to content

Commit

Permalink
Merge pull request #301 from ggriffiths/add_controller_expand_secret_ref
Browse files Browse the repository at this point in the history
Add controller expand secret ref to PV
  • Loading branch information
k8s-ci-robot authored Jun 20, 2019
2 parents b0cfc55 + a1ff9ea commit f4b4ab1
Show file tree
Hide file tree
Showing 70 changed files with 5,289 additions and 2,765 deletions.
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"
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

0 comments on commit f4b4ab1

Please sign in to comment.