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

Fetch VM UUID from - /sys/class/dmi/id/product_serial #45311

Merged

Conversation

divyenpatel
Copy link
Member

@divyenpatel divyenpatel commented May 3, 2017

What this PR does / why we need it:
Current code fetch VM uuid using uuid reported at '/sys/devices/virtual/dmi/id/product_uuid'. This doesn't work with all the distros like Ubuntu 16.04 and Fedora.

updating code to fetch VM uuid from /sys/class/dmi/id/product_serial

Which issue this PR fixes
fixes #

Special notes for your reviewer:
Verified UUID is matching with VM UUID on ubuntu 16.04, Cent OS 7.3 , and Photon OS

@BaluDontu @tusharnt

Release note:

vSphere cloud provider: Fix fetching of VM UUID on Ubuntu 16.04 and Fedora.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 3, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. labels May 3, 2017
@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 3, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @divyenpatel. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with @k8s-bot 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.

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. I understand the commands that are listed here.


// check the uuid starts with "VMware-"
if !strings.HasPrefix(uuidstr, UUIDPrefix) {
return "", fmt.Errorf("cannot find this VM's UUID")
Copy link
Contributor

Choose a reason for hiding this comment

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

How about recording the uuidstr in error info?

Copy link
Member Author

Choose a reason for hiding this comment

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

added uuid in the error.
return "", fmt.Errorf("Failed to match Prefix, UUID read from the file is %v", uuidFromFile)

uuidstr = strings.Replace(uuidstr[len(UUIDPrefix):(len(uuidstr)-1)], " ", "", -1)

// need to add dashes, e.g. "564d395e-d807-e18a-cb25-b79f65eb2b9f"
uuidstr = fmt.Sprintf("%s-%s-%s-%s", uuidstr[0:8], uuidstr[8:12], uuidstr[12:21], uuidstr[21:])
Copy link
Contributor

Choose a reason for hiding this comment

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

Validate the length of uuidstr in case it's shorter than expected by accident.

Copy link
Member Author

Choose a reason for hiding this comment

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

verified length

if len(uuid) != 32 {
		return "", fmt.Errorf("Length check failed, UUID read from the file is %v", uuidFromFile)
	}

@dims
Copy link
Member

dims commented May 4, 2017

@k8s-bot ok to test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 4, 2017
@divyenpatel divyenpatel force-pushed the fix_fetch_VM_UUID branch 2 times, most recently from ce2aa81 to e086d0a Compare May 4, 2017 19:19
@divyenpatel
Copy link
Member Author

@k8s-bot gce etcd3 e2e test this

1 similar comment
@divyenpatel
Copy link
Member Author

@k8s-bot gce etcd3 e2e test this

@divyenpatel
Copy link
Member Author

@dims all tests passed. Can you help merging this change to master?

@dims
Copy link
Member

dims commented May 8, 2017

/assign @luomiao

@dims
Copy link
Member

dims commented May 8, 2017

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 8, 2017
@luomiao
Copy link

luomiao commented May 8, 2017

/approve

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dims, divyenpatel, luomiao

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 8, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 41903, 45311, 45474, 45472, 45501)

@k8s-github-robot k8s-github-robot merged commit 5290382 into kubernetes:master May 8, 2017
@enisoc enisoc added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label May 13, 2017
@enisoc enisoc removed the release-note-none Denotes a PR that doesn't merit a release note. label May 13, 2017
k8s-github-robot pushed a commit that referenced this pull request May 13, 2017
…45311-kubernetes-release-1.6

Automatic merge from submit-queue

Automated cherry pick of #45311 #43545 upstream release 1.6

Cherry pick of #45311 #43545 on release-1.6.

#45311: Fetch VM UUID from - /sys/class/dmi/id/product_serial 
#43545: Remove credentials on worker nodes for vSphere cloud provider.

 @luomiao @BaluDontu @abrarshivani @tusharnt
@divyenpatel divyenpatel deleted the fix_fetch_VM_UUID branch September 5, 2017 23:10
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. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants