dandi / dandi-infrastructure

A repository to collect docs/issues on DANDI project infrastructure
Apache License 2.0
0 stars 5 forks source link

Resolve chicken-vs-egg scenario of initial Heroku deployment vs initial DANDI Infrastructure deployment #195

Open aaronkanzer opened 19 hours ago

aaronkanzer commented 19 hours ago

Girder is the basis for the DANDI Archive API -- https://github.com/dandi/dandi-infrastructure/blob/master/terraform/api.tf#L5-L6.

A chicken vs. egg scenario occurs when using Girder for Heroku deployments of DANDI Archive, as DANDI Archive must be deployed at least once, applying its relevant Procfile to Heroku, as noted here in the Girder docs, prior to Heroku dyno configuration being recognized in corresponding dandi-infrastructure Terraform code.

However, when initially deploying the DANDI Archive, certain environment variables must be set -- in the Django settings file here -- these values are set by the Terraform values set here -- thus, it is impossible to provide a clean, initial terraform apply, causing a chicken vs. egg scenario where DANDI Archive needs to be deployed before dandi-infrastructure, but can't because of missing env vars set via Girder.

This ticket captures this issue -- there are be step-wise mechanisms to get around this (e.g. LINC Archive/infrastructure's prior trial-and-error), albeit potentially messy and confusing to a new user.

Cc @satra @kabilar @yarikoptic @waxlamp

yarikoptic commented 18 hours ago

Yikes, I was not aware of this intricacy. Thank you @aaronkanzer for filing the issue.
For starter -- do we need that Girder for Heroku (source = "girder/girder4/heroku") or could it be some more plain django for Heroku ? I am yet to fully grasp the situation here

aaronkanzer commented 18 hours ago

Yikes, I was not aware of this intricacy. Thank you @aaronkanzer for filing the issue. For starter -- do we need that Girder for Heroku (source = "girder/girder4/heroku") or could it be some more plain django for Heroku ? I am yet to fully grasp the situation here

@yarikoptic

In this case, Girder provisions much of the foundational resources that DANDI Archive relies on -- for starters, see here. We can always take the parts of Girder we like upstream and remove the reference to the module, but that could introduce different complexities.

The core concept to keep in mind here (with Terraform modules in general), is that Terraform is designed to not have modules and resources defined upstream overwritten downstream -- upstream is immutable. Thus, any extension of Terraform is purely extension, not overwriting.

I don't think this is a blocker by any means (we were able to deploy LINC Archive well enough, you could also theoretically switch environ_required=False for all the corresponding settings.py env vars in DANDI Archive); however, it depends on our appetite for following docs / step-wise approach vs. more automation -- food for thought....

kabilar commented 18 hours ago

Thanks @aaronkanzer. This is good to know. For LINC, what manual steps did you have to take to get around this circular dependency? I may have missed it in https://github.com/dandi/handbook/pull/104.

aaronkanzer commented 17 hours ago

Thanks @aaronkanzer. This is good to know. For LINC, what manual steps did you have to take to get around this circular dependency? I may have missed it in dandi/handbook#104.

@kabilar -- definitely going to add handbook docs regarding this -- for LINC, I went into the Heroku app and populated the env vars manually in the Heroku console -- just a quick fix, but another manual step (see screenshot below -- red square is just hiding the env vars)

Image

kabilar commented 17 hours ago

@kabilar -- definitely going to add handbook docs regarding this -- for LINC, I went into the Heroku app and populated the env vars manually in the Heroku console -- just a quick fix, but another manual step (see screenshot below -- red square is just hiding the env vars)

Thanks. I would suggest that we keep this as a manual step for now. To resolve this circular dependency, I agree that we should update the Girder Readme and DANDI Handbook.

aaronkanzer commented 16 hours ago

Girder Readme

@kabilar this isnt so much a problem with Girder, rather, it is the environ_required=True kwarg passed in the settings.py of DANDI Archive (https://github.com/dandi/dandi-archive/blob/master/dandiapi/settings.py#L88-L112)

If environ_required was set to False, than this chicken vs. egg scenario would be resolved

kabilar commented 15 hours ago

@kabilar this isnt so much a problem with Girder, rather, it is the environ_required=True kwarg passed in the settings.py of DANDI Archive (https://github.com/dandi/dandi-archive/blob/master/dandiapi/settings.py#L88-L112)

If environ_required was set to False, than this chicken vs. egg scenario would be resolved

Thanks. Is it possible to not hardcode this argument? I am not sure where mutate_configuration gets called.