cli icon indicating copy to clipboard operation
cli copied to clipboard

Preparation for v1: Bug hunt

Open judepereira opened this issue 5 years ago • 14 comments

Kudos to @StoryScriptAI and @Arinono for rebuilding the OMS CLI and UI. It's already looking good.

For the bug hunt today, we want to make sure that v1 release of this tool is rock solid, and doesn't have any glaring issues. To guide us, let's focus on these items:

CLI

  1. Speed
  2. Validation errors are easy to understand and follow
  3. Error messages when it comes to the container runtime (eg: Docker) are appropriate, and do not take more than 1 minute to understand. If this is a common problem, the CLI must additionally print/link to the solution

UI

  1. There are no "hanging" buttons/links
  2. The content in the UI accurately reflects the actual state as returned from the container runtime (eg: Docker)
  3. Fine motor skills are not required for any aspect of the UI
  4. The UI does not freeze at any point - be it a refresh page, or executing an action. There must never be a point where the user is thinking - is something supposed to happen?

Going about this

The most obvious way for us to experience the CLI and the UI is to use it naturally. We'll split existing services amongst ourselves, and create a few new ones (ideas welcome, must be small and well scoped).

judepereira avatar Sep 27 '19 13:09 judepereira

@Arinono: Arinono/validate @JeanBarriere accuweather @williammartin 5/6 of his own services Aditya - awesome @judepereira - psql

judepereira avatar Sep 27 '19 13:09 judepereira

Bugs:

  1. Two flags to print the version -v, -V
  2. Print the output of validate when there's an error, instead of just saying so. Aim to indicate what to do next:
h2:psql jude$ omg run select
Config file has errors (found at: /Users/jude/developer/omg/psql/microservice.yml)
h2:psql jude$
# What do I do next??
  1. Don't print a needless stack trace for common errors:
Error: Missing environment variables: POSTGRES_DSN
    at getContainer (/Users/jude/.config/yarn/global/node_modules/omg/lib/services/docker/getContainer.js:51:13)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
    at async Daemon.start (/Users/jude/.config/yarn/global/node_modules/omg/lib/services/daemon/Daemon.js:74:11)
    at async Object.run (/Users/jude/.config/yarn/global/node_modules/omg/lib/commands/run.js:49:3)
    at async Object.main [as default] (/Users/jude/.config/yarn/global/node_modules/omg/lib/index.js:119:3)
h2:psql jude$ 

The error above is about a missing environment variable, the output must rather say:

The environment variable POSTGRES_DSN is not specified. Please specify it with -e POSTGRES_DSN=<value>
  1. Missing arguments must be validated wayyyy earlier in the workflow. Rather than taking 10 seconds to build the container and then fail, fail fast:
✔ Built Docker image with name: omg/microservice/psql
✔ Successfully started Docker container
✔ Healthcheck successful
Error: Missing arguments for Action: table, where
    at executeAction (/Users/jude/.config/yarn/global/node_modules/omg/lib/services/action/executeAction.js:40:11)
    at Object.run (/Users/jude/.config/yarn/global/node_modules/omg/lib/commands/run.js:80:35)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
    at async Object.main [as default] (/Users/jude/.config/yarn/global/node_modules/omg/lib/index.js:119:3)

Also, see point 3 regarding stack traces. 5. My service returned an error, with a stack trace of the omg cli.

h2:psql jude$ omg run select -e POSTGRES_DSN="options=--search_path=app_public,app_hidden,app_private,public dbname=asyncy user=jude" -a table=owners -a where={}
✔ Built Docker image with name: omg/microservice/psql
✔ Successfully started Docker container
✔ Healthcheck successful
Error: Action#select returned non-OK Http Status 400
    at executeHttpAction (/Users/jude/.config/yarn/global/node_modules/omg/lib/services/action/executeHttpAction.js:120:17)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
    at async executeAction (/Users/jude/.config/yarn/global/node_modules/omg/lib/services/action/executeAction.js:47:9)
    at async Object.run (/Users/jude/.config/yarn/global/node_modules/omg/lib/commands/run.js:80:3)
    at async Object.main [as default] (/Users/jude/.config/yarn/global/node_modules/omg/lib/index.js:119:3) {
  response: `{"message":"AttributeError(\\"'str' object has no attribute 'items'\\")"}\n`
}
h2:psql jude$
  1. How do I pass maps from the shell?
h2:psql jude$ omg run select -e POSTGRES_DSN="options=--search_path=app_public,app_hidden,app_private,public dbname=asyncy user=jude" -a table=owners -a where={}
✔ Built Docker image with name: omg/microservice/psql
✔ Successfully started Docker container
✔ Healthcheck successful
Error: Action#select returned non-OK Http Status 400
    at executeHttpAction (/Users/jude/.config/yarn/global/node_modules/omg/lib/services/action/executeHttpAction.js:120:17)
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
    at async executeAction (/Users/jude/.config/yarn/global/node_modules/omg/lib/services/action/executeAction.js:47:9)
    at async Object.run (/Users/jude/.config/yarn/global/node_modules/omg/lib/commands/run.js:80:3)
    at async Object.main [as default] (/Users/jude/.config/yarn/global/node_modules/omg/lib/index.js:119:3) {
  response: `{"message":"AttributeError(\\"'str' object has no attribute 'items'\\")"}\n`
}
h2:psql jude$
  1. This one has two problems 7.1. The image is built immediately on starting omg ui - however, env vars were required, and the build failed naturally 7.2. Where in the UI can I put in env vars?
