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
07bc06ba
Commit
07bc06ba
authored
Jun 10, 2016
by
Abhishek Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Counting pod volume towards PV limit even if PV/PVC is missing
parent
8bcecac1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
3 deletions
+77
-3
predicates.go
plugin/pkg/scheduler/algorithm/predicates/predicates.go
+18
-2
predicates_test.go
plugin/pkg/scheduler/algorithm/predicates/predicates_test.go
+59
-1
No files found.
plugin/pkg/scheduler/algorithm/predicates/predicates.go
View file @
07bc06ba
...
...
@@ -18,6 +18,9 @@ package predicates
import
(
"fmt"
"math/rand"
"strconv"
"time"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
...
...
@@ -156,7 +159,13 @@ func (c *MaxPDVolumeCountChecker) filterVolumes(volumes []api.Volume, namespace
}
pvc
,
err
:=
c
.
pvcInfo
.
GetPersistentVolumeClaimInfo
(
namespace
,
pvcName
)
if
err
!=
nil
{
return
err
// if the PVC is not found, log the error and count the PV towards the PV limit
// generate a random volume ID since its required for de-dup
glog
.
Error
(
err
)
source
:=
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
())
generatedID
:=
"missingPVC"
+
strconv
.
Itoa
(
rand
.
New
(
source
)
.
Intn
(
1000000
))
filteredVolumes
[
generatedID
]
=
true
return
nil
}
pvName
:=
pvc
.
Spec
.
VolumeName
...
...
@@ -166,7 +175,14 @@ func (c *MaxPDVolumeCountChecker) filterVolumes(volumes []api.Volume, namespace
pv
,
err
:=
c
.
pvInfo
.
GetPersistentVolumeInfo
(
pvName
)
if
err
!=
nil
{
return
err
// if the PV is not found, log the error
// and count the PV towards the PV limit
// generate a random volume ID since its required for de-dup
glog
.
Error
(
err
)
source
:=
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
())
generatedID
:=
"missingPV"
+
strconv
.
Itoa
(
rand
.
New
(
source
)
.
Intn
(
1000000
))
filteredVolumes
[
generatedID
]
=
true
return
nil
}
if
id
,
ok
:=
c
.
filter
.
FilterPersistentVolume
(
pv
);
ok
{
...
...
plugin/pkg/scheduler/algorithm/predicates/predicates_test.go
View file @
07bc06ba
...
...
@@ -1392,6 +1392,32 @@ func TestEBSVolumeCountConflicts(t *testing.T) {
},
},
}
deletedPVCPod
:=
&
api
.
Pod
{
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{
{
VolumeSource
:
api
.
VolumeSource
{
PersistentVolumeClaim
:
&
api
.
PersistentVolumeClaimVolumeSource
{
ClaimName
:
"deletedPVC"
,
},
},
},
},
},
}
deletedPVPod
:=
&
api
.
Pod
{
Spec
:
api
.
PodSpec
{
Volumes
:
[]
api
.
Volume
{
{
VolumeSource
:
api
.
VolumeSource
{
PersistentVolumeClaim
:
&
api
.
PersistentVolumeClaimVolumeSource
{
ClaimName
:
"deletedPV"
,
},
},
},
},
},
}
emptyPod
:=
&
api
.
Pod
{
Spec
:
api
.
PodSpec
{},
}
...
...
@@ -1466,6 +1492,34 @@ func TestEBSVolumeCountConflicts(t *testing.T) {
fits
:
true
,
test
:
"the same EBS volumes are not counted multiple times"
,
},
{
newPod
:
ebsPVCPod
,
existingPods
:
[]
*
api
.
Pod
{
oneVolPod
,
deletedPVCPod
},
maxVols
:
2
,
fits
:
false
,
test
:
"pod with missing PVC is counted towards the PV limit"
,
},
{
newPod
:
ebsPVCPod
,
existingPods
:
[]
*
api
.
Pod
{
oneVolPod
,
deletedPVCPod
},
maxVols
:
3
,
fits
:
true
,
test
:
"pod with missing PVC is counted towards the PV limit"
,
},
{
newPod
:
ebsPVCPod
,
existingPods
:
[]
*
api
.
Pod
{
oneVolPod
,
deletedPVPod
},
maxVols
:
2
,
fits
:
false
,
test
:
"pod with missing PV is counted towards the PV limit"
,
},
{
newPod
:
ebsPVCPod
,
existingPods
:
[]
*
api
.
Pod
{
oneVolPod
,
deletedPVPod
},
maxVols
:
3
,
fits
:
true
,
test
:
"pod with missing PV is counted towards the PV limit"
,
},
}
pvInfo
:=
FakePersistentVolumeInfo
{
...
...
@@ -1473,7 +1527,7 @@ func TestEBSVolumeCountConflicts(t *testing.T) {
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"someEBSVol"
},
Spec
:
api
.
PersistentVolumeSpec
{
PersistentVolumeSource
:
api
.
PersistentVolumeSource
{
AWSElasticBlockStore
:
&
api
.
AWSElasticBlockStoreVolumeSource
{},
AWSElasticBlockStore
:
&
api
.
AWSElasticBlockStoreVolumeSource
{
VolumeID
:
"ebsVol"
},
},
},
},
...
...
@@ -1494,6 +1548,10 @@ func TestEBSVolumeCountConflicts(t *testing.T) {
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"someNonEBSVol"
},
Spec
:
api
.
PersistentVolumeClaimSpec
{
VolumeName
:
"someNonEBSVol"
},
},
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"deletedPV"
},
Spec
:
api
.
PersistentVolumeClaimSpec
{
VolumeName
:
"deletedPV"
},
},
}
filter
:=
VolumeFilter
{
...
...
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