Skip to content

v0.2.0.alpha driver initial code push #2

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

Merged
merged 3 commits into from
Jun 18, 2018

Conversation

davidz627
Copy link
Contributor

All the code written so far for the driver

@k8s-ci-robot k8s-ci-robot requested a review from saad-ali June 11, 2018 22:22
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 11, 2018
@davidz627
Copy link
Contributor Author

A full review probably isn't possible here. But if you're scrolling through and see any glaring issues feel free to put a comment or add an issue to the repo after this gets merged.

@davidz627 davidz627 force-pushed the feature/GCEDriverCode branch 2 times, most recently from 6f85a0f to 1cf9e6b Compare June 12, 2018 22:53
name = "github.com/container-storage-interface/spec"
packages = ["lib/go/csi/v0"]
revision = "35d9f9d77954980e449e52c3f3e43c21bd8171f5"
version = "v0.2.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

0.3.0 is out. Do you want to do that update separately?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I'll do it in a future push. This is just the current working code.

# See the License for the specific language governing permissions and
# limitations under the License.

FROM fedora:26
Copy link
Contributor

Choose a reason for hiding this comment

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

Confirm with @tallclair what base image we should use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a TODO. Wont fix for initial commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#4

app: csi-gce-pd
ports:
- name: dummy
port: 12345
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add a comments explaining the purpose at the top of the file, e.g.:

# The dummy service is required for creating a StatefulSet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure you actually need a service object. I launched the plugin without the service object and it was fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

weird, we've had this discussion before and I remember trying specifically and having it fail. I will test again

volumeMounts:
- name: socket-dir
mountPath: /csi
- name: csi-attacher
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: csi-attacher -> csi-external-attacher for consistency?

Copy link
Contributor Author

@davidz627 davidz627 Jun 13, 2018

Choose a reason for hiding this comment

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

the image is named csi-attacher. But i'll change it for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

modified the csi-external-provisioner to csi-provisioner instead for provisioner

@davidz627 davidz627 force-pushed the feature/GCEDriverCode branch from 1cf9e6b to 9688b10 Compare June 13, 2018 01:07
Makefile Outdated
# See the License for the specific language governing permissions and
# limitations under the License.

STAGINGIMAGE=gcr.io/dyzz-csi-staging/csi/gce-driver
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 rename all the references to "gce-pd" instead of just "gce"

Step 1 (Create Credentials):
Create Service Account Credential JSON on GCP:
- TODO: Add detailed steps on how to do this
- Requires both Compute Owner and Cloud Project Owner permissions
Copy link
Contributor

Choose a reason for hiding this comment

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

That's pretty broad permissions, there are no reduced scopes for just pd?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

theres a "compute-admin" and a "compute-storage-admin" scope. However when I tried those for some reason there were not enough permissions to Attach. Everything else was fine, just not Attach. I will open an issue on this repo to revisit that and either it will work, or I will open a bug against the compute scopes because I think "Attach" should definitely be covered under "compute-admin"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#3

@msau42
Copy link
Contributor

msau42 commented Jun 13, 2018

Can you separate out vendor from the rest? That could make this slightly easier to review :-)

@davidz627 davidz627 force-pushed the feature/GCEDriverCode branch from 9688b10 to 9c3112c Compare June 13, 2018 17:48
@davidz627
Copy link
Contributor Author

@msau42 seperated out, its still a 4000+ line commit :P

Copy link
Contributor

@msau42 msau42 left a comment

Choose a reason for hiding this comment

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

For the gce-> gce-pd naming change, I meant everywhere in the project. package, file, directory, type names etc.

if err != nil {
return nil, err
}
service.UserAgent = fmt.Sprintf("GCE CSI Driver/%s (%s %s)", "0.2.0", runtime.GOOS, runtime.GOARCH)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to make this version number parameterized so you don't have to modify the code everytime you bump the version? I don't think there's a downward api for container image name though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a TODO, don't think its super important, bumping the version is a very manual process and theres no way to get it from the Spec itself AFAIK

}

func getProjectAndZoneFromMetadata() (string, string, error) {
result, err := metadata.Get("instance/zone")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there's a metadata.Zone() call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@davidz627 davidz627 force-pushed the feature/GCEDriverCode branch from 9abe2c2 to a30cd65 Compare June 13, 2018 20:43
app: csi-gce-pd
ports:
- name: dummy
port: 12345
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure you actually need a service object. I launched the plugin without the service object and it was fine

namespace: default
roleRef:
kind: ClusterRole
name: system:csi-external-provisioner
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a bug and this role doesn't actually have all the permissions needed. So as a workaround, I had to create a custom clusterrole with just persistentvolumes.get and bind to that too.

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 see, the bug was hidden from me because external-attacher has PV GET and I have them bundled together in the controller service account


const (
// MaxVolumeSize is the maximum standard and ssd size of 64TB
MaxVolumeSize int64 = 64000000000000
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can define these in terms of 1000's to make it easier to read

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

DiskTypeStandard = "pd-standard"
diskTypeDefault = DiskTypeStandard

diskTypePersistent = "PERSISTENT"
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like there's two kinds of "disk types". Can you rename one of them to be disambiguate them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

capBytes = tcap
}
// Too small, default
if capBytes < DefaultVolumeSize {
Copy link
Contributor

Choose a reason for hiding this comment

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

cap < min volume size?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done


func (gceCS *GCEControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error) {
// TODO: Only allow deletion of volumes that were created by the driver
// Assuming ID is of form {project}/{zone}/{id}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need project in the id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

comment was obsolete

return splitId[0], splitId[1], nil
}

func CombineVolumeId(zone, name string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

You probably need to add something for repd in the volume id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#7

Copy link
Contributor

Choose a reason for hiding this comment

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

we're not supporting backwards compatibility yet? I wonder how difficult it would be to change the volume handle format later

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 will make sure the volume handle is stable before going to beta. I think its fine for alpha (?) @saad-ali

Copy link
Contributor

Choose a reason for hiding this comment

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

Ya, it's fine for alpha. Update the README file in the root of the repo indicating current status is alpha, and what the implication of alpha are (potentially backwards compatibility breaking changes).

Mounter mountmanager.Mounter
}

func (ns *GCENodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Publish and Unpublish should add some locking in case it gets called multiple times for the same mount. Kubernetes theoretically synchronizes this for the plugin, but it's not a requirement in the CSI spec.

Copy link
Contributor

Choose a reason for hiding this comment

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

And similarly for Stage/Unstage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just locked all of the node calls for now, I'll add a TODO to make them more fine grained and only lock mutually exclusive calls with each other in the future

@davidz627 davidz627 force-pushed the feature/GCEDriverCode branch 2 times, most recently from 8b53c4c to 56ce990 Compare June 14, 2018 18:19
some rudimentary node call locking, changed volume size representations,
removed dummy service from statefulset definition.
@davidz627 davidz627 force-pushed the feature/GCEDriverCode branch from 56ce990 to f3b2119 Compare June 15, 2018 00:01
@davidz627
Copy link
Contributor Author

ping @msau42 @saad-ali for approval

@msau42
Copy link
Contributor

msau42 commented Jun 18, 2018

/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 18, 2018
@davidz627 davidz627 merged commit e0fdcf1 into kubernetes-sigs:master Jun 18, 2018
@davidz627 davidz627 deleted the feature/GCEDriverCode branch June 18, 2018 18:25
k8s-ci-robot pushed a commit that referenced this pull request Aug 12, 2020
Pull request from sigs head to forked head
jsafrane pushed a commit to jsafrane/gcp-compute-persistent-disk-csi-driver that referenced this pull request Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. 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.

4 participants