Skip to content

Commit

Permalink
add nodeselector field to builds
Browse files Browse the repository at this point in the history
  • Loading branch information
bparees committed Sep 28, 2016
1 parent bfdf642 commit 1d92117
Show file tree
Hide file tree
Showing 32 changed files with 1,231 additions and 996 deletions.
6 changes: 6 additions & 0 deletions api/swagger-spec/oapi-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -21009,6 +21009,9 @@
"type": "integer",
"format": "int64",
"description": "completionDeadlineSeconds is an optional duration in seconds, counted from the time when a build pod gets scheduled in the system, that the build may be active on a node before the system actively tries to terminate the build; value must be positive integer"
},
"nodeSelector": {
"type": "object"
}
}
},
Expand Down Expand Up @@ -22021,6 +22024,9 @@
"format": "int64",
"description": "completionDeadlineSeconds is an optional duration in seconds, counted from the time when a build pod gets scheduled in the system, that the build may be active on a node before the system actively tries to terminate the build; value must be positive integer"
},
"nodeSelector": {
"type": "object"
},
"triggeredBy": {
"type": "array",
"items": {
Expand Down
214 changes: 108 additions & 106 deletions pkg/authorization/api/v1/generated.pb.go

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions pkg/build/admission/defaults/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ func (a *buildDefaults) applyBuildDefaults(build *buildapi.Build) {
addDefaultEnvVar(envVar, buildEnv)
}

for k, v := range a.defaultsConfig.NodeSelector {
glog.V(5).Infof("Adding default nodeselector %s=%s to build %s/%s", k, v, build.Namespace, build.Name)
addDefaultNodeSelector(k, v, build.Spec.NodeSelector)
}

sourceDefaults := a.defaultsConfig.SourceStrategyDefaults
sourceStrategy := build.Spec.Strategy.SourceStrategy
if sourceDefaults != nil && sourceDefaults.Incremental != nil && *sourceDefaults.Incremental &&
Expand Down Expand Up @@ -141,3 +146,9 @@ func addDefaultEnvVar(v kapi.EnvVar, envVars *[]kapi.EnvVar) {
*envVars = append(*envVars, v)
}
}

func addDefaultNodeSelector(k, v string, selectors map[string]string) {
if _, ok := selectors[k]; !ok {
selectors[k] = v
}
}
3 changes: 3 additions & 0 deletions pkg/build/admission/defaults/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ type BuildDefaultsConfig struct {
// SourceStrategyDefaults are default values that apply to builds using the
// source strategy.
SourceStrategyDefaults *SourceStrategyDefaultsConfig

// NodeSelector is a selector which must be true for the build pod to fit on a node
NodeSelector map[string]string
}

// SourceStrategyDefaultsConfig contains values that apply to builds using the
Expand Down
11 changes: 6 additions & 5 deletions pkg/build/admission/defaults/api/v1/swagger_doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ package v1

var map_BuildDefaultsConfig = map[string]string{
"": "BuildDefaultsConfig controls the default information for Builds",
"gitHTTPProxy": "GitHTTPProxy is the location of the HTTPProxy for Git source",
"gitHTTPSProxy": "GitHTTPSProxy is the location of the HTTPSProxy for Git source",
"env": "Env is a set of default environment variables that will be applied to the build if the specified variables do not exist on the build",
"sourceStrategyDefaults": "SourceStrategyDefaults are default values that apply to builds using the source strategy.",
"gitHTTPProxy": "gitHTTPProxy is the location of the HTTPProxy for Git source",
"gitHTTPSProxy": "gitHTTPSProxy is the location of the HTTPSProxy for Git source",
"env": "env is a set of default environment variables that will be applied to the build if the specified variables do not exist on the build",
"sourceStrategyDefaults": "sourceStrategyDefaults are default values that apply to builds using the source strategy.",
"nodeSelector": "nodeSelector is a selector which must be true for the build pod to fit on a node",
}

func (BuildDefaultsConfig) SwaggerDoc() map[string]string {
Expand All @@ -19,7 +20,7 @@ func (BuildDefaultsConfig) SwaggerDoc() map[string]string {

var map_SourceStrategyDefaultsConfig = map[string]string{
"": "SourceStrategyDefaultsConfig contains values that apply to builds using the source strategy.",
"incremental": "Incremental indicates if s2i build strategies should perform an incremental build or not",
"incremental": "incremental indicates if s2i build strategies should perform an incremental build or not",
}

func (SourceStrategyDefaultsConfig) SwaggerDoc() map[string]string {
Expand Down
13 changes: 8 additions & 5 deletions pkg/build/admission/defaults/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,29 @@ import (
type BuildDefaultsConfig struct {
unversioned.TypeMeta `json:",inline"`

// GitHTTPProxy is the location of the HTTPProxy for Git source
// gitHTTPProxy is the location of the HTTPProxy for Git source
GitHTTPProxy string `json:"gitHTTPProxy,omitempty"`

// GitHTTPSProxy is the location of the HTTPSProxy for Git source
// gitHTTPSProxy is the location of the HTTPSProxy for Git source
GitHTTPSProxy string `json:"gitHTTPSProxy,omitempty"`

// Env is a set of default environment variables that will be applied to the
// env is a set of default environment variables that will be applied to the
// build if the specified variables do not exist on the build
Env []kapi.EnvVar `json:"env,omitempty"`

// SourceStrategyDefaults are default values that apply to builds using the
// sourceStrategyDefaults are default values that apply to builds using the
// source strategy.
SourceStrategyDefaults *SourceStrategyDefaultsConfig `json:"sourceStrategyDefaults,omitempty"`

// nodeSelector is a selector which must be true for the build pod to fit on a node
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}

// SourceStrategyDefaultsConfig contains values that apply to builds using the
// source strategy.
type SourceStrategyDefaultsConfig struct {

// Incremental indicates if s2i build strategies should perform an incremental
// incremental indicates if s2i build strategies should perform an incremental
// build or not
Incremental *bool `json:"incremental,omitempty"`
}
6 changes: 6 additions & 0 deletions pkg/build/admission/overrides/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ func (a *buildOverrides) applyOverrides(attributes admission.Attributes) error {
glog.V(5).Infof("Setting custom strategy ForcePull to true in build %s/%s", build.Namespace, build.Name)
build.Spec.Strategy.CustomStrategy.ForcePull = true
}

for k, v := range a.overridesConfig.NodeSelector {
glog.V(5).Infof("Adding override nodeselector %s=%s to build %s/%s", k, v, build.Namespace, build.Name)
build.Spec.NodeSelector[k] = v
}

return buildadmission.SetBuild(attributes, build, version)
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/build/admission/overrides/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ type BuildOverridesConfig struct {

// ForcePull indicates whether the build strategy should always be set to ForcePull=true
ForcePull bool

// nodeSelector is a selector which must be true for the build pod to fit on a node
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}
5 changes: 3 additions & 2 deletions pkg/build/admission/overrides/api/v1/swagger_doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ package v1
// ==== DO NOT EDIT THIS FILE MANUALLY ====

var map_BuildOverridesConfig = map[string]string{
"": "BuildOverridesConfig controls override settings for builds",
"forcePull": "ForcePull indicates whether the build strategy should always be set to ForcePull=true",
"": "BuildOverridesConfig controls override settings for builds",
"forcePull": "ForcePull indicates whether the build strategy should always be set to ForcePull=true",
"nodeSelector": "nodeSelector is a selector which must be true for the build pod to fit on a node",
}

func (BuildOverridesConfig) SwaggerDoc() map[string]string {
Expand Down
3 changes: 3 additions & 0 deletions pkg/build/admission/overrides/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ type BuildOverridesConfig struct {

// ForcePull indicates whether the build strategy should always be set to ForcePull=true
ForcePull bool `json:"forcePull"`

// nodeSelector is a selector which must be true for the build pod to fit on a node
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}
3 changes: 3 additions & 0 deletions pkg/build/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ type CommonSpec struct {
// be active on a node before the system actively tries to terminate the
// build; value must be positive integer.
CompletionDeadlineSeconds *int64

// NodeSelector is a selector which must be true for the build pod to fit on a node
NodeSelector map[string]string
}

// BuildTriggerCause holds information about a triggered build. It is used for
Expand Down
Loading

0 comments on commit 1d92117

Please sign in to comment.