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

azure/login pre step takes up to 1 minute to execute #456

Open
olafurnielsen opened this issue Jun 5, 2024 · 5 comments
Open

azure/login pre step takes up to 1 minute to execute #456

olafurnielsen opened this issue Jun 5, 2024 · 5 comments
Assignees
Labels
product enhancement New feature or request

Comments

@olafurnielsen
Copy link

Observed behavior:
The pre step in azure/login takes up to 1 minute to execute. Very seldom does it take a few seconds to execute. In some of our builds this accounts for half the total build time.

Expected behavior:
The step should consistently execute in a few seconds.

Information:

  • azure/login@v2
  • Authenticating against Azure public cloud
  • Using OIDC credentials
  • Running on GitHub hosted runners

Used as:

- name: Login to Azure
  uses: azure/login@v2
  with:
    tenant-id: ${{ secrets.AZURE_TENANT_ID }}
    client-id: ${{ secrets.AZURE_CLIENT_ID }}
    subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

Resulting in:
Screenshot 2024-06-05 at 09 55 30
Screenshot 2024-06-05 at 09 55 14

What can be done to speed this up?

@olafurnielsen olafurnielsen added the need-to-triage Requires investigation label Jun 5, 2024
@MoChilia MoChilia linked a pull request Jun 6, 2024 that will close this issue
@MoChilia MoChilia self-assigned this Jun 6, 2024
@MoChilia MoChilia added product enhancement New feature or request and removed need-to-triage Requires investigation labels Jun 6, 2024
@damianh
Copy link

damianh commented Aug 14, 2024

This step is consuming 10 to 15 percent of our GitHub Actions build minutes and is costing us money. This should be fixed as a high priority please.

image

damianh added a commit to elaway/gha-az-login that referenced this issue Aug 14, 2024
damianh added a commit to elaway/gha-az-login that referenced this issue Aug 14, 2024
damianh added a commit to elaway/gha-az-login that referenced this issue Aug 14, 2024
commit c9795fb
Author: Damian Hickey <dhickey@gmail.com>
Date:   Wed Aug 14 12:18:53 2024 +0200

    Disable pre and post steps

    Pending fix of Azure#456
@MoChilia MoChilia assigned YanaXu and unassigned MoChilia Aug 15, 2024
@YanaXu
Copy link
Collaborator

YanaXu commented Sep 18, 2024

Hi @olafurnielsen and @damianh, we've released a new version v2.2.0. In this version, we removed the pre step and add 2 env variables to enable/disable pre or post cleanup.
v2 is aligned with v2.2.0 now.
Please try the new version. You can also refer to Enable/Disable the cleanup steps.

Just FYI, the time cost is mainly for login context initialization. After we remove pre step, the main step may need more time.

@GoncaloPT
Copy link

GoncaloPT commented Oct 15, 2024

Hi @YanaXu

I've been trying the mentioned version, with both AZURE_LOGIN_PRE_CLEANUP and AZURE_LOGIN_POST_CLEANUP set to false and i'm having an average of 1 minute for the login action.

EDIT: Can we use a composite action to cache the login so it doesn't have to be redone every time?

@YanaXu
Copy link
Collaborator

YanaXu commented Oct 17, 2024

Hi @GoncaloPT , could you help me check these questions?

  • Do you use GitHub-hosted runner or Self-hosted runner? What's the OS type of your runner?
  • When you mention "composite action", do you mean you have several workflows to run or several jobs to run or else? FYI, the login context can only be cached on the same runner.

The login time cost depends on underlying Azure CLI and Azure PowerShell. They needs time to init the login context.
However, our daily test on GitHub-hosted runners (utuntu & windows & MacOS) shows the time cost is less than yours (including both Azure CLI login and Azure PowerShell login).
Take the time cost yesterday for example. There are 18 logins and the max one is 51 seconds, the min one is 10 seconds and the average is 23 seconds.

@GoncaloPT
Copy link

Hi @YanaXu, thanks for your reply.

Replying to your questions:

  • We do use self-hosted runners, which are provided on our enterprise github instance. They run ubuntu.
  • My idea would be to optimize the best I can.. For instance, imagine that I provide a composite action that fetchs secrets from key vault; If I could cache that login for posterior invocations of that same action it would improve the time consumed... To make It useful, it would have to keep that "state" through different workflows.

Regarding the time cost you present, I haven't been able to reproduce logins near those ones values.. The full roundtrip of login + fetch one secret from key vault took from 1m:13s up to 1:50s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants