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

Move unassignable and unremovable labels from constants to settings #485

Merged
merged 1 commit into from
Mar 13, 2020

Conversation

bdunne
Copy link
Member

@bdunne bdunne commented Mar 12, 2020

These values really belong to the ManageIQ organization and the bot is intended to be reusable by people in other organizations. Prefer settings for these types of values rather than hard-coded constants.

cc @NickLaMuro

Copy link
Member

@NickLaMuro NickLaMuro left a comment

Choose a reason for hiding this comment

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

Minor nitpick, but otherwise I am fine with this. 👍

@@ -3,7 +3,9 @@ module Commands
class RemoveLabel < Base
include IsTeamMember

UNREMOVABLE = %w[jansa/yes jansa/no].freeze
def unremovable_labels
Copy link
Member

Choose a reason for hiding this comment

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

Maybe make this a class variable so we aren't loading this on every instance?

Copy link
Member

Choose a reason for hiding this comment

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

Of course, if needed, you can alias it as an instance method, but I think that it should still be cached on the class level.

UNASSIGNABLE = {
"jansa/yes" => "jansa/yes?"
}.freeze
def unassignable_labels
Copy link
Member

Choose a reason for hiding this comment

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

Same here

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 already cached in Settings and that should get reloaded any time the settings are changed. Are you concerned about the call to stringify_keys?

Copy link
Member

Choose a reason for hiding this comment

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

By that logic, then we just shouldn't be caching it at all, and makes me wonder why you have a @ var there in the first place.

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 added the cache here so that we don't have to call stringify_keys for every label in the command.

Copy link
Member Author

Choose a reason for hiding this comment

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

The other cache was not necessary, so I removed it.

Copy link
Member

@NickLaMuro NickLaMuro Mar 12, 2020

Choose a reason for hiding this comment

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

Sorry, to be clear:

I don't really see this as a big performance hit, since we would be caching it for it's once use per instance of this (it seems), so I am more commenting on the fact that we are caching this on the instance, but it's cache should never be made use of since this is only ever called once per instance.

If we still want the cache, then probably cache_with_timeout would make sense based on the use case that you described: changing the files and having it auto reload without a server restart. That said, I have found that the listen gem has caused my CPU to spike to 100% on my current machine, so I tend to avoid trying to relying on that gem/functionality.

Copy link
Member

Choose a reason for hiding this comment

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

I added the cache here so that we don't have to call stringify_keys for every label in the command.

Correction: You are right with this since it is being called with in a loop. I would argue that it is negligible with the number of labels we currently have in this list and the number of labels that are passed in for add_label in general (one or two), and there is more savings to be had by caching this on a class level is that is your true intent.

Copy link
Member

Choose a reason for hiding this comment

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

That said, I have found that the listen gem has caused my CPU to spike to 100% on my current machine, so I tend to avoid trying to relying on that gem/functionality.

Can you open an issue for this...I'd not heard this before and I don't have this issue nor do we see it in prod.

Copy link
Member

Choose a reason for hiding this comment

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

I think the memoization is fine since this is at an instance level. The next instance of AddLabel will query the Settings again.

@NickLaMuro
Copy link
Member

@bdunne I have a larger concern in general about over using config/settings.yml and making it less transparent about what is going on for those who don't run the bot in production, but I don't think that this PR is going against that concern and is only tangentially related.

Should I open an issue about this to get a discussion going?

@bdunne
Copy link
Member Author

bdunne commented Mar 12, 2020

Should I open an issue about this to get a discussion going?

Might be a good idea. Currently the settings override on the box contains a mix of secrets and org-specific configurations. I would be open to splitting the current config file into two files (one for secrets, one for everything else). I'm not sure where we would put the new "everything else" file because I don't think that belongs in this repo. @Fryguy Any thoughts?

These values really belong to the manageiq organization and the bot is
intended to be reusable by people in other organizations.  Prefer settings
for these types of values rather than hard-coded constants.
@bdunne bdunne force-pushed the move_static_labels_to_setings branch from c071dd0 to 0444c41 Compare March 12, 2020 22:27
@miq-bot
Copy link
Member

miq-bot commented Mar 12, 2020

Checked commit bdunne@0444c41 with ruby 2.5.7, rubocop 0.69.0, haml-lint 0.20.0, and yamllint
4 files checked, 1 offense detected

**

  • 💣 💥 🔥 🚒 - Linter/Yaml - missing config files

@Fryguy
Copy link
Member

Fryguy commented Mar 13, 2020

Should I open an issue about this to get a discussion going?

That sounds good to me.

The general idea is that while this is called the miq_bot, it's designed more generally than that (or at least should be). I've had aspirations to move this code to a more generic bot system that others could use.

@Fryguy Fryguy merged commit 4325a17 into ManageIQ:master Mar 13, 2020
@bdunne bdunne deleted the move_static_labels_to_setings branch March 13, 2020 00:41
@NickLaMuro
Copy link
Member

Opened said issue here:

#486

Though, doesn't quite address the thoughts expressed here:

The general idea is that while this is called the miq_bot, it's designed more generally than that (or at least should be). I've had aspirations to move this code to a more generic bot system that others could use.

I don't mind if the conversation there expands to design ideas on how we would approach something like that.

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.

4 participants