Selecting the agentpool present at first index

This commit is contained in:
prebansa 2020-02-13 12:58:10 +05:30
Родитель 1889c0a27c
Коммит b3d8bcf2a1
4 изменённых файлов: 17 добавлений и 20 удалений

Просмотреть файл

@ -4,16 +4,16 @@ metadata:
name: azurepipelinespool-operator
namespace: azuredevops
spec:
controllerImage: mcr.microsoft.com/azurepipelinespool/k8s-poolprovider:v1.0
controllerImage: mcr.microsoft.com/azurepipelinespool/k8s-poolprovider:v1.1
buildkitReplicas: 1
agentPools:
- name: windows
spec:
containers:
- name: vsts-agent
image: prebansa/myagent:v5.17
- name: linux
spec:
containers:
- name: vsts-agent
image: mcr.microsoft.com/azurepipelinespool/azure-pipelines-agent:v1.0
image: mcr.microsoft.com/azurepipelinespool/azure-pipelines-agent:v1.0
- name: windows
spec:
containers:
- name: vsts-agent
image: prebansa/myagent:v5.17

Просмотреть файл

@ -17,7 +17,7 @@ spec:
containers:
- name: k8s-poolprovider
# Replace this with the built image name
image: mcr.microsoft.com/azurepipelinespool/k8s-poolprovideroperator:v1.0
image: mcr.microsoft.com/azurepipelinespool/k8s-poolprovideroperator:v1.1
command:
- k8s-poolprovider
imagePullPolicy: Always

Просмотреть файл

@ -50,8 +50,8 @@ func CreatePod(agentRequest AgentRequest, podnamespace string) AgentProvisionRes
labels := GenerateLabelsForPod(agentRequest.AgentId)
log.Println("Add an agent Pod using CRD")
// currently as demands are not supported so creating agent for Linux
pod = crdclient.AzurePipelinesPool(podnamespace).AddNewPodForCR(crdobject, labels, "linux")
pod = crdclient.AzurePipelinesPool(podnamespace).AddNewPodForCR(crdobject, labels)
log.Println("Agent pod spec fetched ", pod)

Просмотреть файл

@ -22,7 +22,7 @@ type AzurePipelinesPoolV1Alpha1Client struct {
type AzurePipelinesPoolInterface interface {
Get(name string) (*AzurePipelinesPool, error)
AddNewPodForCR(obj *AzurePipelinesPool, labels map[string]string, poolName string) *v1.Pod
AddNewPodForCR(obj *AzurePipelinesPool, labels map[string]string) *v1.Pod
}
type AzurePipelinesPoolclient struct {
@ -39,7 +39,7 @@ func (c *AzurePipelinesPoolclient) Get(name string) (*AzurePipelinesPool, error)
return result, err
}
func (c *AzurePipelinesPoolclient) AddNewPodForCR(obj *AzurePipelinesPool, labels map[string]string, poolname string) *v1.Pod {
func (c *AzurePipelinesPoolclient) AddNewPodForCR(obj *AzurePipelinesPool, labels map[string]string) *v1.Pod {
var spec *v1.PodSpec
if IsTestingEnv() {
@ -52,7 +52,7 @@ func (c *AzurePipelinesPoolclient) AddNewPodForCR(obj *AzurePipelinesPool, label
},
}
} else {
spec = FetchPodSpec(obj, poolname)
spec = FetchPodSpec(obj)
}
// append the RUNNING_ON environment variable
@ -81,14 +81,11 @@ func (c *AzurePipelinesPoolclient) AddNewPodForCR(obj *AzurePipelinesPool, label
return nil
}
func FetchPodSpec(obj *AzurePipelinesPool, poolname string) *v1.PodSpec {
func FetchPodSpec(obj *AzurePipelinesPool) *v1.PodSpec {
if obj.Spec.AgentPools != nil {
for i := range obj.Spec.AgentPools {
if obj.Spec.AgentPools[i].PoolName == poolname {
return obj.Spec.AgentPools[i].PoolSpec
}
}
if obj.Spec.AgentPools != nil && len(obj.Spec.AgentPools) > 0 {
// currently as demands are not supported so creating agentpod from agentspec being passed at first index
return obj.Spec.AgentPools[0].PoolSpec
}
return nil