midl-dev / tezos-on-gke

A secure, turn-key public Tezos baking service on Kubernetes
Apache License 2.0
32 stars 15 forks source link

Terraform apply, "Error running command 'set -x" #43

Open rsmets opened 3 years ago

rsmets commented 3 years ago

It seems when running terraform apply from the /terraform dir that the resource "null_resource" "push_containers" in k8s.tf is causing the following error:

null_resource.push_containers: Creating...
null_resource.push_containers: Provisioning with 'local-exec'...
null_resource.push_containers (local-exec): Executing: ["/bin/bash" "-c" "set -x\n\nbuild_container () {\n  set -x\n  cd $1\n  container=$(basename $1)\n  cp Dockerfile.template Dockerfile\n  sed -i \"s/((tezos_sentry_version))/latest-release/\" Dockerfile\n  sed -i \"s/((tezos_private_version))/latest-release/\" Dockerfile\n  cat << EOY > cloudbuild.yaml\nsteps:\n- name: 'gcr.io/cloud-builders/docker'\n  args: ['build', '-t', \"gcr.io/solo-tezos-baker/$container:tezos-latest\", '.']\nimages: [\"gcr.io/solo-tezos-baker/$container:tezos-latest\"]\nEOY\n  gcloud builds submit --project solo-tezos-baker --config cloudbuild.yaml .\n  rm -v Dockerfile\n  rm cloudbuild.yaml\n}\nexport -f build_container\nfind ./../docker -mindepth 1 -maxdepth 1 -type d -exec bash -c 'build_container \"$0\"' {} \\; -printf '%f\\n'\n"]
null_resource.push_containers (local-exec): + export -f build_container
null_resource.push_containers (local-exec): + find ./../docker -mindepth 1 -maxdepth 1 -type d -exec bash -c 'build_container "$0"' '{}' ';' -printf '%f\n'
null_resource.push_containers (local-exec): find: -printf: unknown primary or operator

Error: Error running command 'set -x

build_container () {
  set -x
  cd $1
  container=$(basename $1)
  cp Dockerfile.template Dockerfile
  sed -i "s/((tezos_sentry_version))/latest-release/" Dockerfile
  sed -i "s/((tezos_private_version))/latest-release/" Dockerfile
  cat << EOY > cloudbuild.yaml
steps:
- name: 'gcr.io/cloud-builders/docker'
  args: ['build', '-t', "gcr.io/solo-tezos-baker/$container:tezos-latest", '.']
images: ["gcr.io/solo-tezos-baker/$container:tezos-latest"]
EOY
  gcloud builds submit --project solo-tezos-baker --config cloudbuild.yaml .
  rm -v Dockerfile
  rm cloudbuild.yaml
}
export -f build_container
find ./../docker -mindepth 1 -maxdepth 1 -type d -exec bash -c 'build_container "$0"' {} \; -printf '%f\n'
': exit status 1. Output: + export -f build_container
+ find ./../docker -mindepth 1 -maxdepth 1 -type d -exec bash -c 'build_container "$0"' '{}' ';' -printf '%f\n'
find: -printf: unknown primary or operator

I simply running apply with a few variables set:

project="the-baker"
cluster_name="the-baker-cluster"
kubernetes_namespace="tezos"
baking_nodes = {
  mynode = {
    mybaker = {
      public_baking_key="edpku3Xg8pYtZP8era5amwhLoip8YGnwpNXT1GJ1xpCDtkK3Pf93xx"
      public_baking_key_hash="tz1NfwaFPNrQi3icf37Ybz7bbqDmVmarFWxx"
      ledger_authorized_path="ledger://four-animal-words-here/ed25519/0h/1h"
      authorized_signers= {
          ssh_pubkey="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQClk976UOhyjMCfcvp5UxyhGM1Unh4lxGDlRCaZFrzBt7DkQRUBX+0EGSkyB7TI5bmGn5UW8OXSFpKJjFB6evZ8PJtUWy5T/TB2aSfMGpNrhDIJmLZ2hGOh7lxScvdjRhXd+plPBaTLoR/cdezSuYJs1OywHFYbqJ90msxHZilSXntTArTu9oCatChi9oNqcYbZM0BDJHMZWcTICtraIAt0b9uSzdPXT8UK/a32DkAMeU92x1xsGEPOOyaI9J4lFC7dpRaLmkYPEFjqRXyXHs2gS9P9VmsqIIRIM1+YUDCPZjWOq1hwxjfbHcF9jRMxG3U+D8S6i1567ZsY/W70cUxx baker@raspberrypi"
          signer_port="22"
          tunnel_endpoint_port="22"
      }
    }
  }
}

Curious if anyone else has run into this or what I may be doing wrong? Thanks!

nicolasochem commented 3 years ago

Thanks for the bug report.

Are you on Mac OS X? It looks like mac os x's find does not support printf option.

https://stackoverflow.com/a/752893/207209

rsmets commented 3 years ago

Thanks for the prompt reply Nicolas.

That is indeed the case. Upon using the suggestion in the supplied link I was able to continue with the terraforming.

However, curious why one would opt to have effectively a shell script in a terraform file in order to build an image when one could just have it hosted publicly for no cost? Feels a little counterintuitive unless I am missing something?

Upon letting the apply run I hit another snag in the similar shell script spot.

Error: Error running command 'set -x

build_container () {
  set -x
  cd $1
  container=$(basename $1)
  cp Dockerfile.template Dockerfile
  sed -i "s/((tezos_sentry_version))/latest-release/" Dockerfile
  sed -i "s/((tezos_private_version))/latest-release/" Dockerfile
  cat << EOY > cloudbuild.yaml
steps:
- name: 'gcr.io/cloud-builders/docker'
  args: ['build', '-t', "gcr.io/solo-tezos-baker/$container:tezos-latest", '.']
images: ["gcr.io/solo-tezos-baker/$container:tezos-latest"]
EOY
  gcloud builds submit --project solo-tezos-baker --config cloudbuild.yaml .
  rm -v Dockerfile
  rm cloudbuild.yaml
}
export -f build_container
find ./../docker -mindepth 1 -maxdepth 1 -type d -exec bash -c 'build_container "$0"' {} \; -print0 | xargs -0 stat -f '%i\n'
': exit status 1. Output: he end of D command
+ cat
+ gcloud builds submit --project solo-tezos-baker --config cloudbuild.yaml .
Creating temporary tarball archive of 4 file(s) totalling 1.4 KiB before compression.
Uploading tarball of [.] to [gs://solo-tezos-baker_cloudbuild/source/1614058707.159403-e3d6bb8e20234fdd900e72e42aa0b551.tgz]
Created [https://cloudbuild.googleapis.com/v1/projects/solo-tezos-baker/locations/global/builds/16a6c80c-0469-4f3e-9261-77c8a26c4033].
Logs are available at [https://console.cloud.google.com/cloud-build/builds/16a6c80c-0469-4f3e-9261-77c8a26c4033?project=662272710037].
ERROR: (gcloud.builds.submit) build 16a6c80c-0469-4f3e-9261-77c8a26c4033 completed with status "FAILURE"

...

Creating temporary tarball archive of 6 file(s) totalling 2.6 KiB before compression.
Uploading tarball of [.] to [gs://solo-tezos-baker_cloudbuild/source/1614058865.801133-78091a7a4b41485090e7e01162f4d2f2.tgz]
Created [https://cloudbuild.googleapis.com/v1/projects/solo-tezos-baker/locations/global/builds/7b73ee68-e58c-4572-8ec1-15e6820a91ab].
Logs are available at [https://console.cloud.google.com/cloud-build/builds/7b73ee68-e58c-4572-8ec1-15e6820a91ab?project=662272710037].
ERROR: (gcloud.builds.submit) build 7b73ee68-e58c-4572-8ec1-15e6820a91ab completed with status "FAILURE"
+ rm -v Dockerfile
+ rm cloudbuild.yaml
stat: illegal option -- -
usage: stat [-FlLnqrsx] [-f format] [-t timefmt] [file ...]
nicolasochem commented 3 years ago

Public images makes coordination of releases harder. I often deploy from my working dir and the current model suits that.

There is another project that I am working on which is releasing containers on docker hub. https://github.com/tqtezos/tezos-k8s

But, it does not support public baking yet.

I am not quite sure what exactly runs stat in the build command above. It looks like you are the first person trying tezos-on-gke on mac os.

rsmets commented 3 years ago

Huh, I guess I don't really understand why you feel "coordinating of [the] releases" is harder with public images, certainly sidesteps OS dependant shell scripts for one. Also ensures that everyone is using the same image instead of what was built locally. Creates a more dependable, repeatable deployment.

If the issue is the time to build and push to an image repo a CI job (github actions and ciricleci have generous free tiers) ought to solve that. Anyways just some suggestions.

Thanks again for your responsiveness. I suppose I could just run this from Ubuntu. I'll take a look at tezos-k8. Curious why you went with a totally new project?

nicolasochem commented 3 years ago

tezos-k8s was launched by the broader tezos dev ecosystem and has more use cases such as private chains.