-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Conversation
Jenkins unit/integration failed for commit a897f308d0975a69016d146395a07dc5f6db6664. Full PR test history. The magic incantation to run this job again is |
a897f30
to
e6c9947
Compare
e6c9947
to
db79bcd
Compare
Jenkins GCI 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 |
@@ -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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the log
There was a problem hiding this 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.
Jenkins GKE smoke e2e failed for commit db79bcd. Full PR test history. The magic incantation to run this job again is |
Jenkins Kubemark GCE e2e failed for commit db79bcd. Full PR test history. The magic incantation to run this job again is |
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added the log
db79bcd
to
2135002
Compare
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 |
1 similar comment
@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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
2135002
to
9e8edf6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks @jingxu97
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue |
@jingxu97 can you open the cherry-pick by tomorrow and ping me please, thanks! |
Sure. Will do it tonight. On Wed, Oct 5, 2016 at 5:38 PM, Jess Frazelle notifications@github.com
|
cherrypick PR is here #34215 On Wed, Oct 5, 2016 at 6:20 PM, Jing Xu jinxu@google.com wrote:
|
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. |
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). |
…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
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 #29324
This change is