Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Plumbing topology information through Provision call in external PVController library. #902

Merged
merged 2 commits into from
Aug 8, 2018

Conversation

verult
Copy link
Contributor

@verult verult commented Aug 3, 2018

This is a dependency for adding topology functionality to CSI.

In the future, we'd like to cache Node objects since almost all plugins will go through CSI. For now I hope to get the provisioner interface change in first to unblock CSI work, and open an issue to track the work once this PR is merged.

/cc @wongma7 @msau42 @lichuqiang

@k8s-ci-robot
Copy link
Contributor

@verult: GitHub didn't allow me to request PR reviews from the following users: lichuqiang.

Note that only kubernetes-incubator members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

This is a dependency for adding topology functionality to CSI.

In the future, we'd like to cache Node objects since almost all plugins will go through CSI. For now I hope to get the provisioner interface change in first to unblock CSI work, and open an issue to track the work once this PR is merged.

/cc @wongma7 @msau42 @lichuqiang

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 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 Aug 3, 2018
@lichuqiang
Copy link
Contributor

Seems you need go-fmt.
Also, can you add some test cases to validate the change?

Copy link
Contributor

@wongma7 wongma7 left a comment

Choose a reason for hiding this comment

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

lgtm

strerr := fmt.Sprintf("Failed to get target node: %v", err)
glog.Infof("unexpected error getting target node %q for claim %q: %v", nodeName, claimToClaimKey(claim), err)
ctrl.eventRecorder.Event(claim, v1.EventTypeWarning, "ProvisioningFailed", strerr)
return err
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use the same error message for the Event + return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The behavior in this block matches the behavior in the internal PVController

Copy link
Contributor

Choose a reason for hiding this comment

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

agreed let's make error message same for event + return + glog, we do the same weird thing here https://github.com/verult/external-storage/blob/5dee038e0ee3133a8e40fbe39d915cef0c722af2/lib/controller/controller.go#L1102

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ACK

selectedNode, err = ctrl.client.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{}) // TODO (verult) cache Nodes
if err != nil {
strerr := fmt.Sprintf("Failed to get target node: %v", err)
glog.Infof("unexpected error getting target node %q for claim %q: %v", nodeName, claimToClaimKey(claim), err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to log the error if it's being returned?

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 the other comment

Copy link
Contributor

Choose a reason for hiding this comment

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

@wongma7 what do you think of potentially cleaning this up (as a separate PR)? I think the style of logging an error that you also return is unusual

Copy link
Contributor

Choose a reason for hiding this comment

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

yes I will clean it up on next week, the caller of provisionClaimOperation should log the error.

upstream is weirder because the error is bubbled up through goroutinemap and such so I imagine there is a logical explanation for the weirdness but at least here we should make it simpler if we can

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ACK

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 4, 2018
@verult
Copy link
Contributor Author

verult commented Aug 4, 2018

Cleaned up errors/logs/events as mentioned above, and added tests

// Get AllowedTopologies
allowedTopologies, err = ctrl.fetchAllowedTopologies(claimClass)
if err != nil {
return err
Copy link
Contributor

Choose a reason for hiding this comment

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

should an event be logged here too?

return class.AllowedTopologies, nil
}

return nil, fmt.Errorf("Cannot convert object to StorageClass: %+v", classObj)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we've been trying to follow the convention of error messages starting with lowercase

expectedParams *provisionParams
}{
{
name: "provision with AllowedTopologies",
Copy link
Contributor

Choose a reason for hiding this comment

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

also a test case to provision with neither

@verult
Copy link
Contributor Author

verult commented Aug 8, 2018

@msau42 addressed comments

@msau42
Copy link
Contributor

msau42 commented Aug 8, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 8, 2018
@wongma7 wongma7 merged commit 8bf0585 into kubernetes-retired:master Aug 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants