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

Kubernetes task does not fail on failure #14283

Closed
tbuico-premera opened this issue Jan 26, 2021 · 2 comments
Closed

Kubernetes task does not fail on failure #14283

tbuico-premera opened this issue Jan 26, 2021 · 2 comments

Comments

@tbuico-premera
Copy link

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name: Kubernetes

list here (V# not needed):
https://github.com/Microsoft/azure-pipelines-tasks/tree/master/Tasks

Environment

  • Server - Azure Pipelines

    • If using Azure Pipelines, provide the account name, team project name, build definition name/build number:
      • account name: [email protected]
      • team project name: Premera
      • build definition name/build number: (unsure how to locate)
  • Agent - Private:

    • If using private agent, provide the OS of the machine running the agent and the agent version:
      • OS: RHEL 7.7
      • Agent Version: 2.175.2
      • Container: alpine:3

Issue Description

The following task in an ado pipeline is used in order to log into a kubernetes cluster:

- task: Kubernetes@1
  displayName: 'login to k8s'
  inputs:
    connectionType: Kubernetes Service Connection
    kubernetesServiceEndpoint: 'kubernetesServiceEndpoint.com'
    command: login

If there is a timeout or another failure for any reason, this task does not fail. This leads to any future tasks in the pipeline which executes code on the k8s cluster to fail.

Here is an example of a failure:

Starting: login to k8s
==============================================================================
Task         : Kubectl
Description  : Deploy, configure, update a Kubernetes cluster in Azure Container Service by running kubectl commands
Version      : 1.181.0
Author       : Microsoft Corporation
Help         : https://aka.ms/azpipes-kubectl-tsg
==============================================================================
Prepending PATH environment variable with directory: /usr/bin
==============================================================================
      Kubectl Client Version: v1.20.1
  Kubectl Server Version: Could not find kubectl server version
==============================================================================
commandOutput
Finishing: login to k8s

Retries of the same pipeline without any changes will often work.

Here is an example of a success on Attempt #2, without any changes to code or pipeline.

Starting: login to k8s
==============================================================================
Task         : Kubectl
Description  : Deploy, configure, update a Kubernetes cluster in Azure Container Service by running kubectl commands
Version      : 1.181.0
Author       : Microsoft Corporation
Help         : https://aka.ms/azpipes-kubectl-tsg
==============================================================================
Prepending PATH environment variable with directory: /usr/bin
==============================================================================
      Kubectl Client Version: v1.20.1
      Kubectl Server Version: v1.18.12+vmware.2
==============================================================================
commandOutput
Finishing: login to k8s

One can notice that now the Kubectl Server Version is valid on Attempt #2

Task logs

Attached as a zip file
f715a6ba-3879-5f79-a1ba-81e2d10a389e.zip

@thesattiraju
Copy link
Contributor

thesattiraju commented Jan 28, 2021

Looks like it's a conscious call.
https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/KubernetesV1/src/kubernetes.ts#L73-L96

Given that kubectl version command is not explicitly requested by your pipeline config, I suppose it's okay not fail upon failure. This is more or less to help with debugging.

Based on this PR, this change was introduced way after KubectlV1 task was released, I suppose the decision to not fail had something to do with back-compatibility.

cc: @shigupt202 would you like to add something?

@shigupt202
Copy link
Contributor

@DS-MS You're right. The version was added in logs to help users with debugging and we are not failing it here because of back-compat.

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

4 participants