h2:psql jude$ omg ui
✔ Server is running at http://localhost:9000/
ℹ Step 1/6 : FROM          python:3.7-alpine
ℹ ---> fe3ef29c73f3
ℹ Step 2/6 : RUN           mkdir /app
ℹ ---> Using cache
ℹ ---> e21269407cc4
ℹ Step 3/6 : COPY          requirements.txt /app
ℹ ---> Using cache
ℹ ---> 6ed1bb748c2c
ℹ Step 4/6 : RUN apk update &&  apk add postgresql-libs &&  apk add --virtual .build-deps gcc musl-dev postgresql-dev &&  pip install -r /app/requirements.txt --no-cache-dir &&  apk --purge del .build-deps
ℹ ---> Using cache
ℹ ---> bdf3ad9ba5e6
ℹ Step 5/6 : COPY          app.py /app
ℹ ---> Using cache
ℹ ---> 4a7592c1250e
ℹ Step 6/6 : ENTRYPOINT    ["python", "/app/app.py"]
ℹ ---> Using cache
ℹ ---> f53a02e68f85
ℹ Successfully built f53a02e68f85
ℹ Successfully tagged omg/microservice/psql:latest
✔ Built Docker image with name: omg/microservice/psql
✖ Starting Docker container failed
ℹ Missing environment variables: POSTGRES_DSN

  1. It was really hard for me to find out where to input environment variables in the UI. Before running an action, the UI must ask me to fill in mandatory env vars, and only then attempt to move forward.
  2. The spelling of environment is incorrect: Screenshot 2019-09-27 at 16 30 02
  3. The docker logs in the UI must auto follow the output. I had to scroll down in the setup page.
  4. The UI needs to expose a better UI to input the arguments, instead of free form JSON: Screenshot 2019-09-27 at 16 32 01
  5. General UI issues: Screenshot 2019-09-27 at 16 35 41

judepereira avatar Sep 27 '19 14:09 judepereira

UI stressed on tabs: wrong behavior (see snapshot) image -> should scroll-x

JeanBarriere avatar Sep 27 '19 14:09 JeanBarriere

@JeanBarriere also, there's no way to close a tab.

judepereira avatar Sep 27 '19 14:09 judepereira

Issues

$ omg validate
Must be ran in a directory with a `Dockerfile` and a `microservice.y[a]ml`

Does validate need a Dockerfile?


$ omg run -i omg/williammartin/storywriter story
Must be ran in a directory with a `Dockerfile` and a `microservice.y[a]ml`

If I'm providing an image, do I need a Dockerfile?


$ omg run write
✔ Built Docker image with name: omg/williammartin/storywriter
✖ Starting Docker container failed
TypeError: Cannot read property 'includes' of null
    at /Users/williammartin/.config/yarn/global/node_modules/omg/lib/services/docker/getContainer.js:32:51
    at Array.some (<anonymous>)
    at getContainer (/Users/williammartin/.config/yarn/global/node_modules/omg/lib/services/docker/getContainer.js:32:24)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
    at async Daemon.start (/Users/williammartin/.config/yarn/global/node_modules/omg/lib/services/daemon/Daemon.js:74:11)
    at async Object.run (/Users/williammartin/.config/yarn/global/node_modules/omg/lib/commands/run.js:49:3)
    at async Object.main [as default] (/Users/williammartin/.config/yarn/global/node_modules/omg/lib/index.js:119:3)

No idea what's going on here?


image

$ omg validate
ℹ Validation failed with the following errors:
  - .actions.run.output.contentType must be one of application/json,application/x-www-form-urlencoded,multipart/form-data

microservice guide doesn't seem to specify this as a problem anywhere?


Given a microservice that exits, we get a nasty traceback:

$ omg run log
✔ Built Docker image with name: omg/williammartin/logger
✔ Successfully started Docker container
✔ Healthcheck successful
GotError [RequestError]: socket hang up
    at ClientRequest.<anonymous> (/Users/williammartin/.config/yarn/global/node_modules/got/source/request-as-event-emitter.js:178:14)
    at Object.onceWrapper (events.js:291:20)
    at ClientRequest.emit (events.js:208:15)
    at ClientRequest.origin.emit (/Users/williammartin/.config/yarn/global/node_modules/@szmarczak/http-timer/source/index.js:37:11)
    at Socket.socketOnEnd (_http_client.js:433:9)
    at Socket.emit (events.js:208:15)
    at endReadableNT (_stream_readable.js:1168:12)
    at processTicksAndRejections (internal/process/task_queues.js:77:11) {
  name: 'RequestError',
  code: 'ECONNRESET',
  host: 'localhost:53198',
  hostname: 'localhost',
  method: 'POST',
  path: '/log',
  socketPath: undefined,
  protocol: 'http:',
  url: 'http://localhost:53198/log',
  gotOptions: undefined
}

