Skip to content

Commit

Permalink
chore: Add dependency between workflows and fix UR issue (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
helayoty committed Oct 10, 2022
1 parent 37c8b9a commit bf25ac1
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 32 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: e2e-tests

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
workflow_run:
workflows: [Lint, azure-aci-test]
types:
- completed
pull_request_target:
branches: [master]
paths-ignore: [docs/**, "**.md", "**.mdx", "**.png", "**.jpg"]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Lint

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: azure-aci-test

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
workflow_run:
workflows: [Lint]
types:
- completed
push:
branches: [master]
paths-ignore: [docs/**, "**.md", "**.mdx", "**.png", "**.jpg"]
Expand Down
60 changes: 31 additions & 29 deletions pkg/provider/aci.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,20 +351,20 @@ func (p *ACIProvider) setupCapacity(ctx context.Context) error {
p.pods = podsQuota
}

//capabilities, err := p.azClientsAPIs.ListCapabilities(ctx, p.region)
//if err != nil {
// return errors.Wrapf(err, "Unable to fetch the ACI capabilities for the location %s, skipping GPU availability check. GPU capacity will be disabled", p.region)
//}
//
//for _, capability := range *capabilities {
// if strings.EqualFold(*capability.Location, p.region) && *capability.Gpu != "" {
// p.gpu = "100"
// if gpu := os.Getenv("ACI_QUOTA_GPU"); gpu != "" {
// p.gpu = gpu
// }
// p.gpuSKUs = append(p.gpuSKUs, azaci.GpuSku(*capability.Gpu))
// }
//}
capabilities, err := p.azClientsAPIs.ListCapabilities(ctx, p.region)
if err != nil {
return errors.Wrapf(err, "Unable to fetch the ACI capabilities for the location %s, skipping GPU availability check. GPU capacity will be disabled", p.region)
}

for _, capability := range *capabilities {
if strings.EqualFold(*capability.Location, p.region) && *capability.Gpu != "" {
p.gpu = "100"
if gpu := os.Getenv("ACI_QUOTA_GPU"); gpu != "" {
p.gpu = gpu
}
p.gpuSKUs = append(p.gpuSKUs, azaci.GpuSku(*capability.Gpu))
}
}

return nil
}
Expand Down Expand Up @@ -458,12 +458,14 @@ func (p *ACIProvider) CreatePod(ctx context.Context, pod *v1.Pod) error {
ctx = addAzureAttributes(ctx, span, p)

cg := &client2.ContainerGroupWrapper{
ContainerGroupPropertiesWrapper: &client2.ContainerGroupPropertiesWrapper{},
ContainerGroupPropertiesWrapper: &client2.ContainerGroupPropertiesWrapper{
ContainerGroupProperties: &azaci.ContainerGroupProperties{},
},
}

cg.Location = &p.region
cg.ContainerGroupProperties.RestartPolicy = azaci.ContainerGroupRestartPolicy(pod.Spec.RestartPolicy)
cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.OsType = azaci.OperatingSystemTypes(p.operatingSystem)
cg.ContainerGroupProperties.OsType = azaci.OperatingSystemTypes(p.operatingSystem)

// get containers
containers, err := p.getContainers(pod)
Expand All @@ -482,10 +484,10 @@ func (p *ACIProvider) CreatePod(ctx context.Context, pod *v1.Pod) error {

}
// assign all the things
cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.Containers = &containers
cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.Volumes = &volumes
cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.ImageRegistryCredentials = creds
cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.Diagnostics = p.getDiagnostics(pod)
cg.ContainerGroupProperties.Containers = &containers
cg.ContainerGroupProperties.Volumes = &volumes
cg.ContainerGroupProperties.ImageRegistryCredentials = creds
cg.ContainerGroupProperties.Diagnostics = p.getDiagnostics(pod)

filterServiceAccountSecretVolume(p.operatingSystem, cg)

Expand All @@ -505,13 +507,13 @@ func (p *ACIProvider) CreatePod(ctx context.Context, pod *v1.Pod) error {
}
}
if len(ports) > 0 && p.subnetName == "" {
cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.IPAddress = &azaci.IPAddress{
cg.ContainerGroupProperties.IPAddress = &azaci.IPAddress{
Ports: &ports,
Type: "Public",
}

if dnsNameLabel := pod.Annotations[virtualKubeletDNSNameLabel]; dnsNameLabel != "" {
cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.IPAddress.DNSNameLabel = &dnsNameLabel
cg.ContainerGroupProperties.IPAddress.DNSNameLabel = &dnsNameLabel
}
}

Expand Down Expand Up @@ -540,8 +542,8 @@ func (p *ACIProvider) amendVnetResources(cg client2.ContainerGroupWrapper, pod *

subnetID := "/subscriptions/" + p.vnetSubscriptionID + "/resourceGroups/" + p.vnetResourceGroup + "/providers/Microsoft.Network/virtualNetworks/" + p.vnetName + "/subnets/" + p.subnetName
cgIDList := []azaci.ContainerGroupSubnetID{{ID: &subnetID}}
cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.SubnetIds = &cgIDList
cg.ContainerGroupPropertiesWrapper.ContainerGroupProperties.DNSConfig = p.getDNSConfig(pod)
cg.ContainerGroupProperties.SubnetIds = &cgIDList
cg.ContainerGroupProperties.DNSConfig = p.getDNSConfig(pod)
cg.Extensions = p.containerGroupExtensions
}

Expand Down Expand Up @@ -1966,7 +1968,7 @@ func filterServiceAccountSecretVolume(osType string, cgw *client2.ContainerGroup
if strings.EqualFold(osType, "Windows") {
serviceAccountSecretVolumeName := make(map[string]bool)

for index, container := range *cgw.ContainerGroupPropertiesWrapper.ContainerGroupProperties.Containers {
for index, container := range *cgw.ContainerGroupProperties.Containers {
volumeMounts := make([]azaci.VolumeMount, 0, len(*container.VolumeMounts))
for _, volumeMount := range *container.VolumeMounts {
if !strings.EqualFold(serviceAccountSecretMountPath, *volumeMount.MountPath) {
Expand All @@ -1975,7 +1977,7 @@ func filterServiceAccountSecretVolume(osType string, cgw *client2.ContainerGroup
serviceAccountSecretVolumeName[*volumeMount.Name] = true
}
}
(*cgw.ContainerGroupPropertiesWrapper.ContainerGroupProperties.Containers)[index].VolumeMounts = &volumeMounts
(*cgw.ContainerGroupProperties.Containers)[index].VolumeMounts = &volumeMounts
}

if len(serviceAccountSecretVolumeName) == 0 {
Expand All @@ -1985,14 +1987,14 @@ func filterServiceAccountSecretVolume(osType string, cgw *client2.ContainerGroup
l := log.G(context.TODO()).WithField("containerGroup", cgw.Name)
l.Infof("Ignoring service account secret volumes '%v' for Windows", reflect.ValueOf(serviceAccountSecretVolumeName).MapKeys())

volumes := make([]azaci.Volume, 0, len(*cgw.ContainerGroupPropertiesWrapper.ContainerGroupProperties.Volumes))
for _, volume := range *cgw.ContainerGroupPropertiesWrapper.ContainerGroupProperties.Volumes {
volumes := make([]azaci.Volume, 0, len(*cgw.ContainerGroupProperties.Volumes))
for _, volume := range *cgw.ContainerGroupProperties.Volumes {
if _, ok := serviceAccountSecretVolumeName[*volume.Name]; !ok {
volumes = append(volumes, volume)
}
}

cgw.ContainerGroupPropertiesWrapper.ContainerGroupProperties.Volumes = &volumes
cgw.ContainerGroupProperties.Volumes = &volumes
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/provider/aci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ func TestCreatePodWithGPU(t *testing.T) {
}

// Tests create pod with GPU SKU in annotation.

func TestCreatePodWithGPUSKU(t *testing.T) {
podName := "pod-" + uuid.New().String()
podNamespace := "ns-" + uuid.New().String()
Expand Down

0 comments on commit bf25ac1

Please sign in to comment.