Skip to content
This repository was archived by the owner on Mar 16, 2021. It is now read-only.

Conversation

@wackxu
Copy link
Contributor

@wackxu wackxu commented Jun 11, 2018

I am working with @xing-yang about Move Snapshot APIs in-tree, and we have test the implementation of host path volume snapshot. so push this code.

@wackxu
Copy link
Contributor Author

wackxu commented Jun 11, 2018

@lpabon

@lpabon
Copy link
Contributor

lpabon commented Jun 19, 2018

Looks like two errors from the unit tests: 1. go fmt 2. Seems one of the API calls did not pass.

return &csi.ValidateVolumeCapabilitiesResponse{Supported: true, Message: ""}, nil
}

func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add a lot of comments to this function to explain what the algorithm is and what tools it needs from the container?

createAt := time.Now().UnixNano()
volPath := hostPathVolume.VolPath
file := snapshotRoot + snapshotID + ".tgz"
args := []string{"czf", file, "-C", volPath, "."}
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool idea.

}

glog.V(4).Infof("create volume snapshot %s", file)
hostPathSna := hostPathSnapshot{}
Copy link
Contributor

Choose a reason for hiding this comment

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

what is Sna? Is that Snapshot? Maybe call it just snap or snapshot since it is a local variable.

}

type hostPathSnapshot struct {
SnaName string `json:"snaName"`
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove all Sna prefixes since they are part of the hostPathSnapshot object. So, SnaID being just Id would be the id of the snapshot. and so one.

glog.V(4).Infof("deleting volume %s", snapshotID)
path := snapshotRoot + snapshotID + ".tgz"
os.RemoveAll(path)
delete(hostPathVolumeSnapshots, snapshotID)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should check first if it is there. If it is not, then it should return that the snapshot id is not found.

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 do not think so. from the spec, we can see this for DeleteSnapshot,

This operation MUST be idempotent. If a snapshot corresponding to the specified snapshot_id does not exist or the artifacts associated with the snapshot do not exist anymore, the Plugin MUST reply 0 OK.

I think we can just do the delete operation like deleteVolume and we do not need check whether the snapshot exists.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, great point.


func (cs *controllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error) {
// Check arguments
if len(req.GetSnapshotId()) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is optional. It is only used to get the snapshot information about a single snapshot id. it should not be checked if it was passed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, we should return a list of all the snapshots in the system that:

  1. Match the source volume id
  2. Match the snapshot id
  3. Match Anything (meaning all of the snapshots)

@wackxu wackxu force-pushed the volsnap branch 2 times, most recently from 8080b3e to 07864ee Compare June 20, 2018 09:20
@wackxu
Copy link
Contributor Author

wackxu commented Jun 20, 2018

@lpabon test has been fixed by kubernetes-csi/csi-test#81

@lpabon
Copy link
Contributor

lpabon commented Jun 20, 2018

@wackxu Seems there is one more csi-sanity issue:

[Fail] ControllerGetCapabilities [Controller Server] [It] should return appropriate capabilities 
/home/travis/gopath/src/github.com/kubernetes-csi/csi-test/pkg/sanity/controller.go:100

I'll take a look to see if we are using the latest from csi-sanity

@xing-yang
Copy link
Contributor

Can you fix the typo in the title s/Hostpaht/hostpath.

@wackxu
Copy link
Contributor Author

wackxu commented Jun 21, 2018

@xing-yang Done

@wackxu wackxu changed the title Hostpaht snapshot implementation Hostpath snapshot implementation Jun 21, 2018
@wackxu
Copy link
Contributor Author

wackxu commented Jun 21, 2018

@lpabon Yes, I see we are using the latest from csi-sanity, and there is a bug when csi-sanity switch to CSI 0.3.0. And we should first merge kubernetes-csi/csi-test#81. then test will pass.

# Get csi-sanity
if [ ! -x $GOPATH/bin/csi-sanity ] ; then
	go get -u github.com/kubernetes-csi/csi-test
	pushd $GOPATH/src/github.com/kubernetes-csi/csi-test/cmd/csi-sanity
	make all
	make install
	popd
#./hack/get-sanity.sh
fi

goto result
}
}
}

Choose a reason for hiding this comment

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

Shouldn't there be duplicate snapshot entries where both, snapshotId and sourceVolumeId are given?

Copy link

@sarjeet2013 sarjeet2013 Aug 7, 2018

Choose a reason for hiding this comment

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

Actually it won't as it'll goto result once process this block. You can skip above comment

}

rsp := &csi.ListSnapshotsResponse{
Entries: entries,

Choose a reason for hiding this comment

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

It shouldn't return more than MaxEntries entries.

}

// case 2: SourceVolumeId is not empty, return snapshots that match the source volume id.
if len(req.SourceVolumeId) != 0 {

Choose a reason for hiding this comment

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

Can it be consistent to be req.GetSourceVolumeId()?

Id: exSnap.Id,
SourceVolumeId: exSnap.VolID,
CreatedAt: exSnap.CreateAt,
Status: exSnap.Status,
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to return SizeBytes.

SourceVolumeId: snapshot.VolID,
CreatedAt: snapshot.CreateAt,
Status: snapshot.Status,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

SizeBytes is missing.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: wackxu
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: sbezverk

If they are not already assigned, you can assign the PR to them by writing /assign @sbezverk in a comment when ready.

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

The pull request process is described here

Details 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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 3, 2018
@wackxu wackxu force-pushed the volsnap branch 2 times, most recently from 10a8abd to ce10084 Compare September 3, 2018 12:56
@wackxu
Copy link
Contributor Author

wackxu commented Sep 3, 2018

@lpabon @sarjeet2013 @xing-yang Sorry for the delay, update, PTAL

@wackxu
Copy link
Contributor Author

wackxu commented Sep 4, 2018

@lpabon @xing-yang I think we should merge this asap, since external-snapshotter is merged and it is easy for us to test the external-snapshotter if we merge this.

snapshot.VolID = volumeID
snapshot.Path = file
snapshot.CreateAt = createAt
snapshot.SizeBytes = fileInfo.Size()
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be the size of the original volume, not how much space is used.
For example, "hostPathVol.VolSize = capacity" in CreateVolume. We should do the same thing here.

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 clarify this, Updated

@k8s-ci-robot
Copy link
Contributor

@xing-yang: changing LGTM is restricted to assignees, and only kubernetes-csi/drivers repo collaborators may be assigned issues.

Details

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.

Copy link
Contributor

@xing-yang xing-yang left a comment

Choose a reason for hiding this comment

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

LGTM

@wackxu
Copy link
Contributor Author

wackxu commented Sep 7, 2018

kindly ping @lpabon for approval

}, nil
}

func covertSnapshot(snap hostPathSnapshot) *csi.ListSnapshotsResponse {

Choose a reason for hiding this comment

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

Did you mean * convertSnapshot*?

}

var nextToken string
if n := startingToken + int32(i); n < ulenSnapshots {

Choose a reason for hiding this comment

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

Why not directly use j as next token?

@sarjeet2013
Copy link

LGTM. few minor comments but not a blocker to merge.

@wackxu
Copy link
Contributor Author

wackxu commented Sep 11, 2018

@sarjeet2013 Thanks for your review, Updated

@k8s-ci-robot k8s-ci-robot merged commit 0910c66 into kubernetes-retired:master Sep 11, 2018
@wackxu wackxu deleted the volsnap branch September 12, 2018 01:12
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. 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.

5 participants