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

Fix issue in updating device path when volume is attached multiple times #33796

Merged
merged 1 commit into from
Oct 4, 2016

Conversation

jingxu97
Copy link
Contributor

@jingxu97 jingxu97 commented Sep 29, 2016

When volume is attached, it is possible that the actual state
already has this volume object (e.g., the volume is attached to multiple
nodes, or volume was detached and attached again). We need to update the
device path in such situation, otherwise, the device path would be stale
information and cause kubelet mount to the wrong device.

Fix issue in updating device path when volume is attached multiple times

This PR partially fixes issue #29324


This change is Reviewable

@jingxu97 jingxu97 added the priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. label Sep 29, 2016
@jingxu97 jingxu97 added this to the v1.4 milestone Sep 29, 2016
@jingxu97 jingxu97 changed the title Fix issue in updating device path when volume is attached Fix issue in updating device path when volume is attached multiple times Sep 29, 2016
@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels Sep 29, 2016
@k8s-ci-robot
Copy link
Contributor

Jenkins unit/integration failed for commit a897f308d0975a69016d146395a07dc5f6db6664. Full PR test history.

The magic incantation to run this job again is @k8s-bot unit test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@jingxu97
Copy link
Contributor Author

@saad-ali PTAL. This is the fix for PR #29324

@k8s-ci-robot
Copy link
Contributor

Jenkins GCI GKE smoke e2e failed for commit db79bcd. Full PR test history.

The magic incantation to run this job again is @k8s-bot gci gke e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@jingxu97
Copy link
Contributor Author

@k8s-bot gke e2e test this

