linkyard / concourse-helm-resource

Deploy to kubernetes helm from your concourse.ci.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check fails: unexpected end of JSON input

rubenv opened this issue · comments

I'm getting the very cryptic unexpected end of JSON input error from check.

I'm using a config like this one, which shouldn't be too special:

    - name: helm
      type: helm
      source:
          cluster_url: ((kubernetes-cluster-url))
          cluster_ca: ((kubernetes-cluster-ca))
          admin_key: ((kubernetes-admin-key))
          admin_cert: ((kubernetes-admin-cert))
          namespace: datahub
          release: datahub

This config works for deploying charts, so I think it's correct.

Is there any way to get more debug output from check? Anything I could do to help figure this out?

More hints: when I fly intercept into the check container, I do find a fully set up container.

Manually running export release=datahub and then executing the bottom half of the check script:

if [ "$current_rev" -eq "0" ]; then
  # Empty => return the current
  helm history $release $tls_flag | tail -n 1 | while read -r line; do
    revision=$(echo $line | awk '{ print $1 }')
    echo "$revision"
  done | jq -R '.' | jq -s "map({\"revision\": ., \"release\": \"$release\"})"
else
  # All versions equal and newer
  helm history $release $tls_flag | tail -n +2 | while read -r line; do
    revision=$(echo $line | awk '{ print $1 }')
    if [ -z "$current_rev" ] || [ "$revision" -ge "$current_rev" ]; then
      echo "$revision"
    fi
  done | jq -R '.' | jq -s "map({\"revision\": ., \"release\": \"$release\"})"
fi

Gives me the correct result.

Going one step further and dropping in a payload:

{
  "source": {
    "cluster_url": "https://...",
    "cluster_ca": "...",                                                                      
    "admin_key": "...",                                                                               
    "admin_cert": "...",
    "release": "robot",
    "namespace": "robot"
  }
}

Running cat payload.json | /opt/resource/check -> works.

I have no idea what else could be going wrong here. Something during the initial setup?

Well, no, not even during initial setup:

rm -rf /root/.kube /root/.helm
cat payload.json | bash -ex /opt/resource/check

Works perfectly.