Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response code 502 (Bad Gateway) #201

Closed
maxime1992 opened this issue Jan 28, 2019 · 24 comments
Closed

Response code 502 (Bad Gateway) #201

maxime1992 opened this issue Jan 28, 2019 · 24 comments

Comments

@maxime1992
Copy link

Hi,

I'm trying to deploy my project but unfortunately I keep getting 502 (Bad Gateway)

No .exoframeignore file found, using default ignores

Ignoring following paths: [ '.git', 'node_modules', '.exoframeignore' ]
0 Bytes
10.56 KB
10.56 KB
Error deploying project: HTTPError: Response code 502 (Bad Gateway)
Build log:

No log available

Original error: { HTTPError: Response code 502 (Bad Gateway)
    at EventEmitter.emitter.on.response (/home/maxime/.config/yarn/global/node_modules/got/source/as-stream.js:35:24)
    at emitOne (events.js:116:13)
    at EventEmitter.emit (events.js:211:7)
    at module.exports (/home/maxime/.config/yarn/global/node_modules/got/source/get-response.js:22:10)
    at ClientRequest.handleResponse (/home/maxime/.config/yarn/global/node_modules/got/source/request-as-event-emitter.js:139:5)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:121:20)
    at ClientRequest.emit (events.js:211:7)
    at ClientRequest.origin.emit.args [as emit] (/home/maxime/.config/yarn/global/node_modules/@szmarczak/http-timer/source/index.js:36:11)
    at HTTPParser.parserOnIncomingClient (_http_client.js:543:21)
  name: 'HTTPError',
  host: 'my-url.com',
  hostname: 'my-url.com',
  method: 'POST',
  path: '/deploy',
  socketPath: undefined,
  protocol: 'https:',
  url: 'https://my-url.com/deploy',
  statusCode: 502,
  statusMessage: 'Bad Gateway',
  headers:
   { 'content-type': 'text/plain; charset=utf-8',
     vary: 'Accept-Encoding',
     date: 'Mon, 28 Jan 2019 19:38:17 GMT',
     'content-length': '11',
     connection: 'close' },
  body: undefined }
Original response: undefined

I'm trying to deploy from Docker-Compose and I've made it really simple to try to narrow down the issue:

version: '3'
services:
  db-backend-mysql:
    image: mysql:5.7
    environment:
      - MYSQL_ROOT_PASSWORD=my-pwd
    ports:
      - 3307:3306
    volumes:
      - /home/dev/mysql:/var/lib/mysql

And my exoframe.json

{
  "name": "my-app",
  "restart": "no",
  "project": "my-app",
  "domain": "my-url.com"
}
@yamalight
Copy link
Contributor

@maxime1992 is there anything in the logs of the exoframe server?

@maxime1992
Copy link
Author

How can I access them?

If you mean exoframe logs it does require to target a deployed project right? But that one is not yet deployed so not sure to follow or how to access it.

@yamalight
Copy link
Contributor

@maxime1992 currently you'd need to run docker logs exoframe-server directly.
It's probably a good idea to add that as an exoframe command though 🤔

@maxime1992
Copy link
Author

maxime1992 commented Jan 28, 2019

Thanks for the command 👍

Here are the logs

# docker logs exoframe-server 
[exoframe-server] › ℹ  info                         Initializing docker services...
[exoframe-server] › ℹ  info                         Traefik already running, docker init done!
[exoframe-server] › ℹ  info                         Server running at: 8080
(node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'Id' of undefined
    at exports.executeTemplate.Promise.all.Object.keys.map.map.map.info (/snapshot/exoframe-server/src/docker/templates/compose.js:282:52)
    at Array.map (<anonymous>)
    at Object.exports.executeTemplate (/snapshot/exoframe-server/src/docker/templates/compose.js:282:8)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'Id' of undefined
    at exports.executeTemplate.Promise.all.Object.keys.map.map.map.info (/snapshot/exoframe-server/src/docker/templates/compose.js:282:52)
    at Array.map (<anonymous>)
    at Object.exports.executeTemplate (/snapshot/exoframe-server/src/docker/templates/compose.js:282:8)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
[exoframe-server] › ℹ  info                         Initializing docker services...
[exoframe-server] › ℹ  info                         Traefik already running, docker init done!
[exoframe-server] › ℹ  info                         Server running at: 808

It's probably a good idea to add that as an exoframe command though

Might be cool 🙌

EDIT

I've recently updated all and before I was able to deploy with docker-compose so I wonder if that's not a recent bug (maybe not)

@yamalight
Copy link
Contributor

@maxime1992 seems like it's failing to get service info after executing compose.
can you try running deploy with very verbose mode (with -vvv flag) and see if there's anything in the logs?

@maxime1992
Copy link
Author

The first log I've posted was produced with that command:

exoframe deploy -u -vvv

(gives the same whether I use -u or not)

@yamalight
Copy link
Contributor

@maxime1992 aha, got it.
The next question would be - do you already have services from current compose in docker? (running or stopped / exited)

@maxime1992
Copy link
Author

Ah! Maybe stopped 🤔 ?

Because docker ps gives me only exoframe and traefik for now.

But I have some when I do docker ps -a.

Gonna try to remove them and redeploy 👍

@maxime1992
Copy link
Author

@yamalight just tried to remove every containers.

When running docker ps -a I now only have traefik and exoframe.

Tried to deployed once again but still the same error 🤔

@yamalight
Copy link
Contributor

@maxime1992 alright. next guess - I've noticed that you are mapping your port to external one - are you sure that port is free? 🤔

@maxime1992
Copy link
Author

maxime1992 commented Jan 28, 2019

According to netstat -antu port 3307 is free.

Are you refering to the port of mysql?

If not which port?

(thanks for your patience!)

EDIT: Just tried to comment out the port mapping for mysql within the Docker compose and deployed again: Same error.

@yamalight
Copy link
Contributor

@maxime1992 I am referring to port of mysql, yes. alright, so that's not it 🤔
alright, next question - can you try deploying that compose file manually with docker? does that work? 🤔

@maxime1992
Copy link
Author

@yamalight sure.

Just tried both locally and on the server: Both working fine

@yamalight
Copy link
Contributor

@maxime1992 alright, this is really weird 😅
I'm leaving for a business trip in a few hours, but I think I'll need to try and reproduce this once I'm back next week 🤔
You could try to run exoframe-server in dev mode (without docker, with full logs) on your server and see what's wrong. I should also probably setup some sort of dev-mode image for that 🤔

@maxime1992
Copy link
Author

Oh ok have a good trip then! 🙌

I really need to somehow deploy this week end so I think I'll just deploy image by image (if that work).
If you have any better idea in the meantime let me know :)

