Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is not possible to use custom agent pools with Bicep #694

Closed
antsok opened this issue May 16, 2023 · 9 comments
Closed

It is not possible to use custom agent pools with Bicep #694

antsok opened this issue May 16, 2023 · 9 comments

Comments

@antsok
Copy link

antsok commented May 16, 2023

Describe the bug
Azure gives an error when deploying taskRun with Bicep, despite that bicep documentation for taskRun states that it is possible to specify agent pool. See https://learn.microsoft.com/en-us/azure/templates/microsoft.containerregistry/registries/taskruns?pivots=deployment-language-bicep#resource-format

At the same time, CLI does allow to specify agent pool.

To Reproduce
Steps to reproduce the behavior:

task.bicep

param acrName string
param name string
param location string = resourceGroup().location

@description('The URL(absolute or relative) of the source context for the task step.')
param dockerContextPath string = ''
@description('The Docker file path relative to the source context.')
param dockerFilePath string = 'Dockerfile'
@description('The fully qualified image names including the repository and tag.')
param dockerImageName string = ''

param doTaskRun bool = false

param forceUpdateTag string = utcNow('yyyyMMddHHmmss')

resource acr 'Microsoft.ContainerRegistry/registries@2023-01-01-preview' existing = {
  name: acrName
}

resource acrTask 'Microsoft.ContainerRegistry/registries/tasks@2019-06-01-preview' = {
  name: name
  location: location
  parent: acr
  properties: {
    status: 'Enabled'
    agentPoolName: 'defaultPool'
    agentConfiguration: {
      cpu: 2
    }
    platform: {
      os: 'Linux'
      architecture: 'amd64'
    }
    step : {
      contextPath: dockerContextPath
      dockerFilePath: dockerFilePath
      type: 'Docker'
      imageNames: [
        dockerImageName
      ]
      isPushEnabled: true
    }
  }
}

resource acrTaskRun 'Microsoft.ContainerRegistry/registries/taskRuns@2019-06-01-preview' = if(doTaskRun) {
  name: name
  parent: acr
  location: location
  properties: {
    forceUpdateTag: forceUpdateTag
    runRequest:{
      isArchiveEnabled: true
      type: 'TaskRunRequest'
      taskId: acrTask.id
      agentPoolName: 'defaultPool'
    }
  }
}

output id string = acrTask.id
output imageNames object = acrTask.properties.step.imageNames

main.bicep

module acrDockerBuildTask '../../modules/task.bicep' = {
  scope: myResourceGroup
  name: '${deployment().name}-acr-task'
  params: {
    acrName: acr.outputs.name
    name: 'build-aznamingtool'
    location: location
    dockerContextPath: 'https://github.com/microsoft/CloudAdoptionFramework.git#master:ready/AzNamingTool'
    dockerFilePath: 'Dockerfile'
    dockerImageName: 'aznamingtool:latest'
    doTaskRun: true
  }
}

Error:

{
    "status": "Failed",
    "error": {
        "code": "DeploymentFailed",
        "target": "/subscriptions/[...]/resourceGroups/[...]/providers/Microsoft.Resources/deployments/[...]-acr-task",
        "message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.",
        "details": [
            {
                "code": "TaskRunInvalidAgentPoolName",
                "target": "request",
                "message": "You can not set the agent pool name in the task run request. Please set the name on the task."
            }
        ]
    }
}

If I leave out this parameter and configure agentPool only on task level then taskRun deploys successfully. However when taskrun is executing it is not using the custom agent pool defined for task.

Expected behavior
I would expect the behavior of Azure RM to match the documentation, so that agent pool parameter is accepted.
I would also expect that task runs to respect the agent pool configured on the task.

Any relevant environment information

  • Datetime (UTC) when the issue occurred : 16-May-2023

Additional context
Add any other context about the problem here.

If any information is a concern to post here, you can create a support ticket or send an email to acrsup@microsoft.com.

@antsok antsok added the bug label May 16, 2023
@github-actions
Copy link

github-actions bot commented Oct 6, 2023

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Oct 6, 2023
@antsok
Copy link
Author

antsok commented Oct 23, 2023

Is this repo being watched by the ACR team?

@github-actions github-actions bot removed the Stale label Oct 24, 2023
@northtyphoon
Copy link
Member

You already specify agentPoolName to defaultPool when you create task resource. You don't need to pass it again in acrTaskRun request as the error pointed it out.

You can try remove agentPoolName from acrTaskRun and see if it works.

resource acrTaskRun 'Microsoft.ContainerRegistry/registries/taskRuns@2019-06-01-preview' = if(doTaskRun) {
  name: name
  parent: acr
  location: location
  properties: {
    forceUpdateTag: forceUpdateTag
    runRequest:{
      isArchiveEnabled: true
      type: 'TaskRunRequest'
      taskId: acrTask.id
    }
  }
}

@yuehaoliang
Copy link

yuehaoliang commented Oct 30, 2023

The agent pool configuration is defined at the task level, and once a task has been designated to run on a specific agent pool, it should not be re-specified for individual task runs.

@antsok I've noticed you mentioned "However when taskrun is executing it is not using the custom agent pool defined for task". Are you certain about that? To verify, you can use the "az acr task show-run" command and examine whether the agent pool name for the task run is null. Additionally, providing us with the registry name and task run ID will enable us to investigate whether the task run indeed executed on your designated custom agent pool.

@antsok
Copy link
Author

antsok commented Oct 30, 2023

The agent pool configuration is defined at the task level, and once a task has been designated to run on a specific agent pool, it should not be re-specified for individual task runs.

This explanation needs to find its way in removing the agentPool property from the taskRun resource

@antsok I've noticed you mentioned "However when taskrun is executing it is not using the custom agent pool defined for task". Are you certain about that? To verify, you can use the "az acr task show-run" command and examine whether the agent pool name for the task run is null. Additionally, providing us with the registry name and task run ID will enable us to investigate whether the task run indeed executed on your designated custom agent pool.

The problem was reported 6 months ago. I no loger have those resources deployed, and logs are not retained for that long.

@yuehaoliang
Copy link

yuehaoliang commented Oct 30, 2023

This explanation needs to find its way in removing the agentPool property from the taskRun resource

For a quick Run (without the creation of a Task resource), the agentPoolName property is necessary to specify where it should be run.

Likewise, when using Azure CLI, you can request a quick Run on an Agentpool by "az acr build --agent-pool", or you can create a Task configured with an Agentpool by "az acr task create --agent-pool" and subsequently execute this Task by "az acr task run". However, "az acr task run --agent-pool" will result in an error "You cannot set the agent pool name in the task run request. Please set the name on the task".

I understand your point, and I agree that the Bicep templates can be misleading. It should be documented that if the Agentpool is configured for a Task resource, the agentPoolName property should be removed for a Run resource. Thank you for your suggestion; we will assess how to enhance the user experience in this regard.

@antsok
Copy link
Author

antsok commented Oct 30, 2023

Thank you for agreeing to consider updating the documentation. It would help avoid the confusion indeed.

Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Dec 30, 2023
Copy link

This issue was closed because it has been stalled for 30 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants