superfly / flyctl

Command line tools for fly.io services
https://fly.io
Apache License 2.0
1.43k stars 239 forks source link

Exit code 1 after `deployed successfully` #1392

Closed alexander-applyinnovations closed 1 year ago

alexander-applyinnovations commented 2 years ago

Please only report specific issues with flyctl behavior. Anything like a support request for your application should go to https://community.fly.io. More people watch that space and can help you faster!

Describe the bug When deploying with flyctl deploy, the deployment succeeds but the command returns an exit code 1 and fails the github action.

Paste your fly.toml

app = "project-name-cms"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[deploy]
  release_command = "yarn deploy"
  strategy = "bluegreen"

[env]
  PORT = "8080"
  PRIMARY_REGION = "syd"

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

Command output:

flyctl deploy --remote-only --auto-confirm --now --verbose --app project-name-cms --region syd --env ENV_NAME=${{ env.ENV_NAME }} --env S3_BUCKET_NAME=${{ secrets.S3_BUCKET_NAME }} --env S3_REGION=${{ secrets.S3_REGION }} --env S3_ACCESS_KEY_ID=${{ secrets.S3_ACCESS_KEY_ID }} --env S3_SECRET_ACCESS_KEY=${{ secrets.S3_SECRET_ACCESS_KEY }}

==> Verifying app config
--> Verified app config
==> Building image
Waiting for remote builder fly-builder-little-night-4837...
Remote builder fly-builder-little-night-4837 ready
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
Sending build context to Docker daemon  316.3kB

#1 [internal] load remote build context
#1 DONE 0.0s

#2 copy /context /
#2 DONE 0.1s

#3 [internal] load metadata for docker.io/library/node:16-alpine
#3 DONE 0.5s

#4 [builder 1/6] FROM docker.io/library/node:16-alpine@sha256:2175727cef5cad4020cb77c8c101d56ed41d44fbe9b1157c54f820e3d345eab1
#4 resolve docker.io/library/node:16-alpine@sha256:2175727cef5cad4020cb77c8c101d56ed41d44fbe9b1157c54f820e3d345eab1 done
#4 DONE 0.0s

#5 [runner 2/6] WORKDIR /app
#5 CACHED

#6 [runner 3/6] RUN addgroup --system --gid 1001 nodejs
#6 CACHED

#7 [runner 4/6] RUN adduser --system --uid 1001 nextjs
#7 CACHED

     Preparing to run: `docker-entrypoint.sh yarn deploy` as nextjs
     2022/10/18 01:40:45 listening on [fdaa:0:bacf:a7b:9e6a:c7ca:bbfa:2]:22 (DNS: [fdaa::3]:53)
     yarn run v1.22.19
     $ keystone prisma migrate deploy
     Prisma schema loaded from schema.prisma
     Datasource "postgresql": PostgreSQL database "focapp_github_action_build_image_cms", schema "public" at "top2.nearest.of.focapp-github-action-build-image-db.internal:5432"
     Prisma schema loaded from schema.prisma
     Datasource "postgresql": PostgreSQL database "focapp_github_action_build_image_cms", schema "public" at "top2.nearest.of.focapp-github-action-build-image-db.internal:5432"
     4 migrations found in prisma/migrations
     4 migrations found in prisma/migrations
     Prisma schema loaded from schema.prisma
     Datasource "postgresql": PostgreSQL database "focapp_github_action_build_image_cms", schema "public" at "top2.nearest.of.focapp-github-action-build-image-db.internal:5432"
     4 migrations found in prisma/migrations
     Prisma schema loaded from schema.prisma
     Datasource "postgresql": PostgreSQL database "focapp_github_action_build_image_cms", schema "public" at "top2.nearest.of.focapp-github-action-build-image-db.internal:5432"
     4 migrations found in prisma/migrations
     No pending migrations to apply.
     Done in 8.84s.
     No pending migrations to apply.
     Done in 8.84s.
     No pending migrations to apply.
     Done in 8.84s.
     No pending migrations to apply.
     Done in 8.84s.
     Starting clean up.
     Starting clean up.
     Starting clean up.
     Starting clean up.
     Starting instance
     Configuring virtual machine
     Pulling container image
     Unpacking image
     Preparing kernel init
     Configuring firecracker
     Starting virtual machine
     Starting init (commit: 249766e)...
     Setting up swapspace version 1, size = 536866816 bytes
     UUID=962b6500-b059-4608-95e1-ded82498a548
     Preparing to run: `docker-entrypoint.sh yarn deploy` as nextjs
     2022/10/18 01:40:45 listening on [fdaa:0:bacf:a7b:9e6a:c7ca:bbfa:2]:22 (DNS: [fdaa::3]:53)
     yarn run v1.22.19
     $ keystone prisma migrate deploy
     Prisma schema loaded from schema.prisma
     Datasource "postgresql": PostgreSQL database "focapp_github_action_build_image_cms", schema "public" at "top2.nearest.of.focapp-github-action-build-image-db.internal:5432"
     4 migrations found in prisma/migrations
     No pending migrations to apply.
     Done in 8.84s.
     Starting clean up.
