redhat-developer / openshift-vsts

OpenShift Extension for Azure DevOps.
Apache License 2.0
15 stars 20 forks source link

error on oc-setup: unknown archive format #212

Closed schurlinga closed 1 year ago

schurlinga commented 1 year ago

Hello,

I am running an azure devops agent on Linux and when it comes to the oc-setup@3 task, it throws an error trying to expand the *.tar.gz file.

Pipeline Error:

##[error]unknown archive format /opt/app-root/app/_work/1/s/.download/openshift-client-linux.tar.gz

Agent Specs:

[2023-01-19 17:00:25Z INFO AgentProcess] Agent package linux-x64.
[2023-01-19 17:00:25Z INFO AgentProcess] Running on Linux (X64).
[2023-01-19 17:00:25Z INFO AgentProcess] RuntimeInformation: Linux 4.18.0-305.65.1.el8_4.x86_64 #1 SMP Thu Sep 22 08:28:21 EDT 2022.
[2023-01-19 17:00:25Z INFO AgentProcess] Version: 2.213.2
[2023-01-19 17:00:25Z INFO AgentProcess] Commit: 4f90e68aaafa0393021e8330f2d0bc7c0697be0b

Pipeline Task:

- task: oc-setup@3
  inputs:
    connectionType: 'OpenShift Connection Service'
    openshiftService: 'Openshift service connection: amdb-dev'

Pipeline Logs:

##[debug]Evaluating condition for step: 'ocsetup'
##[debug]Evaluating: SucceededNode()
##[debug]Evaluating SucceededNode:
##[debug]=> True
##[debug]Result: True
Starting: ocsetup
==============================================================================
Task         : Install and setup oc
Description  : Installs oc and configures the PATH and KUBECONFIG environment variables.
Version      : 3.0.1
Author       : Red Hat

Help         : See [getting started](https://github.com/redhat-developer/openshift-vsts/blob/master/docs/getting-started.md)
==============================================================================
##[debug]Using node path: /opt/app-root/app/externals/node10/bin/node
##[debug]agent.TempDirectory=/opt/app-root/app/_work/_temp
##[debug]loading inputs and endpoints
##[debug]loading INPUT_CONNECTIONTYPE
##[debug]loading INPUT_OPENSHIFTSERVICE
##[debug]loading INPUT_CONFIGURATIONTYPE
##[debug]loading INPUT_CONFIGURATIONPATH
##[debug]loading ENDPOINT_AUTH_8c60117b-76c2-4daf-9182-e3b72b3fa5fd
##[debug]loading ENDPOINT_AUTH_SCHEME_8c60117b-76c2-4daf-9182-e3b72b3fa5fd
##[debug]loading ENDPOINT_AUTH_PARAMETER_8c60117b-76c2-4daf-9182-e3b72b3fa5fd_APITOKEN
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
##[debug]loaded 11
##[debug]Agent.ProxyUrl=undefined
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]Agent.SkipCertValidation=undefined
##[debug]Agent.ProxyUrl=undefined
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]check path : /opt/app-root/app/_work/_tasks/oc-setup_44babac3-ab28-4f68-b843-bf2c295a4a2d/3.0.1/node_modules/azure-pipelines-tool-lib/lib.json
##[debug]adding resource file: /opt/app-root/app/_work/_tasks/oc-setup_44babac3-ab28-4f68-b843-bf2c295a4a2d/3.0.1/node_modules/azure-pipelines-tool-lib/lib.json
##[debug]system.culture=en-US
##[debug]version=undefined
##[debug]proxy=undefined
##[debug]determining latest oc version
##[debug]latest stable oc version: https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz
##[debug]creating download directory
##[debug]downloading: https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz
##[debug]expanding /opt/app-root/app/_work/1/s/.download/openshift-client-linux.tar.gz into /opt/app-root/app/_work/1/s/.download
##[debug]task result: Failed
##[error]unknown archive format /opt/app-root/app/_work/1/s/.download/openshift-client-linux.tar.gz
##[debug]Processed: ##vso[task.issue type=error;]unknown archive format /opt/app-root/app/_work/1/s/.download/openshift-client-linux.tar.gz
##[debug]Processed: ##vso[task.complete result=Failed;]unknown archive format /opt/app-root/app/_work/1/s/.download/openshift-client-linux.tar.gz
Finishing: ocsetup
rgh-hipoges commented 1 year ago

Hello.

I got the same error.

2023-01-20T17:18:30.9743754Z [command]/usr/bin/curl -s -L -o /opt/app-root/app/_work/r1/a/.download/openshift-client-linux.tar.gz https://mirror.openshift.com/pub/openshift-v4/clients/ocp/4.10.44/openshift-client-linux.tar.gz
2023-01-20T17:18:41.8248444Z ##[debug]Exit code 0 received from tool '/usr/bin/curl'
2023-01-20T17:18:41.8257142Z ##[debug]STDIO streams have closed for tool '/usr/bin/curl'
2023-01-20T17:18:41.8267886Z ##[debug]expanding /opt/app-root/app/_work/r1/a/.download/openshift-client-linux.tar.gz into /opt/app-root/app/_work/r1/a/.download
2023-01-20T17:18:41.8287994Z ##[debug]task result: Failed
2023-01-20T17:18:41.8361713Z ##[error]unknown archive format /opt/app-root/app/_work/r1/a/.download/openshift-client-linux.tar.gz

I believe the issue could be located at this line: (https://github.com/redhat-developer/openshift-vsts/blob/master/src/oc-install.ts#L230)

Could it be that "path.extname(archive)" is returning ".bz" instead of ".tar.gz" when the compressed file ends with ".tar.gz"?

schurlinga commented 1 year ago

yes, that is the issue, because in unzipArchive there is no case for ".gz". Only for ".tgz" and ".tar.gz"

lstocchi commented 1 year ago

@schurlinga @rgh-hipoges I just released the extension with the fix (v. 2.0.1). Let me know if you face any other issue.

And ... sorry for the late release. had some issue with Jenkins

schurlinga commented 1 year ago

@lstocchi thx for the release, will test it today.

I also added a comment to your Pull Request, as i think there could be another issue if anyone uploads the archive with .tar.bz2 as the extension.