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

Rely on env variable for manageiq-appliance repo directory #4105

Merged
merged 2 commits into from Sep 8, 2015

Conversation

jrafanie
Copy link
Member

ManageIQ code shouldn't know where the old system/TEMPLATE is
Use the APPLIANCE_TEMPLATE_DIRECTORY environment variable provided by manageiq-appliance PR below.

Related PRs:

@jrafanie jrafanie changed the title [WIP] Rely on env for repo dir [WIP] Rely on env variable for manageiq-appliance repo directory Aug 28, 2015
@jrafanie jrafanie changed the title [WIP] Rely on env variable for manageiq-appliance repo directory Rely on env variable for manageiq-appliance repo directory Aug 28, 2015
@jrafanie
Copy link
Member Author

@simaishi @carbonin @Fryguy please review.

@roliveri @jerryk55 @movitto @hsong-rh Note, if you clone your manage-appliance repo somewhere else on your dev/appliance setup, you'll need to set your APPLIANCE_REPO_DIRECTORY environment variable here when these related PRs are merged. manageiq repo knew too much about where other repos lived and what they contained.

@kbrock
Copy link
Member

kbrock commented Sep 1, 2015

I can't imagine that we will re-arrange our directory structure more than once or twice over the next few years.
This seems like it should be hardcoded, or part of a build time script.

If this is a cross repo concern, then we have 2 choices:

  1. put that variable in a known spot ENV
  2. move this code into THAT repo, so it isn't a cross repo concern

@chessbyte
Copy link
Member

@jrafanie @abellotti @kbrock This PR makes it seem that maybe it is time to extract appliance_console into its own repo?

@chessbyte
Copy link
Member

@simaishi @carbonin @Fryguy any comments on this PR or is this good to merge?

@jrafanie
Copy link
Member Author

jrafanie commented Sep 2, 2015

If this is a cross repo concern, then we have 2 choices:

put that variable in a known spot ENV
move this code into THAT repo, so it isn't a cross repo concern

Good point @kbrock, it doesn't really belong in ManageIQ, maybe you or @abellotti have some ideas if the manageiq code from appliance_console really needs to do this work in the first place. It's really, if you've configured X for (apache/postgresql), set these things. I believe ManageIQ via appliance_console determines X and is also doing the setting of things. If instead, appliance_console called a manageiq-appliance script with some parameters, manageiq-appliance could house all of the logic and TEMPLATE configuration files.

This is probably outside the scope of this PR.

@carbonin
Copy link
Member

carbonin commented Sep 2, 2015

@jrafanie
Copy link
Member Author

jrafanie commented Sep 2, 2015

I think you would also need to change https://github.com/ManageIQ/manageiq/blob/master/gems/pending/appliance_console/external_httpd_authentication.rb#L115 .

Good catch, I'll fix that.

@abellotti
Copy link
Member

I see them defined in the other PR, but wouldn't hurt to have code early on in appliance_console to check these ENV variables are indeed defined and bail out, just in case. Otherwise, we'll get stack traces or worse.

@miq-bot
Copy link
Member

miq-bot commented Sep 3, 2015

Checked commits jrafanie/manageiq@1bea799~...ec7b5e9 with rubocop 0.33.0 and haml-lint 0.13.0
6 files checked, 0 offenses detected
Everything looks good. 👍

@kbrock
Copy link
Member

kbrock commented Sep 4, 2015

@chessbyte

Can we pull the database.yml creation/modification code out of rails/rake and into appliance console before extracting this?

@chessbyte
Copy link
Member

@kbrock Can you clarify which code you want to extract into appliance console?

@jrafanie
Copy link
Member Author

jrafanie commented Sep 4, 2015

I see them defined in the other PR, but wouldn't hurt to have code early on in appliance_console to check these ENV variables are indeed defined and bail out, just in case. Otherwise, we'll get stack traces or worse.

@abellotti I don't know, we've never had checks for APPLIANCE and RAILS_ENV env variables which are used all over the place and are also set in similar places in manageiq-appliance repo. If we've had any problems with them, we'd be using the wrong Rails env or installing development gems on appliances.

Any issues we get now might be temporary until these env variables stabilize or any of my bugs are fixed. When we tag upstream, the different repos will have to be tagged together to work together. If I'm running on an appliance and get a KeyError: key not found: "APPLIANCE_*", I probably git pulled manageiq without also doing manageiq-appliance. This is a side effect of splitting repos.

I also added a appliance alias so we don't have to remember where the new manageiq-appliance repo is checked out, see: https://github.com/ManageIQ/manageiq-appliance/pull/12/files#diff-b9a3e1852620f16206bbe0f3e6736614R5. You can use vmdb and appliance to switch back and forth.

@jrafanie
Copy link
Member Author

jrafanie commented Sep 4, 2015

@kbrock @chessbyte Feel free to open an issue to extract appliance_console to a gem or to the manageiq-appliance repo itself (the latter would eliminate the need of the ENV variable here since it would reside in the same repo as the needed template files). While it sounds doable, it requires a lot of manual testing and is beyond this PR.

@kbrock
Copy link
Member

kbrock commented Sep 4, 2015

@jrafanie @chessbyte I was thinking something like #4212

I like the idea of keeping the appliance code separate from the rails code. never thought of the ENV basically showing where we are coupled across repos.

I've always viewed tasks like database create / backup / restore / set region / database.yml creation and tasks that would basically create or destroy a rails app to be the job of the appliance (and appliance console). But I'm curious where others draw that line.

Case and point: I also consider the job of starting and stopping the rails apps / workers to be outside the role of the rails app as well. And we clearly have that inside the rails app.

@@ -15,7 +15,7 @@ def self.postgres_dir
end

def self.postgresql_template
RAILS_ROOT.join("../system/TEMPLATE").join(postgres_dir)
PostgresAdmin.template_directory.join(postgres_dir)
Copy link
Member

Choose a reason for hiding this comment

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

Is this right? I feel like this should just be template_directory directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's pretty complicated but the TEMPLATE directory has stuff laid out as they get applied to /, like a chroot. So, we need to the root of the TEMPLATE directory and the normal PG_DATA directory (postgres_dir) in this case.

Copy link
Member

Choose a reason for hiding this comment

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

Right, but why does PostgresAdmin know about template_directory? Seems like that class should not care about that.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed that it is too bad we have to rely upon template directory, but lets not revisit at this time.

Ok, so is the request to move PostgresAdmin.template_directory to InternalDatabaseConfiguration?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it's "weird" that PostgresAdmin knows that the templates for postgresql are stored there.

Copy link
Member Author

Choose a reason for hiding this comment

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

It feels like we need a generic template directory on a more generic module/class that these other places can call.

Fryguy added a commit that referenced this pull request Sep 8, 2015
Rely on env variable for manageiq-appliance repo directory
@Fryguy Fryguy merged commit b6cb04a into ManageIQ:master Sep 8, 2015
@Fryguy Fryguy deleted the rely_on_env_for_repo_dir branch September 8, 2015 18:42
@chessbyte chessbyte added this to the Sprint 29 Ending Sept 14, 2015 milestone Sep 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants