Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
638ef1b9
Commit
638ef1b9
authored
Nov 30, 2016
by
rkouj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SetNodeUpdateStatusNeeded whenever nodeAdd event is received
parent
ec1371b2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
6 deletions
+46
-6
attach_detach_controller.go
...ontroller/volume/attachdetach/attach_detach_controller.go
+17
-6
actual_state_of_world.go
...roller/volume/attachdetach/cache/actual_state_of_world.go
+8
-0
actual_state_of_world_test.go
...r/volume/attachdetach/cache/actual_state_of_world_test.go
+19
-0
node_status_updater.go
.../volume/attachdetach/statusupdater/node_status_updater.go
+2
-0
No files found.
pkg/controller/volume/attachdetach/attach_detach_controller.go
View file @
638ef1b9
...
@@ -240,6 +240,23 @@ func (adc *attachDetachController) podDelete(obj interface{}) {
...
@@ -240,6 +240,23 @@ func (adc *attachDetachController) podDelete(obj interface{}) {
func
(
adc
*
attachDetachController
)
nodeAdd
(
obj
interface
{})
{
func
(
adc
*
attachDetachController
)
nodeAdd
(
obj
interface
{})
{
node
,
ok
:=
obj
.
(
*
v1
.
Node
)
node
,
ok
:=
obj
.
(
*
v1
.
Node
)
// TODO: investigate if nodeName is empty then if we can return
// kubernetes/kubernetes/issues/37777
if
node
==
nil
||
!
ok
{
return
}
nodeName
:=
types
.
NodeName
(
node
.
Name
)
adc
.
nodeUpdate
(
nil
,
obj
)
// kubernetes/kubernetes/issues/37586
// This is to workaround the case when a node add causes to wipe out
// the attached volumes field. This function ensures that we sync with
// the actual status.
adc
.
actualStateOfWorld
.
SetNodeStatusUpdateNeeded
(
nodeName
)
}
func
(
adc
*
attachDetachController
)
nodeUpdate
(
oldObj
,
newObj
interface
{})
{
node
,
ok
:=
newObj
.
(
*
v1
.
Node
)
// TODO: investigate if nodeName is empty then if we can return
if
node
==
nil
||
!
ok
{
if
node
==
nil
||
!
ok
{
return
return
}
}
...
@@ -250,15 +267,9 @@ func (adc *attachDetachController) nodeAdd(obj interface{}) {
...
@@ -250,15 +267,9 @@ func (adc *attachDetachController) nodeAdd(obj interface{}) {
// detach controller. Add it to desired state of world.
// detach controller. Add it to desired state of world.
adc
.
desiredStateOfWorld
.
AddNode
(
nodeName
)
adc
.
desiredStateOfWorld
.
AddNode
(
nodeName
)
}
}
adc
.
processVolumesInUse
(
nodeName
,
node
.
Status
.
VolumesInUse
)
adc
.
processVolumesInUse
(
nodeName
,
node
.
Status
.
VolumesInUse
)
}
}
func
(
adc
*
attachDetachController
)
nodeUpdate
(
oldObj
,
newObj
interface
{})
{
// The flow for update is the same as add.
adc
.
nodeAdd
(
newObj
)
}
func
(
adc
*
attachDetachController
)
nodeDelete
(
obj
interface
{})
{
func
(
adc
*
attachDetachController
)
nodeDelete
(
obj
interface
{})
{
node
,
ok
:=
obj
.
(
*
v1
.
Node
)
node
,
ok
:=
obj
.
(
*
v1
.
Node
)
if
node
==
nil
||
!
ok
{
if
node
==
nil
||
!
ok
{
...
...
pkg/controller/volume/attachdetach/cache/actual_state_of_world.go
View file @
638ef1b9
...
@@ -116,6 +116,9 @@ type ActualStateOfWorld interface {
...
@@ -116,6 +116,9 @@ type ActualStateOfWorld interface {
// since volumes should be removed from this list as soon a detach operation
// since volumes should be removed from this list as soon a detach operation
// is considered, before the detach operation is triggered).
// is considered, before the detach operation is triggered).
GetVolumesToReportAttached
()
map
[
types
.
NodeName
][]
v1
.
AttachedVolume
GetVolumesToReportAttached
()
map
[
types
.
NodeName
][]
v1
.
AttachedVolume
// GetNodesToUpdateStatusFor returns the map of nodeNames to nodeToUpdateStatusFor
GetNodesToUpdateStatusFor
()
map
[
types
.
NodeName
]
nodeToUpdateStatusFor
}
}
// AttachedVolume represents a volume that is attached to a node.
// AttachedVolume represents a volume that is attached to a node.
...
@@ -457,6 +460,7 @@ func (asw *actualStateOfWorld) updateNodeStatusUpdateNeeded(nodeName types.NodeN
...
@@ -457,6 +460,7 @@ func (asw *actualStateOfWorld) updateNodeStatusUpdateNeeded(nodeName types.NodeN
"Failed to set statusUpdateNeeded to needed %t because nodeName=%q does not exist"
,
"Failed to set statusUpdateNeeded to needed %t because nodeName=%q does not exist"
,
needed
,
needed
,
nodeName
)
nodeName
)
return
}
}
nodeToUpdate
.
statusUpdateNeeded
=
needed
nodeToUpdate
.
statusUpdateNeeded
=
needed
...
@@ -591,6 +595,10 @@ func (asw *actualStateOfWorld) GetVolumesToReportAttached() map[types.NodeName][
...
@@ -591,6 +595,10 @@ func (asw *actualStateOfWorld) GetVolumesToReportAttached() map[types.NodeName][
return
volumesToReportAttached
return
volumesToReportAttached
}
}
func
(
asw
*
actualStateOfWorld
)
GetNodesToUpdateStatusFor
()
map
[
types
.
NodeName
]
nodeToUpdateStatusFor
{
return
asw
.
nodesToUpdateStatusFor
}
func
getAttachedVolume
(
func
getAttachedVolume
(
attachedVolume
*
attachedVolume
,
attachedVolume
*
attachedVolume
,
nodeAttachedTo
*
nodeAttachedTo
)
AttachedVolume
{
nodeAttachedTo
*
nodeAttachedTo
)
AttachedVolume
{
...
...
pkg/controller/volume/attachdetach/cache/actual_state_of_world_test.go
View file @
638ef1b9
...
@@ -1094,6 +1094,25 @@ func Test_OneVolumeTwoNodes_TwoDevicePaths(t *testing.T) {
...
@@ -1094,6 +1094,25 @@ func Test_OneVolumeTwoNodes_TwoDevicePaths(t *testing.T) {
verifyAttachedVolume
(
t
,
attachedVolumes
,
generatedVolumeName2
,
string
(
volumeName
),
node2Name
,
devicePath2
,
true
/* expectedMountedByNode */
,
false
/* expectNonZeroDetachRequestedTime */
)
verifyAttachedVolume
(
t
,
attachedVolumes
,
generatedVolumeName2
,
string
(
volumeName
),
node2Name
,
devicePath2
,
true
/* expectedMountedByNode */
,
false
/* expectNonZeroDetachRequestedTime */
)
}
}
// Test_SetNodeStatusUpdateNeededError expects the map nodesToUpdateStatusFor
// to be empty if the SetNodeStatusUpdateNeeded is called on a node that
// does not exist in the actual state of the world
func
Test_SetNodeStatusUpdateNeededError
(
t
*
testing
.
T
)
{
// Arrange
volumePluginMgr
,
_
:=
volumetesting
.
GetTestVolumePluginMgr
(
t
)
asw
:=
NewActualStateOfWorld
(
volumePluginMgr
)
nodeName
:=
types
.
NodeName
(
"node-1"
)
// Act
asw
.
SetNodeStatusUpdateNeeded
(
nodeName
)
// Assert
nodesToUpdateStatusFor
:=
asw
.
GetNodesToUpdateStatusFor
()
if
len
(
nodesToUpdateStatusFor
)
!=
0
{
t
.
Fatalf
(
"nodesToUpdateStatusFor should be empty as nodeName does not exist"
)
}
}
func
verifyAttachedVolume
(
func
verifyAttachedVolume
(
t
*
testing
.
T
,
t
*
testing
.
T
,
attachedVolumes
[]
AttachedVolume
,
attachedVolumes
[]
AttachedVolume
,
...
...
pkg/controller/volume/attachdetach/statusupdater/node_status_updater.go
View file @
638ef1b9
...
@@ -59,6 +59,8 @@ type nodeStatusUpdater struct {
...
@@ -59,6 +59,8 @@ type nodeStatusUpdater struct {
}
}
func
(
nsu
*
nodeStatusUpdater
)
UpdateNodeStatuses
()
error
{
func
(
nsu
*
nodeStatusUpdater
)
UpdateNodeStatuses
()
error
{
// TODO: investigate right behavior if nodeName is empty
// kubernetes/kubernetes/issues/37777
nodesToUpdate
:=
nsu
.
actualStateOfWorld
.
GetVolumesToReportAttached
()
nodesToUpdate
:=
nsu
.
actualStateOfWorld
.
GetVolumesToReportAttached
()
for
nodeName
,
attachedVolumes
:=
range
nodesToUpdate
{
for
nodeName
,
attachedVolumes
:=
range
nodesToUpdate
{
nodeObj
,
exists
,
err
:=
nsu
.
nodeInformer
.
GetStore
()
.
GetByKey
(
string
(
nodeName
))
nodeObj
,
exists
,
err
:=
nsu
.
nodeInformer
.
GetStore
()
.
GetByKey
(
string
(
nodeName
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment