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

INIT: Auth App Deployment Init Page [MVP] #176

Closed
7 tasks done
nelsonic opened this issue Feb 2, 2022 · 18 comments
Closed
7 tasks done

INIT: Auth App Deployment Init Page [MVP] #176

nelsonic opened this issue Feb 2, 2022 · 18 comments
Assignees
Labels
awaiting-review An issue or pull request that needs to be reviewed BLOCKED :fire: Core team's HIGHEST priority, blocking critical work chore a tedious but necessary task often paying technical debt enhancement New feature or enhancement of existing functionality help wanted If you can help make progress with this issue, please comment! needs-ui A feature idea that needs UI in order to be discussed/built. priority-1 Highest priority issue. This is costing us money every minute that passes. T4h Time Estimate 4 Hours tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written technical A technical issue that requires understanding of the code, infrastructure or dependencies

Comments

@nelsonic
Copy link
Member

nelsonic commented Feb 2, 2022

At present the engineer deploying auth has no way of knowing the status of their deployment ... 🙈

We are trying to deploy to a new cloud provider Fly.io #172 / #173 and seeing the following in the browser:
https://authprod.fly.dev/
image

The logs are moderately useful:

image

2022-02-02T20:41:50.005 app[597369ab] lhr [info]Request: GET /
2022-02-02T20:41:50.005 app[597369ab] lhr [info]** (exit) an exception was raised:
2022-02-02T20:41:50.005 app[597369ab] lhr [info]    ** (Ecto.ConstraintError) constraint error when attempting to insert struct:
2022-02-02T20:41:50.005 app[597369ab] lhr [info]    * logs_app_id_fkey (foreign_key_constraint)
2022-02-02T20:41:50.005 app[597369ab] lhr [info]If you would like to stop this constraint violation from raising an
2022-02-02T20:41:50.005 app[597369ab] lhr [info]exception and instead add it as an error to your changeset, please
2022-02-02T20:41:50.005 app[597369ab] lhr [info]call `foreign_key_constraint/3` on your changeset with the constraint
2022-02-02T20:41:50.005 app[597369ab] lhr [info]`:name` as an option.
2022-02-02T20:41:50.005 app[597369ab] lhr [info]The changeset has not defined any constraint.
2022-02-02T20:41:50.005 app[597369ab] lhr [info]        (ecto 3.7.1) lib/ecto/repo/schema.ex:783: anonymous fn/4 in Ecto.Repo.Schema.constraints_to_errors/3
2022-02-02T20:41:50.005 app[597369ab] lhr [info]        (elixir 1.12.3) lib/enum.ex:1582: Enum."-map/2-lists^map/1-0-"/2
2022-02-02T20:41:50.005 app[597369ab] lhr [info]        (ecto 3.7.1) lib/ecto/repo/schema.ex:768: Ecto.Repo.Schema.constraints_to_errors/3
2022-02-02T20:41:50.005 app[597369ab] lhr [info]        (ecto 3.7.1) lib/ecto/repo/schema.ex:749: Ecto.Repo.Schema.apply/4
2022-02-02T20:41:50.005 app[597369ab] lhr [info]        (ecto 3.7.1) lib/ecto/repo/schema.ex:367: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
2022-02-02T20:41:50.005 app[597369ab] lhr [info]        (ecto 3.7.1) lib/ecto/repo/schema.ex:269: Ecto.Repo.Schema.insert!/4
2022-02-02T20:41:50.005 app[597369ab] lhr [info]        (auth 1.6.5) lib/auth/log.ex:54: Auth.Log.insert/2
2022-02-02T20:41:50.005 app[597369ab] lhr [info]        (auth 1.6.5) lib/auth_web/controllers/auth_controller.ex:41: AuthWeb.AuthController.index/2

Note: I don't see an advantage to having a Foreign Key Constraint between logs and apps (the reason this is crashing)

Todo

https://www.githubstatus.com/
image

check-icon

https://status.fellow.app/
image

status-icon
https://status.fellow.app/static/media/ok-status-icon.a40ffb2d.svg

Related to improving seeds.exs init process #174

@nelsonic nelsonic added enhancement New feature or enhancement of existing functionality help wanted If you can help make progress with this issue, please comment! priority-1 Highest priority issue. This is costing us money every minute that passes. chore a tedious but necessary task often paying technical debt T4h Time Estimate 4 Hours technical A technical issue that requires understanding of the code, infrastructure or dependencies needs-ui A feature idea that needs UI in order to be discussed/built. BLOCKED :fire: Core team's HIGHEST priority, blocking critical work tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written labels Feb 2, 2022
@nelsonic nelsonic self-assigned this Feb 2, 2022
@nelsonic
Copy link
Member Author