Have a good week!

@maxime1992
Copy link
Author

@yamalight hi!

I need to deploy this we and so I've decided to just destroy and recreate the exoframe server hoping that it'd work 😄. Which it did. Until I called exoframe rm ... and remove all the services.

Then when I tried to deploy I had the error Cannot read property 'Id' of undefined.

I think that might be helpful info to debug :)

@maxime1992
Copy link
Author

=( nevermind. Removed it again, created a brand new one and I still have the error now

@yamalight
Copy link
Contributor

@maxime1992 could you try running exoframe-server locally and reproducing this? does it also happens? or is this something that only happens on your server? 🤔

@maxime1992
Copy link
Author

@yamalight I'd be glad to but it might be really hard to reproduce IMO 🤔

I'm going to try to run exoframe in dev mode on my server. I'll let you know if I manage to do that!

@maxime1992
Copy link
Author

HA! GOT IT!

So I managed to build a dev image on the server and tried to run the deploy again.

[exoframe-server] › ⬤  debug                        Compose build executed, exit code: 0
[exoframe-server] › ⬤  debug                        Compose up executed, exit code: { code: '1',
  log: 
   [ 'Pulling frontend (registry.gitlab.com/my-image)...',
     'Get https://registry.gitlab.com/v2/my-username/my-repo/manifests/my-tag: denied: access forbidden' ] }
(node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'Id' of undefined
    at exports.executeTemplate.Promise.all.Object.keys.map.map.map.info (/snapshot/exoframe-server-debug/src/docker/templates/compose.js:282:52)
    at Array.map (<anonymous>)
    at Object.exports.executeTemplate (/snapshot/exoframe-server-debug/src/docker/templates/compose.js:282:8)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

So now it makes total sense 👍

My private image cannot be fetched by Docker. (CF #117 and exoframejs/exoframe-server#19).

And to give a try on the server at some point I logged into my private registry, and downloaded the image. From there, Docker-Compose was able to start 👍! But then when I removed it and launched a deploy again... 💥

I thought that as I logged into my private registry from the server, Docker-Compose would be able to work from there. It seems that it's not the case 🤷‍♂️ We discussed it here exoframejs/exoframe-server#19 (comment).

Any idea @yamalight? Maybe exoframe is handling that in the end? Or the Docker-Compose running from exoframe doesn't have access to my credentials?

I should definitely try to finish up my PR but if I can have a workaround first to deploy my project that'd be great (another workaround that pulling the new image manually before running my build on CI 😓)

@yamalight
Copy link
Contributor

Ah! I think I know what the problem is - currently exoframe-server uses docker-compose that it has installed inside the image! Hence it doesn't get your local compose config.
So, you'd need to somehow pass that config to it 🤔

@yamalight
Copy link
Contributor

I'm closing this due to inactivity. Feel free to re-open if needed.

@maxime1992
Copy link
Author

Hi @yamalight, I'm still hitting that error and have no other way of loging into ssh onto my server, pull the images I need first, and then manually start a CI task to deploy 😓

It's not a really automated workflow :D ! Have I been the only one facing that issue with private repos? I'm quite surprised honnestly but maybe everyone just have public images 🤷‍♂️

@yamalight
Copy link
Contributor

We do have an issue for private repos (#117), but I haven't had time to look into it at all.
PRs welcome though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants