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

Return error if get NodeStageSecret and NodePublishSecret failed #61096

Merged
merged 1 commit into from
Apr 2, 2018

Conversation

mlmhl
Copy link
Contributor

@mlmhl mlmhl commented Mar 13, 2018

What this PR does / why we need it:

Currently, if got NodeStageSecret or NodePublishSecret failed, we just log the error and assume that there is no credential. I think we should report the error as if user specified these secret, they expect to apply some credentials.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #61052

Release note:

Return error if get NodeStageSecret and NodePublishSecret failed in CSI volume plugin

/sig storage

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 13, 2018
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 13, 2018
@mlmhl
Copy link
Contributor Author

mlmhl commented Mar 13, 2018

/assign @vladimirvivien

@mlmhl
Copy link
Contributor Author

mlmhl commented Mar 13, 2018

/assign @jsafrane

@jsafrane
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 13, 2018
@jsafrane
Copy link
Member

/approve
I let @vladimirvivien lgtm this PR

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 13, 2018
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.

Some nits, otherwise LGTM

@@ -23,16 +23,16 @@ import (
"k8s.io/client-go/kubernetes"
)

func getCredentialsFromSecret(k8s kubernetes.Interface, secretRef *api.SecretReference) map[string]string {
func getCredentialsFromSecret(k8s kubernetes.Interface, secretRef *api.SecretReference) (map[string]string, error) {
credentials := map[string]string{}
secret, err := k8s.CoreV1().Secrets(secretRef.Namespace).Get(secretRef.Name, meta.GetOptions{})
if err != nil {
glog.Warningf("failed to find the secret %s in the namespace %s with error: %v\n", secretRef.Name, secretRef.Namespace, err)
Copy link
Member

Choose a reason for hiding this comment

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

Change Warningf to Errorf

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

if csiSource.NodeStageSecretRef != nil {
nodeStageSecrets, err = getCredentialsFromSecret(c.k8s, csiSource.NodeStageSecretRef)
if err != nil {
return fmt.Errorf("get secret %s/%s failed: %v",
Copy link
Member

Choose a reason for hiding this comment

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

nit: "fetching NodeStageSecretRef failed for secret %s/%s failed: %v

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for reminding, already fixed.

@@ -153,6 +153,15 @@ func (c *csiMountMgr) SetUpAt(dir string, fsGroup *int64) error {

attribs := csiSource.VolumeAttributes

nodePublishSecrets := map[string]string{}
if csiSource.NodePublishSecretRef != nil {
nodePublishSecrets, err = getCredentialsFromSecret(c.k8s, csiSource.NodePublishSecretRef)
Copy link
Member

Choose a reason for hiding this comment

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

nit: "fetching NodePublishSecretRef failed for secret %s/%s failed: %v

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above.

@verult
Copy link
Contributor

verult commented Mar 22, 2018

/uncc

@k8s-ci-robot k8s-ci-robot removed the request for review from verult March 22, 2018 18:48
@saad-ali
Copy link
Member

saad-ali commented Apr 2, 2018

Thanks!!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 2, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jsafrane, mlmhl, 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-github-robot
Copy link

/test all

Tests are more than 96 hours old. Re-running tests.

@saad-ali
Copy link
Member

saad-ali commented Apr 2, 2018

Please cherry pick back to 1.10 branch once this is merged.

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 61096, 61955, 61542, 60597). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit c079d1e into kubernetes:master Apr 2, 2018
@saad-ali
Copy link
Member

saad-ali commented Apr 9, 2018

@mlmhl Please cherry pick back to 1.10 branch.

@mlmhl
Copy link
Contributor Author

mlmhl commented Apr 10, 2018

@saad-ali Thanks for reminding, the cherry pick PR has been submitted.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Apr 14, 2018
k8s-github-robot pushed a commit that referenced this pull request Apr 16, 2018
…origin-release-1.10

Automatic merge from submit-queue.

Automated cherry pick of #61096: return error if get NodeStageSecret and NodePublishSecret failed

Cherry pick of #61096 on release-1.10.

#61096: Return error if get NodeStageSecret and NodePublishSecret failed

**Release note**:

```release-note
Return error if get NodeStageSecret and NodePublishSecret failed in CSI volume plugin
```
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. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSI volume plugin should report error when it can't fetch secrets.
7 participants