nelsonic commented Feb 2, 2022

http://localhost:4000/status
image

This is a fairly helpful error message. I'd hope the person setting up auth could work out what to do here ... 💭

@nelsonic
Copy link
Member Author

nelsonic commented Feb 2, 2022

Scrolling up through the logs, we see that some genius has a bot hitting the server with requests trying to access the database:

image

This is why we can't have nice things ... 🤦‍♂️
It's also why you cannot have an unprotected PHP / MySQL (PHPMyAdmin) instance running anywhere ...

2022-02-02T14:13:12.670 app[597369ab] lhr [info]14:13:12.669 request_id=Fs_9kgjKQzusGy4AABex [info] Sent 404 in 479µs
2022-02-02T14:13:12.671 app[597369ab] lhr [info]14:13:12.669 request_id=Fs_9kgjKQzusGy4AABex [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:13.106 app[597369ab] lhr [info]14:13:13.105 request_id=Fs_9kiLVe1LDcK4AABfB [info] GET /php-myadmin/index.php
2022-02-02T14:13:13.106 app[597369ab] lhr [info]14:13:13.105 request_id=Fs_9kiLVe1LDcK4AABfB [info] Sent 404 in 309µs
2022-02-02T14:13:13.106 app[597369ab] lhr [info]14:13:13.105 request_id=Fs_9kiLVe1LDcK4AABfB [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:13.722 app[597369ab] lhr [info]14:13:13.722 request_id=Fs_9kkeV7dFqeucAABfR [info] GET /phpmyadmin1/index.php
2022-02-02T14:13:13.723 app[597369ab] lhr [info]14:13:13.722 request_id=Fs_9kkeV7dFqeucAABfR [info] Sent 404 in 320µs
2022-02-02T14:13:13.723 app[597369ab] lhr [info]14:13:13.722 request_id=Fs_9kkeV7dFqeucAABfR [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:14.178 app[597369ab] lhr [info]14:13:14.178 request_id=Fs_9kmLAhCywjmAAABfh [info] GET /administrator/phpMyAdmin/index.php
2022-02-02T14:13:14.178 app[597369ab] lhr [info]14:13:14.178 request_id=Fs_9kmLAhCywjmAAABfh [info] Sent 404 in 324µs
2022-02-02T14:13:14.179 app[597369ab] lhr [info]14:13:14.178 request_id=Fs_9kmLAhCywjmAAABfh [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:14.640 app[597369ab] lhr [info]14:13:14.640 request_id=Fs_9kn5PGPJUxj8AABfx [info] GET /phpmyadmin2012/index.php
2022-02-02T14:13:14.641 app[597369ab] lhr [info]14:13:14.640 request_id=Fs_9kn5PGPJUxj8AABfx [info] Sent 404 in 316µs
2022-02-02T14:13:14.641 app[597369ab] lhr [info]14:13:14.640 request_id=Fs_9kn5PGPJUxj8AABfx [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:15.079 app[597369ab] lhr [info]14:13:15.078 request_id=Fs_9kphxMsfnpiwAABgB [info] GET /administrator/db/index.php
2022-02-02T14:13:15.080 app[597369ab] lhr [info]14:13:15.079 request_id=Fs_9kphxMsfnpiwAABgB [info] Sent 404 in 479µs
2022-02-02T14:13:15.080 app[597369ab] lhr [info]14:13:15.079 request_id=Fs_9kphxMsfnpiwAABgB [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:16.495 app[597369ab] lhr [info]14:13:16.494 request_id=Fs_9kuzWjIpJ7YYAABgR [info] GET /php-my-admin/index.php
2022-02-02T14:13:16.495 app[597369ab] lhr [info]14:13:16.495 request_id=Fs_9kuzWjIpJ7YYAABgR [info] Sent 404 in 307µs
2022-02-02T14:13:16.495 app[597369ab] lhr [info]14:13:16.495 request_id=Fs_9kuzWjIpJ7YYAABgR [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:17.047 app[597369ab] lhr [info]14:13:17.046 request_id=Fs_9kw28fXaJnUUAABgh [info] GET /sql/phpMyAdmin2/index.php
2022-02-02T14:13:17.047 app[597369ab] lhr [info]14:13:17.047 request_id=Fs_9kw28fXaJnUUAABgh [info] Sent 404 in 311µs
2022-02-02T14:13:17.047 app[597369ab] lhr [info]14:13:17.047 request_id=Fs_9kw28fXaJnUUAABgh [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:17.468 app[597369ab] lhr [info]14:13:17.468 request_id=Fs_9kybdU7cX0rQAABgx [info] GET /phpmyadmin2015/index.php
2022-02-02T14:13:17.469 app[597369ab] lhr [info]14:13:17.468 request_id=Fs_9kybdU7cX0rQAABgx [info] Sent 404 in 300µs
2022-02-02T14:13:17.469 app[597369ab] lhr [info]14:13:17.468 request_id=Fs_9kybdU7cX0rQAABgx [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:18.506 app[597369ab] lhr [info]14:13:18.505 request_id=Fs_9k2SxzqVlnpIAABhB [info] GET /phpMyAdmin-5.1.1-english/index.php
2022-02-02T14:13:18.506 app[597369ab] lhr [info]14:13:18.506 request_id=Fs_9k2SxzqVlnpIAABhB [info] Sent 404 in 479µs
2022-02-02T14:13:18.507 app[597369ab] lhr [info]14:13:18.506 request_id=Fs_9k2SxzqVlnpIAABhB [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:18.876 app[597369ab] lhr [info]14:13:18.875 request_id=Fs_9k3q7UdrTi_wAABhR [info] GET /mysql/mysqlmanager/index.php
2022-02-02T14:13:18.877 app[597369ab] lhr [info]14:13:18.875 request_id=Fs_9k3q7UdrTi_wAABhR [info] Sent 404 in 555µs
2022-02-02T14:13:18.877 app[597369ab] lhr [info]14:13:18.876 request_id=Fs_9k3q7UdrTi_wAABhR [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:19.264 app[597369ab] lhr [info]14:13:19.263 request_id=Fs_9k5HiUfUAIqYAABhh [info] GET /phpMyAdmin-5.1.1/index.php
2022-02-02T14:13:19.266 app[597369ab] lhr [info]14:13:19.264 request_id=Fs_9k5HiUfUAIqYAABhh [info] Sent 404 in 630µs
2022-02-02T14:13:19.266 app[597369ab] lhr [info]14:13:19.264 request_id=Fs_9k5HiUfUAIqYAABhh [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:19.812 app[597369ab] lhr [info]14:13:19.811 request_id=Fs_9k7KLlfCzWWYAABhx [info] GET /mysql/db/index.php
2022-02-02T14:13:19.812 app[597369ab] lhr [info]14:13:19.812 request_id=Fs_9k7KLlfCzWWYAABhx [info] Sent 404 in 301µs
2022-02-02T14:13:19.813 app[597369ab] lhr [info]14:13:19.812 request_id=Fs_9k7KLlfCzWWYAABhx [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:20.225 app[597369ab] lhr [info]14:13:20.224 request_id=Fs_9k8ssBRPZYXIAABiB [info] GET /administrator/pma/index.php
2022-02-02T14:13:20.226 app[597369ab] lhr [info]14:13:20.225 request_id=Fs_9k8ssBRPZYXIAABiB [info] Sent 404 in 448µs
2022-02-02T14:13:20.226 app[597369ab] lhr [info]14:13:20.225 request_id=Fs_9k8ssBRPZYXIAABiB [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:22.591 app[597369ab] lhr [info]14:13:22.590 request_id=Fs_9lFgsngEcJIYAABiR [info] GET /administrator/db/index.php
2022-02-02T14:13:22.592 app[597369ab] lhr [info]14:13:22.591 request_id=Fs_9lFgsngEcJIYAABiR [info] Sent 404 in 541µs
2022-02-02T14:13:22.592 app[597369ab] lhr [info]14:13:22.591 request_id=Fs_9lFgsngEcJIYAABiR [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:22.956 app[597369ab] lhr [info]14:13:22.955 request_id=Fs_9lG3zhyrX3MQAABih [info] GET /sql/sqladmin/index.php
2022-02-02T14:13:22.957 app[597369ab] lhr [info]14:13:22.956 request_id=Fs_9lG3zhyrX3MQAABih [info] Sent 404 in 541µs
2022-02-02T14:13:22.957 app[597369ab] lhr [info]14:13:22.956 request_id=Fs_9lG3zhyrX3MQAABih [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:23.478 app[597369ab] lhr [info]14:13:23.477 request_id=Fs_9lI0PUfyTNkwAABix [info] GET /phpmyadmin2014/index.php
2022-02-02T14:13:23.479 app[597369ab] lhr [info]14:13:23.478 request_id=Fs_9lI0PUfyTNkwAABix [info] Sent 404 in 365µs
2022-02-02T14:13:23.479 app[597369ab] lhr [info]14:13:23.478 request_id=Fs_9lI0PUfyTNkwAABix [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:23.940 app[597369ab] lhr [info]14:13:23.939 request_id=Fs_9lKiPM0dbWVAAABjB [info] GET /db/phpmyadmin3/index.php
2022-02-02T14:13:23.940 app[597369ab] lhr [info]14:13:23.939 request_id=Fs_9lKiPM0dbWVAAABjB [info] Sent 404 in 321µs
2022-02-02T14:13:23.940 app[597369ab] lhr [info]14:13:23.939 request_id=Fs_9lKiPM0dbWVAAABjB [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:26.481 app[597369ab] lhr [info]14:13:26.480 request_id=Fs_9lUABSZxUPNEAABjR [info] GET /db/dbweb/index.php
2022-02-02T14:13:26.481 app[597369ab] lhr [info]14:13:26.480 request_id=Fs_9lUABSZxUPNEAABjR [info] Sent 404 in 490µs
2022-02-02T14:13:26.482 app[597369ab] lhr [info]14:13:26.480 request_id=Fs_9lUABSZxUPNEAABjR [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:27.997 app[597369ab] lhr [info]14:13:27.996 request_id=Fs_9lZpgllJ24s8AABjh [info] GET /2phpmyadmin/index.php
2022-02-02T14:13:27.998 app[597369ab] lhr [info]14:13:27.996 request_id=Fs_9lZpgllJ24s8AABjh [info] Sent 404 in 516µs
2022-02-02T14:13:27.998 app[597369ab] lhr [info]14:13:27.996 request_id=Fs_9lZpgllJ24s8AABjh [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:13:28.971 app[597369ab] lhr [info]14:13:28.970 request_id=Fs_9ldR06knxUOgAABjx [info] GET /sql/phpmy-admin/index.php
2022-02-02T14:13:28.971 app[597369ab] lhr [info]14:13:28.971 request_id=Fs_9ldR06knxUOgAABjx [info] Sent 404 in 549µs
2022-02-02T14:13:28.972 app[597369ab] lhr [info]14:13:28.971 request_id=Fs_9ldR06knxUOgAABjx [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T14:14:17.916 app[597369ab] lhr [info]14:14:17.916 request_id=Fs_9oTnisfUx0uoAABkB [info] GET /admin/index.php
2022-02-02T14:14:17.917 app[597369ab] lhr [info]14:14:17.916 request_id=Fs_9oTnisfUx0uoAABkB [info] Sent 404 in 545µs
2022-02-02T14:14:17.918 app[597369ab] lhr [info]14:14:17.916 request_id=Fs_9oTnisfUx0uoAABkB [debug] Converted error Phoenix.Router.NoRouteError to 404 response
2022-02-02T15:05:37.514 app[597369ab] lhr [info]15:05:37.513 request_id=FtAAbkAzK80Ix9YAABkR [info] GET /_ignition/execute-solution

Tempted to extract all these links and investigate what the script is ... and block them on CloudFlare ... 💭

@nelsonic
Copy link
Member Author

nelsonic commented Feb 3, 2022

First thing I want to show is are the Environment Variables defined?:
image

Looks amaze, right? 😜

Borrowing check & cross icons from: https://www.flaticon.com/free-icons/cross-check
flaticon

BRB ... ⏳

@nelsonic
Copy link
Member Author

nelsonic commented Feb 3, 2022

Better?

image

@nelsonic
Copy link
Member Author

nelsonic commented Feb 3, 2022

Attempted to deploy to Fly.io but sadly the .env_sample file is not available so we get an :enoent error:

image

Looks like I have to hard-code the Environment variable keys in the status_controller.ex ... 🙄

@nelsonic
Copy link
Member Author

nelsonic commented Feb 3, 2022

Split the Environment Variables into Required and Optional:

image

Thoughts? 💭

@nelsonic
Copy link
Member Author

nelsonic commented Feb 3, 2022

Deployed to Fly.io: https://authprod.fly.dev/status all environment variables are defined:
image

@nelsonic
Copy link
Member Author

nelsonic commented Feb 3, 2022

Helpful message that "init: cannot be run until all the required environment variables are set":

image

@nelsonic nelsonic changed the title STATUS: Auth App Deployment Status Page [MVP] INIT: Auth App Deployment Init Page [MVP] Feb 3, 2022
@nelsonic
Copy link
Member Author

nelsonic commented Feb 4, 2022

Need to put this down for a bit as I have TON of "work work" to do and need to close all browser tabs & dev windows to focus.

Continue: https://fly.io/apps/authprod + https://authprod.fly.dev/status

flyctl --app authprod logs

Asside: ?XDEBUG_SESSION_START=phpstorm ... 🙄

image

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2022

On localhost there's a 500 error if the SECRET_KEY_BASE is not defined:

image

[error] #PID<0.663.0> running AuthWeb.Endpoint (connection #PID<0.662.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /init
** (exit) an exception was raised:
    ** (ArgumentError) cookie store expects conn.secret_key_base to be set
        (plug 1.12.1) lib/plug/session/cookie.ex:203: Plug.Session.COOKIE.validate_secret_key_base/1
        (plug 1.12.1) lib/plug/session/cookie.ex:198: Plug.Session.COOKIE.derive/3
        (plug 1.12.1) lib/plug/session/cookie.ex:98: Plug.Session.COOKIE.get/3
        (plug 1.12.1) lib/plug/session.ex:78: anonymous fn/5 in Plug.Session.fetch_session/1
        (plug 1.12.1) lib/plug/debugger.ex:287: Plug.Debugger.maybe_fetch_session/1
        (plug 1.12.1) lib/plug/debugger.ex:187: Plug.Debugger.render/6
        (plug 1.12.1) lib/plug/debugger.ex:162: Plug.Debugger.__catch__/5
        (auth 1.6.5) lib/auth_web/endpoint.ex:1: AuthWeb.Endpoint.call/2
        (phoenix 1.6.5) lib/phoenix/endpoint/cowboy2_handler.ex:54: Phoenix.Endpoint.Cowboy2Handler.init/4
        (cowboy 2.9.0) /auth/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
        (cowboy 2.9.0) /auth/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
        (cowboy 2.9.0) /auth/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
        (stdlib 3.15.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

This is a required environment variable for any Phoenix app, so this is expected.

But once the SECRET_KEY_BASE is exported, the init page looks like this: http://localhost:4000/init

image

This gives the person trying to deploy the Auth App a clear picture of what is still required to get it working. 🤞

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2022

Deployed to Fly.io: https://authprod.fly.dev/init
image

For some reason AUTH_API_KEY is not accessible via AuthPlug.Token.api_key() ... 🤷‍♂️

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2022

StackOverflow Offline ... 🚫
image
How am I meant to write code?! 😜
Might have to just go to bed. 🙄

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2022

Dang .... it's really not available! 🤦‍♂️
image

@nelsonic
Copy link
Member Author

nelsonic commented Feb 6, 2022

Surely, they could just have a read-only copy of the site ...
image

@nelsonic
Copy link
Member Author

nelsonic commented Feb 7, 2022

mix ecto.gen.migration remove_constraints

@nelsonic
Copy link
Member Author

nelsonic commented Feb 7, 2022

All Green:

image

🙌

@nelsonic
Copy link
Member Author

nelsonic commented Feb 7, 2022

Included in PR #173

@nelsonic
Copy link
Member Author

nelsonic commented Feb 7, 2022

Very much just an MVP version. Happy for anyone to extend/improve this idea.

@nelsonic nelsonic closed this as completed Feb 7, 2022
@nelsonic nelsonic added the awaiting-review An issue or pull request that needs to be reviewed label Feb 7, 2022
nelsonic added a commit to dwyl/gogs-demo that referenced this issue May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review An issue or pull request that needs to be reviewed BLOCKED :fire: Core team's HIGHEST priority, blocking critical work chore a tedious but necessary task often paying technical debt enhancement New feature or enhancement of existing functionality help wanted If you can help make progress with this issue, please comment! needs-ui A feature idea that needs UI in order to be discussed/built. priority-1 Highest priority issue. This is costing us money every minute that passes. T4h Time Estimate 4 Hours tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written technical A technical issue that requires understanding of the code, infrastructure or dependencies
Projects
None yet
Development

No branches or pull requests

1 participant