==> Monitoring deployment

v4 is being deployed
753b2eef: syd running healthy
753b2eef: syd running healthy [health checks: 1 total, 1 passing]
--> v4 deployed successfully
Error: Process completed with exit code 1.
alexander-applyinnovations commented 2 years ago

Looking through our other CI/CD logs, it seems like occasionally when deploying v0 we get --> v0 deployed successfully and the process exists without error (exit code 0), but when the deployment is replacing an existing version, it exists with error code 1.

==> Creating release
--> release v2 created

--> You can detach the terminal anytime without stopping the deployment
==> Release command detected: yarn deploy

--> This release will not be available until the release command succeeds.
     Starting instance
     Unpacking image
     Starting init (commit: 249766e)...
     $ keystone prisma migrate deploy
     Datasource "postgresql": PostgreSQL database "focapp_remove_users_cms", schema "public" at "top2.nearest.of.focapp-remove-users-db.internal:5432"
     Applying migration `20221013032218_image_to_images`
     Starting instance
     Unpacking image
     Starting init (commit: [249](https://github.com/applyinnovations/focapp/actions/runs/3248361363/jobs/5329474781#step:4:250)766e)...
     $ keystone prisma migrate deploy
     Datasource "postgresql": PostgreSQL database "focapp_remove_users_cms", schema "public" at "top2.nearest.of.focapp-remove-users-db.internal:5432"
     Applying migration `20221013032218_image_to_images`
     Starting clean up.
     Starting clean up.
     Starting instance
     Unpacking image
     Starting init (commit: 249766e)...
     $ keystone prisma migrate deploy
     Datasource "postgresql": PostgreSQL database "focapp_remove_users_cms", schema "public" at "top2.nearest.of.focapp-remove-users-db.internal:5432"
     Applying migration `20221013032218_image_to_images`
     Starting clean up.
==> Monitoring deployment

v0 is being deployed
dec94982: syd running healthy
dec94982: syd running unhealthy [health checks: 1 total]
dec94982: syd running healthy [health checks: 1 total, 1 passing]
--> v0 deployed successfully

no exit code 1

alexander-applyinnovations commented 2 years ago

However this is not always the case, also found this:

==> Creating release
--> release v2 created

--> You can detach the terminal anytime without stopping the deployment
==> Release command detected: yarn deploy

--> This release will not be available until the release command succeeds.
     Unpacking image
     2022/10/19 01:33:15 listening on [fdaa:0:bacf:a7b:9c3e:b50a:1b95:2]:22 (DNS: [fdaa::3]:53)
     yarn run v1.22.19
     $ keystone prisma migrate deploy
     Unpacking image
     Starting init (commit: 249766e)...
     UUID=8fa8e6fa-5586-4fae-b934-16f2ea9706bc
     2022/10/19 01:33:15 listening on [fdaa:0:bacf:a7b:9c3e:b50a:1b95:2]:22 (DNS: [fdaa::3]:53)
     yarn run v1.22.19
     $ keystone prisma migrate deploy
     Datasource "postgresql": PostgreSQL database "focapp_benefit_has_its_own_color_cms", schema "public" at "top2.nearest.of.focapp-benefit-has-its-own-color-db.internal:5432"
     Datasource "postgresql": PostgreSQL database "focapp_benefit_has_its_own_color_cms", schema "public" at "top2.nearest.of.focapp-benefit-has-its-own-color-db.internal:5432"
     Applying migration `20[221](https://github.com/applyinnovations/focapp/actions/runs/3278128907/jobs/5396196697#step:4:222)014080127_update_user_attributes`
     Applying migration `20221019011136_added_initial_data_validation_and_required_fields`
     Done in 9.75s.
     Applying migration `20221014080127_update_user_attributes`
     Applying migration `20221019011136_added_initial_data_validation_and_required_fields`
     Done in 9.75s.
     Starting clean up.
     Starting clean up.
     Unpacking image
     Starting init (commit: 249766e)...
     UUID=8fa8e6fa-5586-4fae-b934-16f2ea9706bc
     2022/10/19 01:33:15 listening on [fdaa:0:bacf:a7b:9c3e:b50a:1b95:2]:22 (DNS: [fdaa::3]:53)
     yarn run v1.22.19
     $ keystone prisma migrate deploy
     Datasource "postgresql": PostgreSQL database "focapp_benefit_has_its_own_color_cms", schema "public" at "top2.nearest.of.focapp-benefit-has-its-own-color-db.internal:5432"
     Applying migration `20221014080127_update_user_attributes`
     Applying migration `20221019011136_added_initial_data_validation_and_required_fields`
     Done in 9.75s.
     Starting clean up.
==> Monitoring deployment

v0 is being deployed
609f69b0: syd running healthy
609f69b0: syd running unhealthy [health checks: 1 total, 1 critical]
609f69b0: syd running healthy [health checks: 1 total, 1 passing]
--> v0 deployed successfully
Error: Process completed with exit code 1.
jsierles commented 2 years ago

Could you post a log with LOG_LEVEL=debug enabled?

redjonzaci commented 1 year ago

@jsierles do we want to leave this open until we get a response?