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

Set default server roles from env #15470

Merged
merged 5 commits into from
Jun 29, 2017

Conversation

bdunne
Copy link
Member

@bdunne bdunne commented Jun 28, 2017

Set default server roles from ENV["MIQ_SERVER_DEFAULT_ROLES"] if they don't already exist. This allows us to pass the default roles in the env variable to the backend manageiq container. (don't include UI/WS/etc. which will never receive traffic)

For the frontend, we don't provide the env variable and it will take the defaults from Settings.

cc @jrafanie @carbonin

@jrafanie
Copy link
Member

Can you not @mention me in a commit message? 😆

image

@chrisarcand Has 👑 :trollface:'d me with his epic commit 489a17d

allow_any_instance_of(MiqServer).to receive(:set_assigned_roles).and_return(nil)
allow_any_instance_of(MiqServer).to receive(:sync_workers).and_return(nil)
allow_any_instance_of(MiqServer).to receive(:sync_log_level).and_return(nil)
allow_any_instance_of(MiqServer).to receive(:wait_for_started_workers).and_return(nil)
Copy link
Member

Choose a reason for hiding this comment

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

✂️ 🔥

@jrafanie
Copy link
Member

LGTM, just fixup the commit so I don't get notifications everytime it's extracted to a new repo.

@bdunne bdunne changed the title Set default server roles from env [WIP] Set default server roles from env Jun 29, 2017
@miq-bot miq-bot added the wip label Jun 29, 2017
- If no roles exist (new server), try to source them from the environment
or fall back to the default in Settings
@bdunne bdunne force-pushed the set_default_server_roles_from_env branch from 8e1117b to 780a69c Compare June 29, 2017 14:49
@bdunne bdunne force-pushed the set_default_server_roles_from_env branch from 780a69c to a3e5404 Compare June 29, 2017 15:31
@jrafanie
Copy link
Member

This direction looks good to me @bdunne and is even better now that I'm not getting trolled in the commit message ;-)

It's still WIP though.

@bdunne bdunne changed the title [WIP] Set default server roles from env Set default server roles from env Jun 29, 2017
@bdunne bdunne removed the wip label Jun 29, 2017
@bdunne
Copy link
Member Author

bdunne commented Jun 29, 2017

Ok, got it working. Ready for review

self.role = ::Settings.server.role
end

def ensure_default_roles
MiqServer.my_server.add_settings_for_resource(:server => {:role => ENV["DEFAULT_ROLES"]}) if role.blank? && ENV["DEFAULT_ROLES"].present?
Copy link
Member

Choose a reason for hiding this comment

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

Should environment variable names be prefixed with MIQ_ or MANAGEIQ_?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not too concerned about the variable name since I hope it will be short lived, but I namespaced it to avoid conflict.

@miq-bot
Copy link
Member

miq-bot commented Jun 29, 2017

Checked commits bdunne/manageiq@eeabe1e~...6e84d92 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
4 files checked, 0 offenses detected
Everything looks fine. 👍

@jrafanie
Copy link
Member

EDIT: Updated description due to env variable rename

@jrafanie jrafanie merged commit 3376fa4 into ManageIQ:master Jun 29, 2017
@jrafanie jrafanie added this to the Sprint 64 Ending Jul 3, 2017 milestone Jun 29, 2017
@bdunne bdunne deleted the set_default_server_roles_from_env branch June 29, 2017 20:11
self.role = ::Settings.server.role
end

def ensure_default_roles
MiqServer.my_server.add_settings_for_resource(:server => {:role => ENV["MIQ_SERVER_DEFAULT_ROLES"]}) if role.blank? && ENV["MIQ_SERVER_DEFAULT_ROLES"].present?
Copy link
Member

Choose a reason for hiding this comment

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

@bdunne I don't see the discussion on this change, but why the move from self.role= ?

Copy link
Member

Choose a reason for hiding this comment

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

Ohhhh I see...if you don't change it then you end up with it syncing back from config and everything is wonky. Even so, I don't like using add_settings_for_resource because it broadcasts a config change to all running servers.

Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if it's cleaner to extract this into a separate method like maybe save_settings and call it directly...

Vmdb::Settings.save!(self, settings)
# Reload the settings immediately for this worker. This is typically a UI
# worker making the change, who will need to see the changes right away.
Vmdb::Settings.reload!

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.

5 participants