jenkins-x / jx

Jenkins X provides automated CI+CD for Kubernetes with Preview Environments on Pull Requests using Cloud Native pipelines from Tekton
https://jenkins-x.io/
Apache License 2.0
4.57k stars 787 forks source link

step-install-repositories fails while running org/environment-clustername-dev/master pipeline #6083

Closed rudolph9 closed 4 years ago

rudolph9 commented 4 years ago

Summary

step-install-repositories fails while running org/environment-clustername-dev/master pipeline

Steps to reproduce the behavior

  1. Create a repo with a jenkins-x.yaml defined and no charts.
  2. run `jx import --no-draft --org=orgname --url=https://github.com/orgname/reponame.git

Import should work but subsequent trigger of org/environment-name-dev/master I think fails (I did not capture the error at that time and the logs have now been garbage collected)

  1. run jx start pipeline org/environment-clustername-dev/master

In an attempt to recapture the error I manually started the pipeline.

Expected behavior

It should run without error.

Actual behavior

Showing logs for build exergy/environment-clustername-dev/master #3 stage release and container step-install-repositories
Modified file /workspace/source/repositories/Chart.yaml to set the chart to version 3
Ignoring templates/default-group.yaml                                              
Ignoring templates/reponame-sr.yaml                                                                                
No requirements file: /tmp/jx-helm-apply-536455435/repositories/requirements.yaml so not checking for missing versions
WARNING: No $CHART_REPOSITORY defined so using the default value of: http://jenkins-x-chartmuseum:8080
Adding missing Helm repo: jenkins-x-chartmuseum http://jenkins-x-chartmuseum:8080  
Read credentials for http://jenkins-x-chartmuseum:8080 from vault helm/repos                                                 
Successfully added Helm repository jenkins-x-chartmuseum.                                                                      
error: upgrading helm chart '.': failed to run 'kubectl apply --recursive -f /tmp/helm-template-workdir-616140014/repos/output/namespaces/jx -l jenkins.io/chart-release=repos --namespace jx --wait --validate=false' command in directory '/tmp/jx-helm-apply-536455435/repositories', output: 'sourcerepositorygroup.jenkins.io/default-group configured
error: unable to decode "/tmp/helm-template-workdir-616140014/repos/output/namespaces/jx/repositories/templates/part0-reponame-sr.yaml": Object 'Kind' is missing in '{"metadata":{"annotations":{"jenkins.io/chart":"repositories"},"creationTimestamp":null,"labels":{"jenkins.io/chart-release":"repos","jenkins.io/namespace":"jx","jenkins.io/version":"3","
owner":"orgname","provider":"github","repository":"reponame"},"name":"orgname-reponame"},"spec":{"description":"Imported application for orgname/reponame","httpCloneURL":"https://github.com/orgname/reponame.git","org":"exergy","provider":"https://github.com","providerKind":"github","providerName":"github","repo":"reponame","scheduler":{"kind"
:"","name":""},"url":"https://github.com/orgname/reponame.git"}}'' 

Jx version

The output of jx version is:

$  jx version
NAME               VERSION
jx                 2.0.937
Kubernetes cluster v1.13.11-gke.9
kubectl            v1.16.2
helm client        Client: v2.13.1+g618447c
git                2.17.1
Operating System   Ubuntu 18.04.3 LTS

Jenkins type

Kubernetes cluster

jx create cluster gke --skip-installation -n clustername --region=us-west1 --max-num-nodes=9 --min-num-nodes=1

Operating system / Environment

$  jx version
.
.
.
Operating System   Ubuntu 18.04.3 LTS

Other Notes

orgname/environment-clustername-dev [master] $ cat repositories/templates/orgname-reponame-sr.yaml
metadata:
  creationTimestamp: null
  labels:
    owner: orgname
    provider: github
    repository: reponame
  name: orgname-reponame
spec:
  description: Imported application for orgname/reponame
  httpCloneURL: https://github.com/orgname/reponame.git
  org: orgname
  provider: https://github.com
  providerKind: github
  providerName: github
  repo: reponame
  scheduler:
    kind: ""
    name: ""
  url: https://github.com/orgname/reponame.git
orgname/environment-clustername-dev [master] $ ls -la repositories/templates/orgname-reponame-sr.yaml
-rwxr-xr-x 1 user user 474 Nov 12 07:04 repositories/templates/orgname-reponame-sr.yaml
rudolph9 commented 4 years ago

As a work around (NOTE: I believe the bug still exists as think jx import created an invalid repository template) I added the kind: SourceRepository to the repository and it now get's past that error without issue.

orgname/environment-clustername-dev [master] $ cat repositories/templates/orgname-reponame-sr.yaml
apiVersion: jenkins.io/v1
kind: SourceRepository
metadata:
  creationTimestamp: null
  labels:
    owner: orgname
    provider: github
    repository: reponame
  name: orgname-reponame
spec:
  description: Imported application for orgname/reponame
  httpCloneURL: https://github.com/orgname/reponame.git
  org: orgname
  provider: https://github.com
  providerKind: github
  providerName: github
  repo: reponame
  scheduler:
    kind: ""
    name: ""
  url: https://github.com/orgname/reponame.git
orgname/environment-clustername-dev [master] $ ls -la repositories/templates/orgname-reponame-sr.yaml
-rwxr-xr-x 1 user user 474 Nov 12 07:04 repositories/templates/orgname-reponame-sr.yaml
abayer commented 4 years ago

I believe I fixed this with #6017, which is in jx 2.0.946 and later. Can you update to a newer jx and give it a try?

abayer commented 4 years ago

Yup, it's fixed - reopen if you're still seeing it.