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 new reserved prefixed parameter keys which are stripped out of parameter list, add deprecation notice for old keys and keep their behavior the same #178

Merged
merged 1 commit into from
Dec 4, 2018

Conversation

davidz627
Copy link
Contributor

@davidz627 davidz627 commented Nov 29, 2018

Add new reserved prefixed parameter keys which are stripped out of parameter list:

csiParameterPrefix = "csi.storage.k8s.io/"
prefixedFsTypeKey = csiParameterPrefix + "FSType"
prefixedProvisionerSecretNameKey      = csiParameterPrefix + "ProvisionerSecretName"
prefixedProvisionerSecretNamespaceKey = csiParameterPrefix + "ProvisionerSecretNamespace"
prefixedControllerPublishSecretNameKey      = csiParameterPrefix + "ControllerPublishSecretName"
prefixedControllerPublishSecretNamespaceKey = csiParameterPrefix + "ControllerPublishSecretNamespace"
prefixedNodeStageSecretNameKey      = csiParameterPrefix + "NodeStageSecretName"
prefixedNodeStageSecretNamespaceKey = csiParameterPrefix + "NodeStageSecretNamespace"
prefixedNodePublishSecretNameKey      = csiParameterPrefix + "NodePublishSecretName"
prefixedNodePublishSecretNamespaceKey = csiParameterPrefix + "NodePublishSecretNamespace"

add deprecation notice for old keys, example:
"fstype" is deprecated and will be removed in a future release, please use "csi.storage.k8s.io/FSType" instead

the behavior will be the same for the old parameter keys, except for the fact that they cannot be specified in conjunction with their respective new prefixed parameter key

/assign @saad-ali @lpabon @jsafrane @msau42 @mkimuram @vladimirvivien

@k8s-ci-robot
Copy link
Contributor

@davidz627: GitHub didn't allow me to assign the following users: mkimuram.

Note that only kubernetes-csi members and repo collaborators can be assigned.
For more information please see the contributor guide

In response to this:

all parameters that start with "csi" are interpreted by the external-provisioner as special parameters and they are placed into objects as first class CSI fields. Therefore after they have been "translated" into field they are stripped from the parameters list that gets passed to CreateVolume.

In this vein we add csifstype so that you can specify fstype that the external provisioner will understand and place in to the volume capability, it will then get stripped out of the parameters list.

/assign @saad-ali @lpabon @jsafrane @msau42 @mkimuram @vladimirvivien

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 29, 2018
@davidz627 davidz627 changed the title Add csifstype paramater, strip all parameters that start with CSI [BREAKING CHANGE] Add csifstype parameter, strip all parameters that start with CSI Nov 29, 2018
func runProvisionTest(t *testing.T, k string, tc provisioningTestcase, requestedBytes int64) {
t.Logf("Running test: %v", k)

mockController, driver, identityServer, controllerServer, csiConn, err := createMockServer(t)
Copy link
Contributor Author

@davidz627 davidz627 Nov 29, 2018

Choose a reason for hiding this comment

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

this refactor was so that we have a new server for each test, so that mock expectations did not carry through from test to test causing hard to debug cascading failures

} else {
// Setup regular mock call expectations.
provisionMockServerSetupExpectations(identityServer, controllerServer)
if !tc.expectErr {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also added that we should not expect create volume when test is supposed to error

@saad-ali
Copy link
Member

I support this change. This reserves StorageClass parameters with keys starting with csi... for use by the CSI external-provisioner and prevents them from being passed through to the CSI driver in the CreateVolume call.

@mkimuram
Copy link
Contributor

@davidz627

Is my understanding right that the issue is caused by that csi external provisioner passes all the storage class parameters to csi driver's CreateVolume, as a result, parameters that are not specific to csi driver, such as fsType and secrets for csi, is passed to csi driver?

As spec describes as below, I agree that csi plugins should check if invalid parameters are not passed like this, and then above behavior will make csi driver regard such parameters as invalid.

  // Plugin specific parameters passed in as opaque key-value pairs.
  // This field is OPTIONAL. The Plugin is responsible for parsing and
  // validating these parameters. COs will treat these as opaque.

To solve this issue, we also have an option to strip fsType in addition to parameters that is prefixed with csi, instead of introducing new csiFsType. Pros and Cons will be as below, so if we don't need to prioritize compatibility, implementation of this PR will be better.

Pros:

  • Compatible with csi v0 driver on how to specify fstype in storage class parameters
  • Compatible with in-tree driver or non csi external provisioner on how to specify fstype in storage class parameters

Cons:

  • Introduce an irregular case for handling csi's storage class parameters (Assuming that this PR intends to make a rule that storage class parameters prefixed with "csi" are not for each csi driver in k8s.)

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 30, 2018
@davidz627 davidz627 changed the title [BREAKING CHANGE] Add csifstype parameter, strip all parameters that start with CSI Add new reserved prefixed parameter keys which are stripped out of parameter list, add deprecation notice for old keys and keep their behavior the same Nov 30, 2018
@davidz627
Copy link
Contributor Author

@saad-ali @lpabon @jsafrane @msau42 @mkimuram @vladimirvivien
new version based on morning CSI standup discussion pushed

@verult
Copy link
Contributor

verult commented Dec 1, 2018

/assign

pkg/controller/controller.go Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
@davidz627
Copy link
Contributor Author

@saad-ali resolved. The error messages I made more generic because we can't tell if the user used the deprecated or new parameters, unless we want to add more cases :S

@@ -82,6 +110,40 @@ const (
snapshotAPIGroup = snapapi.GroupName // "snapshot.storage.k8s.io"
)

var (
Copy link
Contributor

Choose a reason for hiding this comment

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

What about a function

generateCSIParams(actor, key string, deprecated bool)

and

noActor = ""
provisionerActor = "Provisioner"
controllerPublishActor = "ControllerPublish"
...
secretNameKey = "SecretName"
fsTypeKey = "FSType"
...
actors = []string{provisionerActor, controllerPublishActor, ...}
keys = []string{secretNameKey, fsTypeKey, ...}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how would we associate actors with keys? This ends up just shifting the variable definition into a different type of struct I think. It's unclear what params we're trying to generate here, whats the output of this function?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry the func should be called generateCSIParamKeys and returns an actual storageclass parameter key. The logic would be the same as what you have right now, but encapsulated in a function, so it's easier to read and you don't need a giant list of variables.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm trying to see if there's a way to not have a hard-coded list of all the various combinations.

namespaceTemplate = t
numNamespace += 1
}

Copy link
Contributor

Choose a reason for hiding this comment

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

What if you had a helper function

getKeyFromParams(actor, key string) (val string, isDeprecated bool, err error)

that

  • Returns the val corresponding to either the deprecated or the existing key if only 1 of them exists (and set isDeprecated accordingly)
  • Returns an error if both deprecated and existing keys exist

Then the check below becomes something like:

if secretNameIsDeprecated != secretNamespaceIsDeprecated {
   throwError()
} else if secretNameIsDeprecated {
   ...
} else { // !secretNameIsDeprecated && !secretNamespaceIsDeprecated
   ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when passing in a key we already know whether its deprecated or not as we define that so it doesnt make sense to me to have that as a return. Also given one deprecated theres no way to associate that with the "non-deprecated" version of that key without a struct that binds both together (or some hardcoding in this function) which serves the same purpose.

Copy link
Contributor

Choose a reason for hiding this comment

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

Tried to prototype this piece of logic and yeah, it doesn't look much prettier. OK to keep everything as is!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

could you LGTM?

@@ -702,8 +805,52 @@ func (p *csiProvisioner) volumeHandleToId(handle string) string {
return handle
}

// getSecretReference returns a reference to the secret specified in the given nameKey and namespaceKey parameters, or an error if the parameters are not specified correctly.
// if neither the name or namespace parameter are set, a nil reference and no error is returned.
func getSecretNameAndNamespaceTemplate(secret secretParamsType, storageClassParams map[string]string) (nameTemplate, namespaceTemplate string, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Going off the suggestions from above, this would take in actor string instead of secret secretParamsType

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this just shifts association of deprecatedness/actors from the structs that I created into hardcoded cases in the functions

Copy link
Member

@saad-ali saad-ali left a comment

Choose a reason for hiding this comment

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

/approve

LGTM

Will let @verult or @msau42 do final lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: davidz627, saad-ali

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 1, 2018
Copy link
Contributor

@verult verult left a comment

Choose a reason for hiding this comment

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

Couple nits but LGTM otherwise!

secretNameKey string
secretNamespaceKey string
}

const (
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Move new consts to a separate file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

refactor in future

pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/controller/controller_test.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Show resolved Hide resolved
…rameter list, add deprecation notice for old keys and keep their behavior the same
@jingxu97
Copy link
Contributor

jingxu97 commented Dec 4, 2018

/lgtm

@k8s-ci-robot
Copy link
Contributor

@jingxu97: changing LGTM is restricted to assignees, and only kubernetes-csi/external-provisioner repo collaborators may be assigned issues.

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@verult
Copy link
Contributor

verult commented Dec 4, 2018

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants