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
e1241599
Commit
e1241599
authored
Sep 04, 2018
by
Michelle Au
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add scheduler option for bind timeout
parent
8fcbcafc
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
51 additions
and
7 deletions
+51
-7
options_test.go
cmd/kube-scheduler/app/options/options_test.go
+7
-1
server.go
cmd/kube-scheduler/app/server.go
+1
-0
types.go
pkg/scheduler/apis/config/types.go
+5
-0
defaults.go
pkg/scheduler/apis/config/v1alpha1/defaults.go
+6
-0
validation.go
pkg/scheduler/apis/config/validation/validation.go
+3
-0
validation_test.go
pkg/scheduler/apis/config/validation/validation_test.go
+12
-2
factory.go
pkg/scheduler/factory/factory.go
+2
-1
factory_test.go
pkg/scheduler/factory/factory_test.go
+2
-0
volume_binder.go
pkg/scheduler/volumebinder/volume_binder.go
+3
-3
types.go
staging/src/k8s.io/kube-scheduler/config/v1alpha1/types.go
+5
-0
scheduler_test.go
test/integration/scheduler/scheduler_test.go
+4
-0
util.go
test/integration/scheduler/util.go
+1
-0
No files found.
cmd/kube-scheduler/app/options/options_test.go
View file @
e1241599
...
...
@@ -144,6 +144,7 @@ users:
}
defaultSource
:=
"DefaultProvider"
defaultBindTimeoutSeconds
:=
int64
(
600
)
testcases
:=
[]
struct
{
name
string
...
...
@@ -157,7 +158,10 @@ users:
options
:
&
Options
{
ConfigFile
:
configFile
,
ComponentConfig
:
func
()
kubeschedulerconfig
.
KubeSchedulerConfiguration
{
cfg
,
_
:=
newDefaultComponentConfig
()
cfg
,
err
:=
newDefaultComponentConfig
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
return
*
cfg
}(),
},
...
...
@@ -187,6 +191,7 @@ users:
ContentType
:
"application/vnd.kubernetes.protobuf"
,
},
PercentageOfNodesToScore
:
50
,
BindTimeoutSeconds
:
&
defaultBindTimeoutSeconds
,
},
},
{
...
...
@@ -229,6 +234,7 @@ users:
ContentType
:
"application/vnd.kubernetes.protobuf"
,
},
PercentageOfNodesToScore
:
50
,
BindTimeoutSeconds
:
&
defaultBindTimeoutSeconds
,
},
},
{
...
...
cmd/kube-scheduler/app/server.go
View file @
e1241599
...
...
@@ -305,6 +305,7 @@ func NewSchedulerConfig(s schedulerserverconfig.CompletedConfig) (*scheduler.Con
EnableEquivalenceClassCache
:
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
EnableEquivalenceClassCache
),
DisablePreemption
:
s
.
ComponentConfig
.
DisablePreemption
,
PercentageOfNodesToScore
:
s
.
ComponentConfig
.
PercentageOfNodesToScore
,
BindTimeoutSeconds
:
*
s
.
ComponentConfig
.
BindTimeoutSeconds
,
})
source
:=
s
.
ComponentConfig
.
AlgorithmSource
...
...
pkg/scheduler/apis/config/types.go
View file @
e1241599
...
...
@@ -85,6 +85,11 @@ type KubeSchedulerConfiguration struct {
// DEPRECATED.
// Indicate the "all topologies" set for empty topologyKey when it's used for PreferredDuringScheduling pod anti-affinity.
FailureDomains
string
// Duration to wait for a binding operation to complete before timing out
// Value must be non-negative integer. The value zero indicates no waiting.
// If this value is nil, the default value will be used.
BindTimeoutSeconds
*
int64
}
// SchedulerAlgorithmSource is the source of a scheduler algorithm. One source
...
...
pkg/scheduler/apis/config/v1alpha1/defaults.go
View file @
e1241599
...
...
@@ -23,6 +23,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
apiserverconfigv1alpha1
"k8s.io/apiserver/pkg/apis/config/v1alpha1"
kubescedulerconfigv1alpha1
"k8s.io/kube-scheduler/config/v1alpha1"
// this package shouldn't really depend on other k8s.io/kubernetes code
api
"k8s.io/kubernetes/pkg/apis/core"
kubeletapis
"k8s.io/kubernetes/pkg/kubelet/apis"
...
...
@@ -102,4 +103,9 @@ func SetDefaults_KubeSchedulerConfiguration(obj *kubescedulerconfigv1alpha1.Kube
// Use the default LeaderElectionConfiguration options
apiserverconfigv1alpha1
.
RecommendedDefaultLeaderElectionConfiguration
(
&
obj
.
LeaderElection
.
LeaderElectionConfiguration
)
if
obj
.
BindTimeoutSeconds
==
nil
{
defaultBindTimeoutSeconds
:=
int64
(
600
)
obj
.
BindTimeoutSeconds
=
&
defaultBindTimeoutSeconds
}
}
pkg/scheduler/apis/config/validation/validation.go
View file @
e1241599
...
...
@@ -41,6 +41,9 @@ func ValidateKubeSchedulerConfiguration(cc *config.KubeSchedulerConfiguration) f
if
cc
.
HardPodAffinitySymmetricWeight
<
0
||
cc
.
HardPodAffinitySymmetricWeight
>
100
{
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
field
.
NewPath
(
"hardPodAffinitySymmetricWeight"
),
cc
.
HardPodAffinitySymmetricWeight
,
"not in valid range 0-100"
))
}
if
cc
.
BindTimeoutSeconds
==
nil
{
allErrs
=
append
(
allErrs
,
field
.
Required
(
field
.
NewPath
(
"bindTimeoutSeconds"
),
""
))
}
return
allErrs
}
...
...
pkg/scheduler/apis/config/validation/validation_test.go
View file @
e1241599
...
...
@@ -17,15 +17,17 @@ limitations under the License.
package
validation
import
(
"testing"
"time"
apimachinery
"k8s.io/apimachinery/pkg/apis/config"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
apiserver
"k8s.io/apiserver/pkg/apis/config"
"k8s.io/kubernetes/pkg/scheduler/apis/config"
"testing"
"time"
)
func
TestValidateKubeSchedulerConfiguration
(
t
*
testing
.
T
)
{
testTimeout
:=
int64
(
0
)
validConfig
:=
&
config
.
KubeSchedulerConfiguration
{
SchedulerName
:
"me"
,
HealthzBindAddress
:
"0.0.0.0:10254"
,
...
...
@@ -56,6 +58,7 @@ func TestValidateKubeSchedulerConfiguration(t *testing.T) {
RetryPeriod
:
metav1
.
Duration
{
Duration
:
5
*
time
.
Second
},
},
},
BindTimeoutSeconds
:
&
testTimeout
,
}
HardPodAffinitySymmetricWeightGt100
:=
validConfig
.
DeepCopy
()
...
...
@@ -86,6 +89,9 @@ func TestValidateKubeSchedulerConfiguration(t *testing.T) {
enableContentProfilingSetWithoutEnableProfiling
.
EnableProfiling
=
false
enableContentProfilingSetWithoutEnableProfiling
.
EnableContentionProfiling
=
true
bindTimeoutUnset
:=
validConfig
.
DeepCopy
()
bindTimeoutUnset
.
BindTimeoutSeconds
=
nil
scenarios
:=
map
[
string
]
struct
{
expectedToFail
bool
config
*
config
.
KubeSchedulerConfiguration
...
...
@@ -126,6 +132,10 @@ func TestValidateKubeSchedulerConfiguration(t *testing.T) {
expectedToFail
:
true
,
config
:
HardPodAffinitySymmetricWeightLt0
,
},
"bind-timeout-unset"
:
{
expectedToFail
:
true
,
config
:
bindTimeoutUnset
,
},
}
for
name
,
scenario
:=
range
scenarios
{
...
...
pkg/scheduler/factory/factory.go
View file @
e1241599
...
...
@@ -159,6 +159,7 @@ type ConfigFactoryArgs struct {
EnableEquivalenceClassCache
bool
DisablePreemption
bool
PercentageOfNodesToScore
int32
BindTimeoutSeconds
int64
}
// NewConfigFactory initializes the default implementation of a Configurator To encourage eventual privatization of the struct type, we only
...
...
@@ -305,7 +306,7 @@ func NewConfigFactory(args *ConfigFactoryArgs) scheduler.Configurator {
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeScheduling
)
{
// Setup volume binder
c
.
volumeBinder
=
volumebinder
.
NewVolumeBinder
(
args
.
Client
,
args
.
PvcInformer
,
args
.
PvInformer
,
args
.
StorageClassInformer
)
c
.
volumeBinder
=
volumebinder
.
NewVolumeBinder
(
args
.
Client
,
args
.
PvcInformer
,
args
.
PvInformer
,
args
.
StorageClassInformer
,
time
.
Duration
(
args
.
BindTimeoutSeconds
)
*
time
.
Second
)
args
.
StorageClassInformer
.
Informer
()
.
AddEventHandler
(
cache
.
ResourceEventHandlerFuncs
{
...
...
pkg/scheduler/factory/factory_test.go
View file @
e1241599
...
...
@@ -49,6 +49,7 @@ import (
const
(
enableEquivalenceCache
=
true
disablePodPreemption
=
false
bindTimeoutSeconds
=
600
)
func
TestCreate
(
t
*
testing
.
T
)
{
...
...
@@ -557,6 +558,7 @@ func newConfigFactory(client *clientset.Clientset, hardPodAffinitySymmetricWeigh
enableEquivalenceCache
,
disablePodPreemption
,
schedulerapi
.
DefaultPercentageOfNodesToScore
,
bindTimeoutSeconds
,
})
}
...
...
pkg/scheduler/volumebinder/volume_binder.go
View file @
e1241599
...
...
@@ -36,11 +36,11 @@ func NewVolumeBinder(
client
clientset
.
Interface
,
pvcInformer
coreinformers
.
PersistentVolumeClaimInformer
,
pvInformer
coreinformers
.
PersistentVolumeInformer
,
storageClassInformer
storageinformers
.
StorageClassInformer
)
*
VolumeBinder
{
storageClassInformer
storageinformers
.
StorageClassInformer
,
bindTimeout
time
.
Duration
)
*
VolumeBinder
{
return
&
VolumeBinder
{
// TODO: what is a good bind timeout value?
Binder
:
persistentvolume
.
NewVolumeBinder
(
client
,
pvcInformer
,
pvInformer
,
storageClassInformer
,
10
*
time
.
Minute
),
Binder
:
persistentvolume
.
NewVolumeBinder
(
client
,
pvcInformer
,
pvInformer
,
storageClassInformer
,
bindTimeout
),
}
}
...
...
staging/src/k8s.io/kube-scheduler/config/v1alpha1/types.go
View file @
e1241599
...
...
@@ -81,6 +81,11 @@ type KubeSchedulerConfiguration struct {
// DEPRECATED.
// Indicate the "all topologies" set for empty topologyKey when it's used for PreferredDuringScheduling pod anti-affinity.
FailureDomains
string
`json:"failureDomains"`
// Duration to wait for a binding operation to complete before timing out
// Value must be non-negative integer. The value zero indicates no waiting.
// If this value is nil, the default value will be used.
BindTimeoutSeconds
*
int64
`json:"bindTimeoutSeconds"`
}
// SchedulerAlgorithmSource is the source of a scheduler algorithm. One source
...
...
test/integration/scheduler/scheduler_test.go
View file @
e1241599
...
...
@@ -183,6 +183,7 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) {
eventBroadcaster
:=
record
.
NewBroadcaster
()
eventBroadcaster
.
StartRecordingToSink
(
&
clientv1core
.
EventSinkImpl
{
Interface
:
clientSet
.
CoreV1
()
.
Events
(
""
)})
defaultBindTimeout
:=
int64
(
30
)
ss
:=
&
schedulerappconfig
.
Config
{
ComponentConfig
:
kubeschedulerconfig
.
KubeSchedulerConfiguration
{
HardPodAffinitySymmetricWeight
:
v1
.
DefaultHardPodAffinitySymmetricWeight
,
...
...
@@ -195,6 +196,7 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) {
},
},
},
BindTimeoutSeconds
:
&
defaultBindTimeout
,
},
Client
:
clientSet
,
InformerFactory
:
informerFactory
,
...
...
@@ -244,6 +246,7 @@ func TestSchedulerCreationFromNonExistentConfigMap(t *testing.T) {
eventBroadcaster
:=
record
.
NewBroadcaster
()
eventBroadcaster
.
StartRecordingToSink
(
&
clientv1core
.
EventSinkImpl
{
Interface
:
clientSet
.
CoreV1
()
.
Events
(
""
)})
defaultBindTimeout
:=
int64
(
30
)
ss
:=
&
schedulerappconfig
.
Config
{
ComponentConfig
:
kubeschedulerconfig
.
KubeSchedulerConfiguration
{
SchedulerName
:
v1
.
DefaultSchedulerName
,
...
...
@@ -256,6 +259,7 @@ func TestSchedulerCreationFromNonExistentConfigMap(t *testing.T) {
},
},
HardPodAffinitySymmetricWeight
:
v1
.
DefaultHardPodAffinitySymmetricWeight
,
BindTimeoutSeconds
:
&
defaultBindTimeout
,
},
Client
:
clientSet
,
InformerFactory
:
informerFactory
,
...
...
test/integration/scheduler/util.go
View file @
e1241599
...
...
@@ -91,6 +91,7 @@ func createConfiguratorWithPodInformer(
EnableEquivalenceClassCache
:
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
EnableEquivalenceClassCache
),
DisablePreemption
:
false
,
PercentageOfNodesToScore
:
schedulerapi
.
DefaultPercentageOfNodesToScore
,
BindTimeoutSeconds
:
600
,
})
}
...
...
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