cathive / concourse-chartmuseum-resource

interacts with a Chart Museum instance or Harbor (Kubernetes Helm Charts storage)
Apache License 2.0
14 stars 9 forks source link

An unexpected error occured. #3

Closed metacoma closed 6 years ago

metacoma commented 6 years ago

Hello, I have a trouble with chartmuseum-resource. It's reproduces with chartmuseum latest/0.2.7, chartmuseum-resource 0.2.0/latest

Pipeline source:

---                                                                                                                                   
resource_types:                                                                                                                       
  - name: chartmuseum                                                                                                                 
    type: docker-image                                                                                                                
    source:                                                                                                                           
      repository: cathive/concourse-chartmuseum-resource                                                                              
      tag: latest                                                                                                                     

resources:                                                                                                                            
- name: gerrit                                                                                                                        
  type: git                                                                                                                           
  source:                                                                                                                             
    uri: http://git/gerrit
    branch: master                                                                                                                    

- name: gerrit-chartmuseum                                                                                                            
  type: chartmuseum                                                                                                                   
  source:                                                                                                                             
    server_url: "http://chartmuseum-chartmuseum.infra:8080/"                                                                          
    chart_name: "gerrit"                                                                                                              
    version_range: "*"                                                                                                                

jobs:                                                                                                                                 
- name: publish chart                                                                                                                 
  plan:                                                                                                                               
  - get: gerrit                                                                                                                       
    trigger: true                                                                                                                     
  - put: gerrit-chartmuseum                                                                                                           
    params:                                                                                                                           
      chart: gerrit                                                                                                                   
      sign: false                

Pipeline fails with:

Processing chart at "/tmp/build/put/gerrit"...
Performing "helm package"...
Inspecting chart file: "/tmp/tmp-83H2Kne19liUL/gerrit-0.1.0.tgz"...
Uploading chart file: "/tmp/tmp-83H2Kne19liUL/gerrit-0.1.0.tgz"...

An unexpected error occured.
events.js:167
      throw er; // Unhandled 'error' event
      ^

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be one of type string or Buffer. Received type object
    at validChunk (_stream_writable.js:258:10)
    at Socket.Writable.write (_stream_writable.js:292:21)
    at process.on.err (/usr/local/lib/node_modules/@cathive/concourse-chartmuseum-resource/out.js:296:24)
    at process.emit (events.js:182:13)
    at emitPromiseRejectionWarnings (internal/process/promises.js:105:20)
    at process._tickCallback (internal/process/next_tick.js:69:34)
Emitted 'error' event at:
    at validChunk (_stream_writable.js:261:12)
    at Socket.Writable.write (_stream_writable.js:292:21)
    [... lines matching original stack trace ...]
    at process._tickCallback (internal/process/next_tick.js:69:34)

Also, i double checked, chartmuseum-endpoint works correctly and available from concourse container

headcr4sh commented 6 years ago

I think, I encountered a similar error in the past if the URL of my ChartMuseum instance pointed to a wrong / misconfigured host. Just to rule that one out: could you please check if "http://chartmuseum-chartmuseum.infra:8080/" reachable from your Concourse CI worker instance?

# Step 1
fly -t $YOUR_TARGET hijack $YOUR_BUILD_ID
# Step 2
## Press the number that represents the "put" step
# Step 3
curl http://chartmuseum-chartmuseum.infra:8080/
metacoma commented 6 years ago

yep, Chartmuseum endpoint looks good

$ fly -t cd-staging hijack -j gerrit-chart-publish/publish_chart -b 1 /bin/sh
# /sbin/apk add --update curl
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
(1/4) Installing nghttp2-libs (1.32.0-r0)
(2/4) Installing libssh2 (1.8.0-r3)
(3/4) Installing libcurl (7.61.1-r0)
(4/4) Installing curl (7.61.1-r0)
Executing busybox-1.28.4-r0.trigger
OK: 29 MiB in 43 packages
# curl http://chartmuseum-chartmuseum.infra:8080/health
{"healthy":true}
headcr4sh commented 6 years ago

Ok. So it's most definitely a bug within the resource. :-( Thanks for veryfying.

metacoma commented 6 years ago

BTW, i tested against

/chartmuseum --version
ChartMuseum version 0.2.7 (build 3650311)
headcr4sh commented 6 years ago

Mh. Latest version of ChartMuseum is 0.7.1... maybe you try upgrading? ;-) (but I doubt that's gonna change anything)

metacoma commented 6 years ago

I updated ChartMuseum up to 0.7.1 and got a strange behavior

for now, my pipeline fails with:

Processing chart at "/tmp/build/put/gerrit"...
Performing "helm package"...
Inspecting chart file: "/tmp/tmp-8azjKx1TJWRTS/gerrit-0.1.0.tgz"...
Uploading chart file: "/tmp/tmp-8azjKx1TJWRTS/gerrit-0.1.0.tgz"...
An error occured while uploading the chart: "not found".

ChartMuseum logs:

{"L":"WARN","T":"2018-09-12T18:58:07.705Z","M":"[115] Request served","path":"/api/charts","comment":"","latency":"58.9µs","clientIP":"10.244.2.23","method":"POST","statusCode":404,"reqID":"e961ef12-9e96-45b9-9534-3a6957abc68c"}

Sorry, it's my first experience with ChartMuseum, maybe i miss some steps to initialize or something like that?

metacoma commented 6 years ago

Hey @headcr4sh

I installed ChartMuseum from stable/chartmuseum helm chart By default (sic!), this chart installs ChartMuseum with disabled API! https://github.com/helm/charts/blob/master/stable/chartmuseum/values.yaml#L64

After enabling API, cocnourse-chartmuseum-resource works fine

Processing chart at "/tmp/build/put/gerrit"...
Performing "helm package"...
Inspecting chart file: "/tmp/tmp-9BXDt6XVkQ6Mf/gerrit-0.2.0.tgz"...
Uploading chart file: "/tmp/tmp-9BXDt6XVkQ6Mf/gerrit-0.2.0.tgz"...
Helm Chart has been uploaded.
- Name: gerrit
- Version: 0.2.0

Fetching chart data from "http://chartmuseum-chartmuseum.infra:8080/api/charts/gerrit/0.2.0"...
Cleaning up...

Thanks for the support!

headcr4sh commented 6 years ago

Oh man... ... the error message of the resource is really misleading, then. I'll have to improve on that.

Sluggerman commented 5 years ago

For us, it was force keyword since allow-overwrite was disabled in Chartmuseum.