mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-05 11:28:35 +00:00
Agent-wide node selector (#3608)
Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
This commit is contained in:
@@ -154,7 +154,7 @@ func podSpec(step *types.Step, config *config, options BackendOptions) (v1.PodSp
|
||||
ServiceAccountName: options.ServiceAccountName,
|
||||
ImagePullSecrets: imagePullSecretsReferences(config.ImagePullSecretNames),
|
||||
HostAliases: hostAliases(step.ExtraHosts),
|
||||
NodeSelector: nodeSelector(options.NodeSelector, step.Environment["CI_SYSTEM_PLATFORM"]),
|
||||
NodeSelector: nodeSelector(options.NodeSelector, config.PodNodeSelector, step.Environment["CI_SYSTEM_PLATFORM"]),
|
||||
Tolerations: tolerations(options.Tolerations),
|
||||
SecurityContext: podSecurityContext(options.SecurityContext, config.SecurityContext, step.Privileged),
|
||||
}
|
||||
@@ -331,7 +331,7 @@ func resourceList(resources map[string]string) (v1.ResourceList, error) {
|
||||
return requestResources, nil
|
||||
}
|
||||
|
||||
func nodeSelector(backendNodeSelector map[string]string, platform string) map[string]string {
|
||||
func nodeSelector(backendNodeSelector, configNodeSelector map[string]string, platform string) map[string]string {
|
||||
nodeSelector := make(map[string]string)
|
||||
|
||||
if platform != "" {
|
||||
@@ -340,6 +340,11 @@ func nodeSelector(backendNodeSelector map[string]string, platform string) map[st
|
||||
log.Trace().Msgf("using the node selector from the Agent's platform: %v", nodeSelector)
|
||||
}
|
||||
|
||||
if len(configNodeSelector) > 0 {
|
||||
log.Trace().Msgf("appending labels to the node selector from the configuration: %v", configNodeSelector)
|
||||
maps.Copy(nodeSelector, configNodeSelector)
|
||||
}
|
||||
|
||||
if len(backendNodeSelector) > 0 {
|
||||
log.Trace().Msgf("appending labels to the node selector from the backend options: %v", backendNodeSelector)
|
||||
maps.Copy(nodeSelector, backendNodeSelector)
|
||||
|
Reference in New Issue
Block a user