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

[CZID-8461] Start happy setup #75

Merged
merged 10 commits into from
Sep 29, 2023
Merged

[CZID-8461] Start happy setup #75

merged 10 commits into from
Sep 29, 2023

Conversation

j-x-han
Copy link
Contributor

@j-x-han j-x-han commented Sep 29, 2023

Description

This PR begins the happy setup needed for cloud deployment; so far this has only been tested for the dev environment, but some of the config for staging has been started as well.

(Instructions on how to install happy) To start a stack, run happy create <your-stack-name> in the directory of the service you want to start. You should be able to see the service running at <your-stack-name>.dev.happy.czid.org/graphql.

Notes

There are still a few TODOs for everything to be functional:

  • The migration script(s) to set up the db schemas currently aren't working:
    • Running happy migrate <stack-name> doesn't seem to run the script as expected; however, I was able to manually run the script when executing into the container.
  • The workflows and entities schemas also need to be split up, as they're currently both using the default public schema (which results in conflicts since their migrations both create an entities table).
  • Running queries/mutations currently results in httpcore.ConnectError: [Errno -2] Name or service not known. Looking at the stack trace, I suspect the issue is because cerbos isn't set up properly. Here's the relevant snippet:
  File "/czid-platformics/entities/platformics/api/core/gql_loaders.py", line 172, in resolve_entity
    return await get_entities(sql_model, session, cerbos_client, principal, filters, [])  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/czid-platformics/entities/platformics/api/core/gql_loaders.py", line 39, in get_entities
    plan = cerbos_client.plan_resources(CERBOS_ACTION_VIEW, principal, rd)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/cerbos/sdk/_sync/_http.py", line 268, in plan_resources
    resp = self._http.post("/api/plan/resources", json=req.to_dict())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/cerbos/sdk/_sync/_http.py", line 38, in post
    return self._post_fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@@ -1,18 +1,15 @@
version: '3.8'

x-aws-variables: &aws-variables
? AWS_ACCESS_KEY_ID
? AWS_SECRET_ACCESS_KEY
? AWS_SESSION_TOKEN
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this will trip up @rzlim08 ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@j-x-han is there a reason to get rid of these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good catch, I'll add them back in. I think the happy command I used to generate some of the files also modified the docker-compose files, I must have missed reverting this change.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the happy CLI freak out if these vars don't exist in your environment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested it, seems to work fine even if those variables aren't defined

app_name = var.app
deployment_stage = "dev"
additional_env_vars = {
CERBOS_URL = "http://cerbos.cerbos-system.svc.cluster.local:3592"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're going to need to add cerbos to our applications as a sidecar (see input var format here: https://github.com/chanzuckerberg/happy/blob/main/terraform/modules/happy-service-eks/variables.tf#L289) for our main applications, but we can add that in later.

@j-x-han j-x-han merged commit 4a99b2e into main Sep 29, 2023
0 of 2 checks passed
@j-x-han j-x-han deleted the j-x-han/happy-setup branch September 29, 2023 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants