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
28088159
Commit
28088159
authored
Dec 09, 2016
by
Humble Chirammal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make iscsi pv claim aware of nodiskconflict feature.
Being ISCSI a RWO/ROX volumes it should inherit nodiskconflict feature. Signed-off-by:
Humble Chirammal
<
hchiramm@redhat.com
>
parent
f5f109ca
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
1 deletion
+82
-1
predicates.go
plugin/pkg/scheduler/algorithm/predicates/predicates.go
+23
-1
predicates_test.go
plugin/pkg/scheduler/algorithm/predicates/predicates_test.go
+59
-0
No files found.
plugin/pkg/scheduler/algorithm/predicates/predicates.go
View file @
28088159
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"fmt"
"fmt"
"math/rand"
"math/rand"
"strconv"
"strconv"
"strings"
"sync"
"sync"
"time"
"time"
...
@@ -109,7 +110,7 @@ type predicateMetadata struct {
...
@@ -109,7 +110,7 @@ type predicateMetadata struct {
func
isVolumeConflict
(
volume
v1
.
Volume
,
pod
*
v1
.
Pod
)
bool
{
func
isVolumeConflict
(
volume
v1
.
Volume
,
pod
*
v1
.
Pod
)
bool
{
// fast path if there is no conflict checking targets.
// fast path if there is no conflict checking targets.
if
volume
.
GCEPersistentDisk
==
nil
&&
volume
.
AWSElasticBlockStore
==
nil
&&
volume
.
RBD
==
nil
{
if
volume
.
GCEPersistentDisk
==
nil
&&
volume
.
AWSElasticBlockStore
==
nil
&&
volume
.
RBD
==
nil
&&
volume
.
ISCSI
==
nil
{
return
false
return
false
}
}
...
@@ -128,6 +129,26 @@ func isVolumeConflict(volume v1.Volume, pod *v1.Pod) bool {
...
@@ -128,6 +129,26 @@ func isVolumeConflict(volume v1.Volume, pod *v1.Pod) bool {
}
}
}
}
if
volume
.
ISCSI
!=
nil
&&
existingVolume
.
ISCSI
!=
nil
{
iqn
,
lun
,
target
:=
volume
.
ISCSI
.
IQN
,
volume
.
ISCSI
.
Lun
,
volume
.
ISCSI
.
TargetPortal
eiqn
,
elun
,
etarget
:=
existingVolume
.
ISCSI
.
IQN
,
existingVolume
.
ISCSI
.
Lun
,
existingVolume
.
ISCSI
.
TargetPortal
if
!
strings
.
Contains
(
target
,
":"
)
{
target
=
target
+
":3260"
}
if
!
strings
.
Contains
(
etarget
,
":"
)
{
etarget
=
etarget
+
":3260"
}
lun1
:=
strconv
.
Itoa
(
int
(
lun
))
elun1
:=
strconv
.
Itoa
(
int
(
elun
))
// two ISCSI volumes are same, if they share the same iqn, lun and target. As iscsi volumes are of type
// RWO or ROX, we could permit only one RW mount. Same iscsi volume mounted by multiple Pods
// conflict unless all other pods mount as read only.
if
iqn
==
eiqn
&&
lun1
==
elun1
&&
target
==
etarget
&&
!
(
volume
.
ISCSI
.
ReadOnly
&&
existingVolume
.
ISCSI
.
ReadOnly
)
{
return
true
}
}
if
volume
.
RBD
!=
nil
&&
existingVolume
.
RBD
!=
nil
{
if
volume
.
RBD
!=
nil
&&
existingVolume
.
RBD
!=
nil
{
mon
,
pool
,
image
:=
volume
.
RBD
.
CephMonitors
,
volume
.
RBD
.
RBDPool
,
volume
.
RBD
.
RBDImage
mon
,
pool
,
image
:=
volume
.
RBD
.
CephMonitors
,
volume
.
RBD
.
RBDPool
,
volume
.
RBD
.
RBDImage
emon
,
epool
,
eimage
:=
existingVolume
.
RBD
.
CephMonitors
,
existingVolume
.
RBD
.
RBDPool
,
existingVolume
.
RBD
.
RBDImage
emon
,
epool
,
eimage
:=
existingVolume
.
RBD
.
CephMonitors
,
existingVolume
.
RBD
.
RBDPool
,
existingVolume
.
RBD
.
RBDImage
...
@@ -150,6 +171,7 @@ func isVolumeConflict(volume v1.Volume, pod *v1.Pod) bool {
...
@@ -150,6 +171,7 @@ func isVolumeConflict(volume v1.Volume, pod *v1.Pod) bool {
// - GCE PD allows multiple mounts as long as they're all read-only
// - GCE PD allows multiple mounts as long as they're all read-only
// - AWS EBS forbids any two pods mounting the same volume ID
// - AWS EBS forbids any two pods mounting the same volume ID
// - Ceph RBD forbids if any two pods share at least same monitor, and match pool and image.
// - Ceph RBD forbids if any two pods share at least same monitor, and match pool and image.
// - ISCSI forbids if any two pods share at least same IQN, LUN and Target
// TODO: migrate this into some per-volume specific code?
// TODO: migrate this into some per-volume specific code?
func
NoDiskConflict
(
pod
*
v1
.
Pod
,
meta
interface
{},
nodeInfo
*
schedulercache
.
NodeInfo
)
(
bool
,
[]
algorithm
.
PredicateFailureReason
,
error
)
{
func
NoDiskConflict
(
pod
*
v1
.
Pod
,
meta
interface
{},
nodeInfo
*
schedulercache
.
NodeInfo
)
(
bool
,
[]
algorithm
.
PredicateFailureReason
,
error
)
{
for
_
,
v
:=
range
pod
.
Spec
.
Volumes
{
for
_
,
v
:=
range
pod
.
Spec
.
Volumes
{
...
...
plugin/pkg/scheduler/algorithm/predicates/predicates_test.go
View file @
28088159
...
@@ -738,6 +738,65 @@ func TestRBDDiskConflicts(t *testing.T) {
...
@@ -738,6 +738,65 @@ func TestRBDDiskConflicts(t *testing.T) {
}
}
}
}
func
TestISCSIDiskConflicts
(
t
*
testing
.
T
)
{
volState
:=
v1
.
PodSpec
{
Volumes
:
[]
v1
.
Volume
{
{
VolumeSource
:
v1
.
VolumeSource
{
ISCSI
:
&
v1
.
ISCSIVolumeSource
{
TargetPortal
:
"127.0.0.1:3260"
,
IQN
:
"iqn.2014-12.server:storage.target01"
,
FSType
:
"ext4"
,
Lun
:
0
,
},
},
},
},
}
volState2
:=
v1
.
PodSpec
{
Volumes
:
[]
v1
.
Volume
{
{
VolumeSource
:
v1
.
VolumeSource
{
ISCSI
:
&
v1
.
ISCSIVolumeSource
{
TargetPortal
:
"127.0.0.2:3260"
,
IQN
:
"iqn.2014-12.server:storage.target01"
,
FSType
:
"ext4"
,
Lun
:
1
,
},
},
},
},
}
tests
:=
[]
struct
{
pod
*
v1
.
Pod
nodeInfo
*
schedulercache
.
NodeInfo
isOk
bool
test
string
}{
{
&
v1
.
Pod
{},
schedulercache
.
NewNodeInfo
(),
true
,
"nothing"
},
{
&
v1
.
Pod
{},
schedulercache
.
NewNodeInfo
(
&
v1
.
Pod
{
Spec
:
volState
}),
true
,
"one state"
},
{
&
v1
.
Pod
{
Spec
:
volState
},
schedulercache
.
NewNodeInfo
(
&
v1
.
Pod
{
Spec
:
volState
}),
false
,
"same state"
},
{
&
v1
.
Pod
{
Spec
:
volState2
},
schedulercache
.
NewNodeInfo
(
&
v1
.
Pod
{
Spec
:
volState
}),
true
,
"different state"
},
}
expectedFailureReasons
:=
[]
algorithm
.
PredicateFailureReason
{
ErrDiskConflict
}
for
_
,
test
:=
range
tests
{
ok
,
reasons
,
err
:=
NoDiskConflict
(
test
.
pod
,
PredicateMetadata
(
test
.
pod
,
nil
),
test
.
nodeInfo
)
if
err
!=
nil
{
t
.
Errorf
(
"%s: unexpected error: %v"
,
test
.
test
,
err
)
}
if
!
ok
&&
!
reflect
.
DeepEqual
(
reasons
,
expectedFailureReasons
)
{
t
.
Errorf
(
"%s: unexpected failure reasons: %v, want: %v"
,
test
.
test
,
reasons
,
expectedFailureReasons
)
}
if
test
.
isOk
&&
!
ok
{
t
.
Errorf
(
"%s: expected ok, got none. %v %s %s"
,
test
.
test
,
test
.
pod
,
test
.
nodeInfo
,
test
.
test
)
}
if
!
test
.
isOk
&&
ok
{
t
.
Errorf
(
"%s: expected no ok, got one. %v %s %s"
,
test
.
test
,
test
.
pod
,
test
.
nodeInfo
,
test
.
test
)
}
}
}
func
TestPodFitsSelector
(
t
*
testing
.
T
)
{
func
TestPodFitsSelector
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
pod
*
v1
.
Pod
pod
*
v1
.
Pod
...
...
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