Skip to content

Add metadata info in tag on PD #570

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 1 commit into from
Aug 6, 2020

Conversation

saad-ali
Copy link
Contributor

@saad-ali saad-ali commented Aug 6, 2020

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind feature

What this PR does / why we need it:
In-tree GCE PD "tags" a disk with information about which PVC/PV the disk was created for.
These tags are stored as JSON in the disk Description field.
This PR archives feature-parity with that behavior using kubernetes-csi/external-provisioner#399
Added automated tests and did manual tests to verify new behavior:

Example disk Description field provisioned by in-tree GCE PD plugin:

{"kubernetes.io/created-for/pv/name":"pvc-4ffe59ed-8ee0-11e7-a29f-42010a800002","kubernetes.io/created-for/pvc/name":"myclaim","kubernetes.io/created-for/pvc/namespace":"default"}

Example disk Description field provisioned by GCE PD CSI Driver with this change:

{"kubernetes.io/created-for/pv/name":"pvc-32af883a-d7cc-11ea-86f9-42010a800053","kubernetes.io/created-for/pvc/name":"pvc-demo","kubernetes.io/created-for/pvc/namespace":"default","storage.gke.io/created-by":"pd.csi.storage.gke.io"}

Which issue(s) this PR fixes:

Fixes #387

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Provisioned GCE PD Description will contain JSON with information about what PVC/PV disk was created for (similar to volumes provisioned by in-tree GCE PD plugin). This feature requires the `--extra-create-metadata` flag to be set on the CSI external-provisioner.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 6, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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

@saad-ali
Copy link
Contributor Author

saad-ali commented Aug 6, 2020

/assign @msau42

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 6, 2020
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 6, 2020
default:
return p, fmt.Errorf("parameters contains invalid option %q", k)
}
}
if len(p.Tags) > 0 {
p.Tags[tagKeyCreatedBy] = driverName
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 want to set this regardless?

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 want to retain the existing behavior (description set to Regional disk created by GCE-PD CSI Driver or Disk created by GCE-PD CSI Driver depending on disk) if the PVC/PV parameters aren't present.

@@ -788,3 +817,18 @@ func removeCryptoKeyVersion(kmsKey string) string {
}
return kmsKey
}

// encodeDiskTags encodes requested volume tags into JSON string, as GCE does
// not support tags on GCE PDs and we use Description field as fallback.
Copy link
Contributor

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.

There is another PR adding labels (#566). My plan is to merge this, and poke that PR to incorporate these as labels as well.

@@ -32,6 +32,7 @@ spec:
- "--enable-leader-election"
- "--leader-election-type=leases"
- "--leader-election-namespace=$(PDCSI_NAMESPACE)"
- "--extra-create-metadata"
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 want to set this in staging overlays for now? This will update the "stable" overlay, which may cause stable deployments to fail since the older released drivers can't handle the new parameters.

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, I'll move this to staging.

@saad-ali
Copy link
Contributor Author

saad-ali commented Aug 6, 2020

PTAL

@msau42
Copy link
Contributor

msau42 commented Aug 6, 2020

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 6, 2020
@k8s-ci-robot k8s-ci-robot merged commit a1ba4cb into kubernetes-sigs:master Aug 6, 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. kind/feature Categorizes issue or PR as related to a new feature. 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. 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.

Add metadata information in tag on PD
3 participants