microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.5k stars 2.61k forks source link

[BUG]: KubeloginInstallerV0 Cannot read properties of undefined (reading 'trim') #19097

Open TeodoraEinoryte opened 1 year ago

TeodoraEinoryte commented 1 year ago

Task name

KubeloginInstallerV0

Task version

0.226.0

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

Azure DevOps Server type

Azure DevOps Server (Please specify exact version in the textbox below)

Azure DevOps Server Version (if applicable)

Azure DevOps Server 2023.8

Operation system

Debian 12

Task log

Starting: KubeloginInstaller
==============================================================================
Task         : Kubelogin tool installer
Description  : Helps to install kubelogin
Version      : 0.226.0
Author       : Microsoft Corporation
Help         : https://azure.github.io/kubelogin/index.html
==============================================================================
##[error]Cannot read properties of undefined (reading 'trim')
Finishing: KubeloginInstaller

Relevant log output

##[error]Cannot read properties of undefined (reading 'trim')

Aditional info

Kubelogin version: 0.0.32
After restarting failed job, this task succeeds
bartwitkowski commented 1 year ago

Same problem here!

Exchizz commented 1 year ago

I was also experiencing that issue ~30 mins ago on self-hosted agents.

It appears to have been fixed now - my pipelines are working again :)

v-mohithgc commented 1 year ago

Hi everyone, thanks for reporting. Can anyone confirm if this issue still persists? if so what's the reoccurrence rate? I was just checking the source code of this task, and I don't see any recent changes deployed (last change was 2 months back), so ig it's unlikely this issue might be from the task end.

Can anyone confirm if this issue is fixed? if not, can you enable the debug logs (system.debug=true) and send us the failure logs to v-mohithgc @microsoft.com.

Thanks

TeodoraEinoryte commented 1 year ago

Hello, thanks for the response. This issue appears from time to time, like once a week for us on multiple pipelines. It existed all the time since we started using kubelogin task (for a month now). I will try to capture output with debug logs.

Edit: logs sent to the provided email

Exchizz commented 1 year ago

I was experiencing the issue yesterday for about 1 hour (on self hosted agents).

EDIT: We've started to experience the issue again

YevheniiKholodkov commented 1 year ago

Hello, Thank you for reporting the issue.

The root cause of the issue is that the task is making an anonymous REST API call to GitHub in order to fetch the latest version of kubelogin. However, anonymous calls in GitHub are subject to a limit of 60 requests per hour. When a 403 error occurs in the task, it is not being handled properly, leading to a failure later in the code when attempting to use the version tag. Hence, you see the error "cannot read property of undefined".

There is no way to provide credentials to the task to make an authorized rest api call with a rate limit of 5000 calls per hour. However, there are 2 possible workarounds. The first one is to specify the version explicitly in the task. This way we will skip the call to github to retrieve the latest version. For example,

We will be working on a fix , but there is no ETA at the moment.

(Note. This issue is unlikly to happen on Microsoft Hosted agents because a new agent is assigned to each pipeline run )

TeodoraEinoryte commented 1 year ago

Thank you very much for your response and your suggestions on how to resolve the issue!

sivetic commented 8 months ago

Is there any update on this issue? We are required to use kubelogin for AKS + Azure AD + Azure RBAC integration, and the task fails often enough to make this a serious challenge for teams.

sivetic commented 8 months ago

The first one is to specify the version explicitly in the task. This way we will skip the call to github to retrieve the latest version. For example,

  • task: KubeloginInstaller@0 inputs: kubeloginVersion: 0.0.30

Wouldn't specifying the version explicitly also hit the GitHub API rate limit? It seems getKubeloginRelease() is called which queries the API:

let request = new webClient.WebRequest();
request.uri = 'https://api.github.com/repos/' + KUBELOGIN_REPO_OWNER + '/' + KUBELOGIN_REPO + '/releases/tags/' + version;
request.method = 'GET';
request.headers = request.headers || {};
request.headers['User-Agent'] = userAgent;

const response = await webClient.sendRequest(request);
matthawley commented 7 months ago

@sivetic is right -we've specified a version, and we consistently still get rate limited. We need to find a different solution until this gets resolved as it's pretty impactful to our pipelines.

sivetic commented 7 months ago

@matthawley A quick workaround we do is to replace the official task with a bash/PS script:

- bash: |
   curl -fsSLO https://github.com/Azure/kubelogin/releases/download/v0.1.1/kubelogin-linux-amd64.zip
   unzip -ojd /usr/local/bin kubelogin-linux-amd64.zip bin/linux_amd64/kubelogin
   rm -f kubelogin-linux-amd64.zip
   kubelogin --version

  displayName: 'Install Kubelogin'
matthawley commented 7 months ago

@sivetic Nice - I'll give this a try!

SamirFarhat commented 1 month ago

@matthawley A quick workaround we do is to replace the official task with a bash/PS script:

- bash: |
   curl -fsSLO https://github.com/Azure/kubelogin/releases/download/v0.1.1/kubelogin-linux-amd64.zip
   unzip -ojd /usr/local/bin kubelogin-linux-amd64.zip bin/linux_amd64/kubelogin
   rm -f kubelogin-linux-amd64.zip
   kubelogin --version

  displayName: 'Install Kubelogin'

Thank you, this works great