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

make mock driver support PV healthy monitor #268

Merged
merged 1 commit into from
Jun 23, 2020

Conversation

fengzixu
Copy link
Contributor

@fengzixu fengzixu commented May 31, 2020

What I did in this PR

  1. Mock ControllerGetVolume RPC interface
  2. Extend ListVolumes for supporting VolumeCondition support
  3. Extend the NodeVolumeStats functions

This PR is for supporting test of PV health monitor
Fixes: kubernetes-csi/external-health-monitor#9

Updates CSI Spec to v1.3.0.  
Updates the mock driver to support volume health monitoring by implementing ControllerGetVolume and updating ListVolumes and NodeVolumeStats functions.

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 31, 2020
@k8s-ci-robot k8s-ci-robot requested review from jsafrane and msau42 May 31, 2020 09:27
@k8s-ci-robot
Copy link
Contributor

Welcome @fengzixu!

It looks like this is your first PR to kubernetes-csi/csi-test 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-csi/csi-test has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@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 May 31, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @fengzixu. Thanks for your PR.

I'm waiting for a kubernetes-csi member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@fengzixu
Copy link
Contributor Author

/ok-to-test

@k8s-ci-robot
Copy link
Contributor

@fengzixu: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/ok-to-test

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.

@xing-yang
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 31, 2020
@xing-yang
Copy link
Contributor

/assign @xing-yang

go.mod Outdated
@@ -3,7 +3,7 @@ module github.com/kubernetes-csi/csi-test/v3
go 1.12

require (
github.com/container-storage-interface/spec v1.2.0
github.com/container-storage-interface/spec v1.2.0-rc1.0.20200530102742-4c5274ab4e5e
Copy link
Contributor

@xing-yang xing-yang Jun 3, 2020

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it.

Status: &csi.ControllerGetVolumeResponse_VolumeStatus{},
}

volumeStatus, err := s.NodeGetVolumeStats(ctx, &csi.NodeGetVolumeStatsRequest{})
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is NodeGetVolumeStats called within ControllerGetVolume?

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 misunderstand the working mechanism between Controller and Agent. Revised

@@ -388,8 +420,19 @@ func (s *service) ListVolumes(
)

for i = 0; i < len(entries); i++ {
volumeStatus, err := s.NodeGetVolumeStats(ctx, &csi.NodeGetVolumeStatsRequest{
Copy link
Contributor

Choose a reason for hiding this comment

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

ListVolumes is controller PRC. We should not call a Node PRC within a controller RPC.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Thanks for your comment.

@xing-yang
Copy link
Contributor

/assign @NickrenREN

@NickrenREN
Copy link

NickrenREN commented Jun 4, 2020

What I did in this PR
Mock ControllerGetVolume RPC interface
Extend ListVolumes for supporting VolumeCondition support

There are two newly added RPC interfaces, one is controller side: ControllerGetVolume and the other one is node side: NodeGetVolumeStats. Both of them should be mocked here

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 7, 2020
@fengzixu
Copy link
Contributor Author

fengzixu commented Jun 7, 2020

@xing-yang @NickrenREN

Please review it again.


i, v := s.findVolByID(ctx, req.VolumeId)
if i < 0 {
return nil, status.Error(codes.NotFound, req.VolumeId)

Choose a reason for hiding this comment

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

Could we return VolumeCondition and set its Abnormal and Message fields


resp := &csi.ControllerGetVolumeResponse{
Volume: &v,
Status: &csi.ControllerGetVolumeResponse_VolumeStatus{},

Choose a reason for hiding this comment

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

Could we generate the VolumeCondition field instead of returning an empty one (nil)?

Copy link

@NickrenREN NickrenREN Jun 7, 2020

Choose a reason for hiding this comment

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

Please refer to the comments

type ControllerGetVolumeResponse_VolumeStatus struct {
	// A list of all the `node_id` of nodes that this volume is
	// controller published on.
	// This field is OPTIONAL.
	// This field MUST be specified if the PUBLISH_UNPUBLISH_VOLUME
	// controller capability is supported.
	// published_node_ids MAY include nodes not published to or
	// reported by the SP. The CO MUST be resilient to that.
	PublishedNodeIds []string `protobuf:"bytes,1,rep,name=published_node_ids,json=publishedNodeIds,proto3" json:"published_node_ids,omitempty"`
	// Information about the current condition of the volume.
	// This field is OPTIONAL.
	// This field MUST be specified if the
	// VOLUME_CONDITION controller capability is supported.
	VolumeCondition      *VolumeCondition `protobuf:"bytes,2,opt,name=volume_condition,json=volumeCondition,proto3" json:"volume_condition,omitempty"`
	XXX_NoUnkeyedLiteral struct{}         `json:"-"`
	XXX_unrecognized     []byte           `json:"-"`
	XXX_sizecache        int32            `json:"-"`
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For error, I mock the VolumeCondition filed. For normal response, I mocked the PublishedNodeIds

Choose a reason for hiding this comment

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

        // Information about the current condition of the volume.
	// This field is OPTIONAL.
	// This field MUST be specified if the
	// VOLUME_CONDITION controller capability is supported.

@@ -427,6 +434,7 @@ func (s *service) NodeGetVolumeStats(ctx context.Context,
Unit: csi.VolumeUsage_BYTES,
},
},
VolumeCondition: &csi.VolumeCondition{},

Choose a reason for hiding this comment

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

Could we also construct some abnormal conditions ?

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 17, 2020
@fengzixu
Copy link
Contributor Author

@xing-yang @NickrenREN Request review

resp.Status.VolumeCondition.Abnormal = true
resp.Status.VolumeCondition.Message = "volume not found"
return resp, status.Error(codes.NotFound, req.VolumeId)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a case where volume is found but condition is Abnormal=true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the mock test, I think we can divide it into 2 parts to do

  1. Add basic mock test functions for testing if volume-healthy-monitor can work(Due to the initial implementation PR wasn’t merged, it is hard to do further works)
  2. Add more unit, integration, e2e test for testing volume-healthy-monitor can work correctly on positive and negative cases

The reasons I want to do a testing task like above are below

  1. The initial PR blocks many works and it isn’t perfect. We can ensure it works normally and improves it
  2. After initial PR was merged. It is better for us to let more contributors contribute this project.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure

@xing-yang
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 23, 2020
@xing-yang
Copy link
Contributor

/assign @pohly

Copy link
Contributor

@pohly pohly left a comment

Choose a reason for hiding this comment

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

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fengzixu, pohly

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 Jun 23, 2020
@k8s-ci-robot k8s-ci-robot merged commit 1bfc435 into kubernetes-csi:master Jun 23, 2020
@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 Aug 25, 2020
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mock ControllerGetVolume/NodeGetVolumeStats/ListVolumes RPCs to test controller/agent here
5 participants