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
fa6b62fa
Commit
fa6b62fa
authored
Nov 08, 2017
by
Michelle Au
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Library for scheduler volume binding
parent
b49a1ce1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
0 deletions
+74
-0
framework_test.go
pkg/controller/volume/persistentvolume/framework_test.go
+11
-0
scheduler_binder.go
pkg/controller/volume/persistentvolume/scheduler_binder.go
+0
-0
scheduler_binder_fake.go
...ntroller/volume/persistentvolume/scheduler_binder_fake.go
+63
-0
scheduler_binder_test.go
...ntroller/volume/persistentvolume/scheduler_binder_test.go
+0
-0
No files found.
pkg/controller/volume/persistentvolume/framework_test.go
View file @
fa6b62fa
...
...
@@ -196,6 +196,8 @@ func (r *volumeReactor) React(action core.Action) (handled bool, ret runtime.Obj
if
storedVer
!=
requestedVer
{
return
true
,
obj
,
versionConflictError
}
// Don't modify the existing object
volume
=
volume
.
DeepCopy
()
volume
.
ResourceVersion
=
strconv
.
Itoa
(
storedVer
+
1
)
}
else
{
return
true
,
nil
,
fmt
.
Errorf
(
"Cannot update volume %s: volume not found"
,
volume
.
Name
)
...
...
@@ -220,6 +222,8 @@ func (r *volumeReactor) React(action core.Action) (handled bool, ret runtime.Obj
if
storedVer
!=
requestedVer
{
return
true
,
obj
,
versionConflictError
}
// Don't modify the existing object
claim
=
claim
.
DeepCopy
()
claim
.
ResourceVersion
=
strconv
.
Itoa
(
storedVer
+
1
)
}
else
{
return
true
,
nil
,
fmt
.
Errorf
(
"Cannot update claim %s: claim not found"
,
claim
.
Name
)
...
...
@@ -301,7 +305,12 @@ func (r *volumeReactor) checkVolumes(expectedVolumes []*v1.PersistentVolume) err
gotMap
:=
make
(
map
[
string
]
*
v1
.
PersistentVolume
)
// Clear any ResourceVersion from both sets
for
_
,
v
:=
range
expectedVolumes
{
// Don't modify the existing object
v
:=
v
.
DeepCopy
()
v
.
ResourceVersion
=
""
if
v
.
Spec
.
ClaimRef
!=
nil
{
v
.
Spec
.
ClaimRef
.
ResourceVersion
=
""
}
expectedMap
[
v
.
Name
]
=
v
}
for
_
,
v
:=
range
r
.
volumes
{
...
...
@@ -331,6 +340,8 @@ func (r *volumeReactor) checkClaims(expectedClaims []*v1.PersistentVolumeClaim)
expectedMap
:=
make
(
map
[
string
]
*
v1
.
PersistentVolumeClaim
)
gotMap
:=
make
(
map
[
string
]
*
v1
.
PersistentVolumeClaim
)
for
_
,
c
:=
range
expectedClaims
{
// Don't modify the existing object
c
=
c
.
DeepCopy
()
c
.
ResourceVersion
=
""
expectedMap
[
c
.
Name
]
=
c
}
...
...
pkg/controller/volume/persistentvolume/scheduler_binder.go
0 → 100644
View file @
fa6b62fa
This diff is collapsed.
Click to expand it.
pkg/controller/volume/persistentvolume/scheduler_binder_fake.go
0 → 100644
View file @
fa6b62fa
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
persistentvolume
import
(
"k8s.io/api/core/v1"
)
type
FakeVolumeBinderConfig
struct
{
AllBound
bool
FindUnboundSatsified
bool
FindBoundSatsified
bool
FindErr
error
AssumeBindingRequired
bool
AssumeErr
error
BindErr
error
}
// NewVolumeBinder sets up all the caches needed for the scheduler to make
// topology-aware volume binding decisions.
func
NewFakeVolumeBinder
(
config
*
FakeVolumeBinderConfig
)
*
FakeVolumeBinder
{
return
&
FakeVolumeBinder
{
config
:
config
,
}
}
type
FakeVolumeBinder
struct
{
config
*
FakeVolumeBinderConfig
AssumeCalled
bool
BindCalled
bool
}
func
(
b
*
FakeVolumeBinder
)
FindPodVolumes
(
pod
*
v1
.
Pod
,
nodeName
string
)
(
unboundVolumesSatisfied
,
boundVolumesSatsified
bool
,
err
error
)
{
return
b
.
config
.
FindUnboundSatsified
,
b
.
config
.
FindBoundSatsified
,
b
.
config
.
FindErr
}
func
(
b
*
FakeVolumeBinder
)
AssumePodVolumes
(
assumedPod
*
v1
.
Pod
,
nodeName
string
)
(
bool
,
bool
,
error
)
{
b
.
AssumeCalled
=
true
return
b
.
config
.
AllBound
,
b
.
config
.
AssumeBindingRequired
,
b
.
config
.
AssumeErr
}
func
(
b
*
FakeVolumeBinder
)
BindPodVolumes
(
assumedPod
*
v1
.
Pod
)
error
{
b
.
BindCalled
=
true
return
b
.
config
.
BindErr
}
func
(
b
*
FakeVolumeBinder
)
GetBindingsCache
()
PodBindingCache
{
return
nil
}
pkg/controller/volume/persistentvolume/scheduler_binder_test.go
0 → 100644
View file @
fa6b62fa
This diff is collapsed.
Click to expand it.
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