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

[BUG]: AzureCLI@2 task ignores existing optimizations on hosted agent #19209

Closed
1 of 4 tasks
jessehouwing opened this issue Nov 2, 2023 · 4 comments
Closed
1 of 4 tasks

Comments

@jessehouwing
Copy link
Contributor

jessehouwing commented Nov 2, 2023

Task name

AzureCLI

Task version

2

Environment type (Please select at least one environment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Operation system

Windows-latest

Task log

n/a

Relevant log output

Setting AZURE_CONFIG_DIR env variable to: D:\a\_temp\.azclitask

Aditional info

The Azure Pipelines Hosted Agent images take extra care making sure that azure-cli is configured, pre-compiled, all required additional packages have been installed and the command index has been built.

By redirecting the AZURE_CONFIG_DIR to the agent's temp directory, all of that goes to waste and the performance difference is quite high. On the Windows Hosted Agents the time to run a simple command is about 1 extra minute than is needed.

Setting the useGlobalConfig: true prevents the overriding of the azure configuration directory.

I'm proposing that when:

  1. the task runs on the hosted agent
  2. the AZURE_CONFIG_DIR environment variable is already set

Then:

  • AzureCLI@2 will not reset the AZURE_CONFIG_DIR variable

OR:

  • AzureCLI@2 will log a warning if useGlobalConfig isn't explicitly set to false to indicate the perf improvement that's possible by introducing this setting.

The method that would be changed:

private static setConfigDirectory(): void {
if (tl.getBoolInput("useGlobalConfig")) {
return;
}
if (!!tl.getVariable('Agent.TempDirectory')) {
var azCliConfigPath = path.join(tl.getVariable('Agent.TempDirectory'), ".azclitask");
console.log(tl.loc('SettingAzureConfigDir', azCliConfigPath));
process.env['AZURE_CONFIG_DIR'] = azCliConfigPath;
} else {
console.warn(tl.loc('GlobalCliConfigAgentVersionWarning'));
}
}

⚠️ Warning: this might be a breaking change if people are mixing useGlobalConfig with both true and false on the hosted agent, in the same job. hence my alternative of logging the suggestion.

@jessehouwing
Copy link
Contributor Author

jessehouwing commented Nov 2, 2023

Something like:

 private static setConfigDirectory(): void { 
     if (tl.getBoolInput("useGlobalConfig") || !!tl.getVariable("agent.cloudid")) { 
         return; 
     } 
  
     if (!!tl.getVariable('Agent.TempDirectory')) { 
         var azCliConfigPath = path.join(tl.getVariable('Agent.TempDirectory'), ".azclitask"); 
         console.log(tl.loc('SettingAzureConfigDir', azCliConfigPath)); 
         process.env['AZURE_CONFIG_DIR'] = azCliConfigPath; 
     } else { 
         console.warn(tl.loc('GlobalCliConfigAgentVersionWarning')); 
     } 
 }

or

 private static setConfigDirectory(): void { 
     if (tl.getBoolInput("useGlobalConfig")) { 
         return; 
     } 
  
     if (!!tl.getVariable('Agent.TempDirectory')) { 
         if (!!tl.getVariable("agent.cloudid"))
         {
             console.log("Consider setting 'useGlobalConfig: true' for significantly higher performance");
         }
         var azCliConfigPath = path.join(tl.getVariable('Agent.TempDirectory'), ".azclitask"); 
         console.log(tl.loc('SettingAzureConfigDir', azCliConfigPath)); 
         process.env['AZURE_CONFIG_DIR'] = azCliConfigPath; 
     } else { 
         console.warn(tl.loc('GlobalCliConfigAgentVersionWarning')); 
     } 
 }

@jessehouwing
Copy link
Contributor Author

without useGlobalConfig:true:
image

with useGlobalConfig:true:
image

@jessehouwing
Copy link
Contributor Author

@geekzter 👆

Copy link

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

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

1 participant