-
Notifications
You must be signed in to change notification settings - Fork 332
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
Conversation
@davidz627: GitHub didn't allow me to assign the following users: mkimuram. Note that only kubernetes-csi members and repo collaborators can be assigned. In response to this:
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. |
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) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
2b1cf72
to
c9af2e3
Compare
I support this change. This reserves |
Is my understanding right that the issue is caused by that csi external provisioner passes all the storage class parameters to csi driver's 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.
To solve this issue, we also have an option to strip Pros:
Cons:
|
c9af2e3
to
bf160c0
Compare
bf160c0
to
ed46e81
Compare
ed46e81
to
05716f9
Compare
05716f9
to
0ac9db9
Compare
/assign |
0ac9db9
to
2b53902
Compare
@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 ( |
There was a problem hiding this comment.
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, ...}
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 | ||
} | ||
|
There was a problem hiding this comment.
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
...
}
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you LGTM?
pkg/controller/controller.go
Outdated
@@ -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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[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 |
2b53902
to
b29e000
Compare
There was a problem hiding this 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 ( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor in future
b29e000
to
452a401
Compare
…rameter list, add deprecation notice for old keys and keep their behavior the same
452a401
to
26305f2
Compare
/lgtm |
@jingxu97: changing LGTM is restricted to assignees, and only kubernetes-csi/external-provisioner repo collaborators may be assigned issues. In response to this:
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. |
/lgtm |
Add new reserved prefixed parameter keys which are stripped out of parameter list:
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