digitalocean / marketplace-partners

Image validation, automation, and other tools for DigitalOcean Marketplace Vendors and Custom Image users
Other
193 stars 98 forks source link

Packer build images failing DigitalOcean droplet snapshot creation with 504 gateway timeout errors ? #48

Closed centminmod closed 4 years ago

centminmod commented 5 years ago

I've built out my Centmin Mod LEMP stack's DO droplet snapshot image building routines using Packer https://github.com/centminmod/centminmod-digitalocean-marketplace/tree/master/packer#using-build-imagesh-script for preparing images for DO Vendor Market Place submission but my last few runs of Packer had ended in errors at snapshot image creation stage in Packer with DO API returning 504 gateway timeout errors ? It seems to be a Cloudflare 504 returned error I suspect it's protecting the DO API and something isn't configured correctly and Cloudflare isn't getting a response back from DO API ?

Cloudflare reports 504 error with Ray ID: 4ccedc82ca4f9336

My commands to build a Centmin Mod LEMP stack image were

cd /root/tools/centminmod-digitalocean-marketplace/packer
git stash
git pull
./build-image-with-kernel-ml.sh 44955XXX s-1vcpu-1gb

which builds a CentOS 7 image via Packer using Droplet size = s-1vcpu-1gb which defaults to using Linux 5.0.x mainline kernel using a previously updated golden CentOS 7 snapshot image id = 44955XXX

starting output

packer validate packer-centos7-basic.json
Template validated successfully.

packer inspect packer-centos7-basic.json
Optional variables and their defaults:

  do_image               = centos-7-x64
  do_image_name          = centos7-packer-snapshot-php72-{{timestamp}}
  do_region              = sfo2
  do_size                = c-2
  do_tags                = cmm
  do_token               = {{env `TOKEN`}}
  enable_argon           = n
  enable_brotli          = n
  enable_dualcerts       = n
  enable_logrotate_zstd  = n
  enable_phpfpm_systemd  = n
  enable_phppgo          = n
  install_auditd         = n
  install_bbr            = n
  install_customcurl     = n
  install_docker         = n
  install_elrepo         = n
  install_go             = n
  install_mariadbtenfour = n
  install_mariadbtentwo  = n
  install_mongodb        = n
  install_newergit       = n
  install_nodejs         = n
  install_redis          = n

Builders:

  digitalocean

Provisioners:

  shell
  file
  file
  shell
  shell

Note: If your build names contain user variables or template
functions such as 'timestamp', these are processed at build time,
and therefore only show in their raw form here.

time TMPDIR=/home/packertmp PACKER_LOG=1 packer build -var do_image=44955XXX -var do_size=s-1vcpu-1gb -var do_region=sfo2 -var enable_argon=y -var 'install_elrepo=y' -var 'install_bbr=y' -var 'install_redis=y' -var 'enable_phpfpm_systemd=y' packer-centos7-basic.json
digitalocean output will be in this color.

==> digitalocean: Creating temporary ssh key for droplet...
==> digitalocean: Creating droplet...
==> digitalocean: Waiting for droplet to become active...
==> digitalocean: Using ssh communicator to connect: 167.99.xxx.xxx
==> digitalocean: Waiting for SSH to become available...
==> digitalocean: Connected to SSH!
==> digitalocean: Provisioning with shell script: /home/packertmp/packer-shell655352819
==> digitalocean: Uploading scripts/first-login.sh => /opt/centminmod/
1 items:  42.29 KiB / 42.29 KiB [=====================================================================================================================================================================================================================] 0s
==> digitalocean: Uploading scripts/01-setup-first-login.sh => /var/lib/cloud/scripts/per-instance/
1 items:  1.30 KiB / 1.30 KiB [=======================================================================================================================================================================================================================] 0s
==> digitalocean: Provisioning with shell script: /home/packertmp/packer-shell072918681
==> digitalocean: Provisioning with shell script: scripts/cmm-install.sh
    digitalocean: LETSENCRYPT_DETECT='y'
    digitalocean: SWITCH_PHPFPM_SYSTEMD='y'
    digitalocean: NGINX_VIDEO='y'
    digitalocean: PHPFINFO='y'
    digitalocean: PHP_LZFOUR='y'
    digitalocean: PHP_LZF='y'
    digitalocean: PHP_ARGON='y'
    digitalocean:
    digitalocean:
    digitalocean: hostname: packer-5cc15a71-b807-6db8-9b11-e82628f10fc1
    digitalocean:
    digitalocean: Architecture:          x86_64
    digitalocean: CPU op-mode(s):        32-bit, 64-bit
    digitalocean: Byte Order:            Little Endian
    digitalocean: CPU(s):                1
    digitalocean: On-line CPU(s) list:   0
    digitalocean: Thread(s) per core:    1
    digitalocean: Core(s) per socket:    1
    digitalocean: Socket(s):             1
    digitalocean: NUMA node(s):          1
    digitalocean: Vendor ID:             GenuineIntel
    digitalocean: CPU family:            6
    digitalocean: Model:                 63
    digitalocean: Model name:            Intel(R) Xeon(R) CPU E5-2650L v3 @ 1.80GHz
    digitalocean: Stepping:              2
    digitalocean: CPU MHz:               1799.998
    digitalocean: BogoMIPS:              3599.99
    digitalocean: Virtualization:        VT-x
    digitalocean: Hypervisor vendor:     KVM
    digitalocean: Virtualization type:   full
    digitalocean: L1d cache:             32K
    digitalocean: L1i cache:             32K
    digitalocean: L2 cache:              256K
    digitalocean: L3 cache:              30720K
    digitalocean: NUMA node0 CPU(s):     0
    digitalocean: Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt

however when it comes time for Packer to shutdown the build droplet to create the resulting snapshot, it fails with DO API returning 504 gateway timeout

==> digitalocean: Gracefully shutting down droplet...
==> digitalocean: Creating snapshot: centos7-packer-snapshot-php72-1556175473
==> digitalocean: Waiting for snapshot to complete...
==> digitalocean: Error waiting for snapshot: GET https://api.digitalocean.com/v2/droplets/1414XXXXXX/actions/672746207: 504 <!DOCTYPE html>
==> digitalocean: <html>
==> digitalocean: <head>
==> digitalocean:   <title>DigitalOcean - Something went wrong!</title>
==> digitalocean:   <style type="text/css" >body{background-color:#fff;margin:0;padding:0;font-family:"Proxima Nova",Helvetica,sans-serif}h1{font-size:40px;color:#4b4b4b;font-weight:700;text-align:center;margin-top:0;margin-bottom:0;padding:0 10px}.sub-copy a{color:#474747;border-bottom:1px dotted #474747;text-decoration:none}.sub-copy{font-size:24px;font-weight:400;color:#3686be;line-height:1.5;max-width:800px;margin:0 auto;text-align:center;padding:15px 10px 0}.sammy{display:block;margin:0 auto;max-width:100%;position:relative;left:-50px}.header{background:#3686be;padding:40px}.header a,.header img{margin:0 auto;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BNLx43hfS51HooFyH9qYKqkGZ37hZnOaRz7kc8ZMLQ7cXshTx5HQuZ05ysy0ZIZOeRjyHDegtDQUVmJ6qyvTlkR/xDecYe7pZz1SGLyhp3Z2JoZ988C9k2Xprmq2xMpn9ol3mViaVEmiISPQN98ZBDsdS+tVdcaCmdDjnXNlZYt5adrZirrQp54tXByoZVRXTMd1eH/LK3e+bGyv6pBwbON4X8FCt5+z2ynHWKzr/sLQv5rangRDLa/4eChmOVXw8PVof1o2jbl8Zvk/tn6z9Fo9fq61tTk6ONe941BwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/ge/BBgAc8GKsbXnyeIAAAAASUVORK5CYII=);background-size:100px 100px;background-repeat:repeat-x;opacity:1}.cf-error-details{max-width:800px;margin:40px auto 0;text-align:center}.cf-error-details p{max-width:600px;margin:20px auto 0}.cf-error-details ul{list-style-type:none;line-height:20px}</style>
==> digitalocean: 
==> digitalocean: 
==> digitalocean: </head>
==> digitalocean: 
==> digitalocean: <body>
==> digitalocean:   <div class="header">
==> digitalocean:     <a href="https://www.digitalocean.com"><img src="data:image/png; charset=binary;base64,iVBORw0KGgoAAAANSUhEUgAAALUAAAA0CAQAAABmtrFfAAAJ9UlEQVR4Ae3aCZDU1Z0H8E/PycDACOEajlEOERFFiZHDxDtxo1GUIJh4YhZX3F1TFdcjsqEi0VITNYvuuiqisaIkbvCKwu6yClEwiIDiAQgMhw4mJERhHO45ftv1r+mukWGEIcYqq/rzLaq73ntFz3z79b9ed0/K5yQnT06u6lzVObmqc1Xn5KrOVZ2rOidXda7qnL0VOGDRywiDddHgA29YZItWyCkIB6SrK11okBRgt9dN95jdcg5QKhyAy92um+beco2XfEZyVRe411UydqiRp5N8QJ1/MdVnIlf1gyaAHX5phuW2KdTdicY7GXClabjQSAFWul+r5aoe72GE37nDZqW2qrIF8F1TdUatEy32mIsA852klXInkG7uAlXa+I06a7xvow3mWKXBDG94Wl95fupUO2Rs12q5qi/REVT4yHhz1IACb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aMylqI6Myzg4xIvP/J5bFiVEab0XGrPhVcsYWb0REbXQJISTtbYuHQgip0ERPcwzCbA8Z7Fpl2ObPqtUpdohuisl6zW89ZSXoop8NNtmXwVapBeQZaamdZJ2jp4yw1bveJOtMfTR4yQKd/cDPQYEfmpLMlSi306/tRmff0cOH5lmqjXEGqfWWmYpcZLfHHGcY/scGGUf6qgptbLPGyzZq6ihn6G6HFdkjQhvfdLQSWywzTy06uUA/Oy32vE7G2OS3Rim3y6/tAt/WxXbrvIK9qqaHp7zsefcaYJZnLVZlhwB0MMRZRhsgo948j5ilWncXqPCWRd6zG7RxmDOc5AFzBSgzwTMqtdYQy3CnyXaik6kuVm2gTV/s7xYLXJjOr7yss+FOcLgvKVKvWpV3vGqJj3zFpc7TXcYmT3rUYt1d4lu6q02nnc7yzTPJcsBoF7vbAq1XbI6T8IEqBQ5Xhonu54tddb90ipzrFN3t9JGP7dSgQFuH6Ky9Buu97Ekr9HV2OgNlLPdCckFpr4/u+IM3bAUDnO8sVSZb5+B8yWRj9AB1FviZ2Xyxq04lh6muVnjHRh9r0FShMuWOcJyj5XnJTO85yulOcZwKwB5vWGylTWqVOdQggx1iqXv8zl+nVB+d7PGB9+GLXnWeMtUa7F+JYw3ykfn+gmJ9DHSE/nrppoMCtWp8aKNVllpiC7m/A/FXqVCgSq2MlA7aKZavwW4fq9Fcruqc3N9X56rOyVWdqzpXdU6u6lzVObmqc1Xn5Kr+vP0/7Avj+KATCRMAAAAASUVORK5CYII="></a>
==> digitalocean:   </div>
==> digitalocean:   <div class="waves"></div>
==> digitalocean:   <div class="oops-copy">
==> digitalocean:     <h1>Looks like something went wrong...</h1>
==> digitalocean:     <p class="sub-copy">If this keeps happening, check out <a href="https://status.digitalocean.com/">status.digitalocean.com</a>.</p>
==> digitalocean:     <div class="cf-error-details cf-error-504">
==> digitalocean:   <h1>Gateway time-out</h1>
==> digitalocean:   <p>The web server reported a gateway time-out error.</p>
==> digitalocean:   <ul class="cferror_details">
==> digitalocean:     <li>Ray ID: 4ccedc82ca4f9336</li>
==> digitalocean:     <li>Your IP address: 159.65.xxx.xxx</li>
==> digitalocean:     <li>Error reference number: 504</li>
==> digitalocean:     <li>Cloudflare Location: San Jose</li>
==> digitalocean:   </ul>
==> digitalocean: </div>
==> digitalocean: 
==> digitalocean:   </div>
==> digitalocean: </body>
==> digitalocean: </html>
==> digitalocean: Destroying droplet...
==> digitalocean: Deleting temporary ssh key...
Build 'digitalocean' errored: Error waiting for snapshot: GET https://api.digitalocean.com/v2/droplets/1414XXXXXX/actions/672746207: 504 <!DOCTYPE html>

Part of the Packer build script routine is I inspect the droplet's IP geo data and looks like Cloudflare reported issue with Ray ID: 4ccedc82ca4f9336

==> digitalocean:   <div class="waves"></div>
==> digitalocean:   <div class="oops-copy">
==> digitalocean:     <h1>Looks like something went wrong...</h1>
==> digitalocean:     <p class="sub-copy">If this keeps happening, check out <a href="https://status.digitalocean.com/">status.digitalocean.com</a>.</p>
==> digitalocean:     <div class="cf-error-details cf-error-504">
==> digitalocean:   <h1>Gateway time-out</h1>
==> digitalocean:   <p>The web server reported a gateway time-out error.</p>
==> digitalocean:   <ul class="cferror_details">
==> digitalocean:     <li>Ray ID: 4ccedc82ca4f9336</li>
==> digitalocean:     <li>Your IP address: 159.65.xxx.xxx</li>
==> digitalocean:     <li>Error reference number: 504</li>
==> digitalocean:     <li>Cloudflare Location: San Jose</li>
==> digitalocean:   </ul>
==> digitalocean: </div>

I see status entry at https://status.digitalocean.com/incidents/m9b2g31t4g9z for 9hrs ago with DO API issues, but my issue is happening around 25 mins ago. Is it an DO API issue and/or a Cloudflare configuration issue for protected DO API ?

jgannondo commented 5 years ago

@andrewsomething thoughts on if this is an API issue? Thanks for any feedback you might be able to provide.

jgannondo commented 4 years ago

@centminmod I talked with @andrewsomething who thinks that this was likely a transient issue. We've also made recent improvements to how we handle timeouts in our services that power the DO API. I'll close this out but please re-open if you continue to see issues. Thanks again for reporting this to us.