I don't really know what these buttons represent:

image


image

The stderr is quoted for some reason and stdout isn't


image

This may be the behaviour we want, but I'm not sure if it matches storyscript, does the empty string count as an argument if I'm explicit?


image

Valid but also invalid?!!?


image

The history seems to maintain state across different microservices, which isn't all that useful

williammartin avatar Sep 27 '19 14:09 williammartin

@judepereira

  1. Two flags to print the version -v, -V

IMO I don't think this is an issue, in fact I think that't the opposite. Python uses -V and Node uses -v and I always make the mistake when I'm using python. So the good thing is that the user will never do this mistake, and I don't see and issue supporting both

Arinono avatar Sep 27 '19 14:09 Arinono

@williammartin

Does validate need a Dockerfile?

I'm pretty sure it doesn't and the check for this files is before any command, which is maybe not a good idea indeed

Arinono avatar Sep 27 '19 14:09 Arinono

OMG UI:

  • The Contribute to Github in the top right corner does nothing
  • The history filtering too
  • We cannot start the UI with an existing Docker image (-i)

Screenshot 2019-09-27 at 16 15 53 Could be good to have required attributes already written here

The container failed, but the CLI nor the UI are notifying me that's the case. Here is the terminal output https://asciinema.org/a/MHHHcoxd6P5pvPfybIu1Mn2ZC

On the UI side, the "button" on top is still saying started and nothing in the logs tells me that the container is down.


https://asciinema.org/a/9yWzS4te2J8WTZIqFr8usk7Fq OMG run is completely defunct with my SpaceX microservice (the container is working properly alone)


A -p or --pretty is welcome on the omg list -j, because this is unreadable. Also the omg list and omg list -d returns the same info ? https://asciinema.org/a/uiPLYyE1quQmC9FA2Mtybgww5

Arinono avatar Sep 27 '19 14:09 Arinono

I've checked the UI a bit more:

https://www.loom.com/share/d5e20d92b34343bd85f641214621367e

JeanBarriere avatar Sep 27 '19 14:09 JeanBarriere

Awesome micro service

  • omg run id What's the delay after running the command. delay

  • In the UI, Send button should not be clickable when no action is selected. dash

  • No title mentioned for the arguments box image

  • Send doesn't work if no argument is present. awesome services id action doesn't accept args. dash

  • If I can't write anything why does it allow the cursor to come up when clicked. dash

  • Lot of empty space with some free floating arrows makes the UI look broken. dash

  • Opening too many tabs :P image

adnrs96 avatar Sep 27 '19 15:09 adnrs96

In that case it should explicitly specify it is shutting down the container and press ctrl + c to force exit :)

adnrs96 avatar Sep 27 '19 16:09 adnrs96

@adnrs96 The delay AFTER running the command is shutting down the container and garbage collecting it. You can ask the CLI to terminate the container with a ctrl-c if you don't wanna wait.

In that case it should explicitly specify it is shutting down the container and press ctrl + c to force exit :)

It should yes, I'll add that somewhere

ghost avatar Sep 27 '19 18:09 ghost

Thanks for the feedback everyone, here's a changelog of what's happened since this bughunt concluded:

  • Action arguments and environment values are now validated before booting up the container
  • Action/Env error messages include extra help content to help the user navigate on fix for them
  • Typos inside the Environment modal have been fixed
  • Environment modal as well as left/right side-bars have been resized to fix bad styles on small screens
  • Inherit env option is now supported in omg run and omg subscribe
  • Horizontal scroll and close button have been made functional for tabs
  • Empty strings are now correctly recognized as arguments/env values
  • Docker/App log is persisted across app refreshes upto 500 lines for both types individually
  • Dockerfile existence is no longer required when specifying image in CLI
  • Specifying custom image is now supported for omg ui
  • omg list now has a --pretty in addition to --json for pretty printing the JSON
  • Container network errors now look nicer with more helpful info
  • CLI now supports JSON-encoded arguments for map, object and list types
  • Contribute on Github button now opens a github tab properly
  • CLI Errors do not print a stack trace unless OMS_CLI_DEBUG var is provided

There's more UI stuff cooking in the oven

ghost avatar Sep 29 '19 21:09 ghost

Here's a tl;dr of what's changed since the last changelog posting:

  • -V has been removed in favor of -v
  • Validation bug with nested object args has been fixed for in
  • Image build failures are detected and reported properly
  • Grouping has been removed from actions history
  • Actions history now has controls for bookmarking or deleting individual items
  • Search for history is now functioning as intended
  • Image building is deferred until env vars are input in UI for when there are some required env vars
  • Both Env modal and sidebar now shows both Docker and Application logs in reversed order
  • Styles of the Actions select have been fixed for different screen sizes
  • UX Improvements around the board, especially for areas that have nothing to show
  • Send and save buttons are disabled to avoid confusion when no action is selected

More to come soon!

ghost avatar Oct 09 '19 08:10 ghost