@@ -279,8 +279,13 @@ func (asw *actualStateOfWorld) AddVolumeNode(
nodesAttachedTo: make(map[types.NodeName]nodeAttachedTo),
devicePath: devicePath,
}
asw.attachedVolumes[volumeName] = volumeObj
} else {
// If volume object already exists, it indicates that the information would be out of date.
Copy link
Member

Choose a reason for hiding this comment

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

Do you think we should glog.Info or glog.V(2).Info, so we can have some indication in the logs?

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 the log

@@ -367,6 +367,10 @@ func (asw *actualStateOfWorld) addVolume(
devicePath: devicePath,
}
asw.attachedVolumes[volumeName] = volumeObj
} else {
// If volume object already exists, update the fields such as device path
Copy link
Member

Choose a reason for hiding this comment

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

And here as well I guess?

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 the log

Copy link
Member

@justinsb justinsb left a comment

Choose a reason for hiding this comment

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

LGTM, though I don't know this code other than what you have taught me! Did propose some additional logging points, if you think that would be helpful if we have to diagnose this further.

@k8s-ci-robot
Copy link
Contributor

Jenkins GKE smoke e2e failed for commit db79bcd. Full PR test history.

The magic incantation to run this job again is @k8s-bot gke e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins Kubemark GCE e2e failed for commit db79bcd. Full PR test history.

The magic incantation to run this job again is @k8s-bot kubemark e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@@ -367,6 +367,10 @@ func (asw *actualStateOfWorld) addVolume(
devicePath: devicePath,
}
asw.attachedVolumes[volumeName] = volumeObj
} else {
// If volume object already exists, update the fields such as device path
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 the log

@jingxu97
Copy link
Contributor Author

jingxu97 commented Oct 3, 2016

addressed comments. @justinsb @saad-ali PTAL

@k8s-ci-robot
Copy link
Contributor

Jenkins GCE e2e failed for commit 2135002. Full PR test history.

The magic incantation to run this job again is @k8s-bot gce e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@jingxu97
Copy link
Contributor Author

jingxu97 commented Oct 3, 2016

@k8s-bot gce e2e test this

1 similar comment
@jingxu97
Copy link
Contributor Author

jingxu97 commented Oct 3, 2016

@k8s-bot gce e2e test this

} else {
// If volume object already exists, update the fields such as device path
volumeObj.devicePath = devicePath
volumeObj.spec = volumeSpec
Copy link
Member

Choose a reason for hiding this comment

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

This will not update the devicePath/volumeSpec for asw.attachedVolumes[volumeName]. It only updates the temporary volumeObj object. To update the value in the map, you have to write the temp object back:

        asw.attachedVolumes[volumeName] = volumeObj

Copy link
Member

Choose a reason for hiding this comment

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

nit: also add a unit test verifying new behavior please.

Copy link
Contributor Author

@jingxu97 jingxu97 Oct 4, 2016

Choose a reason for hiding this comment

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

I tried to add the unit test, but this device path stored in attachedVolumes does not used anywhere. So right now there is no public API to retrieve this piece of information. If we want to test it, it requires to add a new API which we don't really need right now.

I changed this part of code mainly for consistency.

@@ -26,6 +26,36 @@ import (
volumetesting "k8s.io/kubernetes/pkg/volume/testing"
)

func verifyAttachedVolume(
Copy link
Member

Choose a reason for hiding this comment

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

nit: Why move the helper method to the top of the file? I'd prefer to leave the helper method near the bottom where it was (makes the diff easier 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.

Before it was in the middle of the code. If I move it to the bottom, it will still has the same effect, I think

Copy link
Member

Choose a reason for hiding this comment

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

Got it. Let's keep Tests grouped together at the top, and helper methods at the bottom.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the order

verifyAttachedVolume(t, attachedVolumes, generatedVolumeName1, string(volumeName), node1Name, devicePath, true /* expectedMountedByNode */, false /* expectNonZeroDetachRequestedTime */)
}

func Test_OneVolumeTwoNodes_TwoDevicePaths(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: move this up after the last Test_... so all tests are grouped together.

When volume is attached, it is possible that the actual state
already has this volume object (e.g., the volume is attached to multiple
nodes, or volume was detached and attached again). We need to update the
device path in such situation, otherwise, the device path would be stale
information and cause kubelet mount to the wrong device.

This PR partially fixes issue kubernetes#29324
Copy link
Member

@saad-ali saad-ali left a comment

Choose a reason for hiding this comment

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

LGTM Thanks @jingxu97

@saad-ali saad-ali added lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels Oct 4, 2016
@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 1dc8277 into kubernetes:master Oct 4, 2016
@saad-ali
Copy link
Member

saad-ali commented Oct 5, 2016

Adding cherrypick-candidate and v1.4 milestone -- @jingxu97 please create cherrypick for this to ensure it is in v1.4.1

CC @jessfraz

@jessfraz jessfraz added the cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. label Oct 6, 2016
@jessfraz
Copy link
Contributor

jessfraz commented Oct 6, 2016

@jingxu97 can you open the cherry-pick by tomorrow and ping me please, thanks!

@jingxu97
Copy link
Contributor Author

jingxu97 commented Oct 6, 2016

Sure. Will do it tonight.

On Wed, Oct 5, 2016 at 5:38 PM, Jess Frazelle notifications@github.com
wrote:

@jingxu97 https://github.com/jingxu97 can you open the cherry-pick by
tomorrow and ping me please, thanks!


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#33796 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ASSNxaYJT8oNHM9YAnvI9yM0oUMunnLOks5qxEL8gaJpZM4KKjcf
.

  • Jing

@jingxu97
Copy link
Contributor Author

jingxu97 commented Oct 6, 2016

cherrypick PR is here #34215
Please let me know if there is any issue. Thanks!

On Wed, Oct 5, 2016 at 6:20 PM, Jing Xu jinxu@google.com wrote:

Sure. Will do it tonight.

On Wed, Oct 5, 2016 at 5:38 PM, Jess Frazelle notifications@github.com
wrote:

@jingxu97 https://github.com/jingxu97 can you open the cherry-pick by
tomorrow and ping me please, thanks!


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#33796 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ASSNxaYJT8oNHM9YAnvI9yM0oUMunnLOks5qxEL8gaJpZM4KKjcf
.

  • Jing

  • Jing

@jessfraz jessfraz 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 Oct 6, 2016
k8s-github-robot pushed a commit that referenced this pull request Oct 6, 2016
…96-upstream-release-1.4

Automatic merge from submit-queue

Automated cherry pick of #33796

Cherry pick of #33796 on release-1.4.

#33796: Fix issue in updating device path when volume is attached
@k8s-cherrypick-bot
Copy link

Commit found in the "release-1.4" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked.

@saad-ali
Copy link
Member

saad-ali commented Oct 6, 2016

Thanks @jingxu97. Now that this has been cherry-picked to the 1.4 branch (for 1.4.1), let's also cherry-pick it to the 1.3 branch (for 1.3.9).

@saad-ali saad-ali added cherrypick-candidate and removed cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. labels Oct 6, 2016
@saad-ali saad-ali modified the milestones: v1.3, v1.4 Oct 6, 2016
shyamjvs pushed a commit to shyamjvs/kubernetes that referenced this pull request Dec 1, 2016
…ck-of-#33796-upstream-release-1.4

Automatic merge from submit-queue

Automated cherry pick of kubernetes#33796

Cherry pick of kubernetes#33796 on release-1.4.

kubernetes#33796: Fix issue in updating device path when volume is attached
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. 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.

8 participants