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

Keep full model name when parsing expression with tag #16211

Conversation

yrudman
Copy link
Contributor

@yrudman yrudman commented Oct 16, 2017

Issue:
MiqExpression::Tag.parse does not return full model name. Parsing tag like ManageIQ::Providers::CloudManager.managed-service_level will return CloudManager and
>> "CloudManager".safe_constantize => nil
https://bugzilla.redhat.com/show_bug.cgi?id=1501333

Solution:
keep full model name when parsing

Example: group has assigned filter expression
screen shot 2017-10-16 at 4 15 50 pm

and tag was assigned to some instances of gce provider
screen shot 2017-10-16 at 4 26 42 pm

BEFORE:

before

AFTER:

after

@miq-bot add-label bug, core

\cc @gtanzillo @imtayadeway

Copy link
Contributor

@imtayadeway imtayadeway left a comment

Choose a reason for hiding this comment

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

LGTM thanks @yrudman 👍

@@ -1,6 +1,6 @@
class MiqExpression::Tag < MiqExpression::Target
REGEX = /
(?<model_name>([[:alnum:]]*(::)?)?)
(?<model_name>([[:alnum:]]*(::)?)*)
Copy link
Contributor

@lpichler lpichler Oct 16, 2017

Choose a reason for hiding this comment

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

@yrudman you need probably limit count of ::
Problem is failing case like, it is too slow.

MiqExpression::Tag.parse('ManageIQ::Providers::CloudManagermanaged-se')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 nice catch @lpichler
parsing your example from console never finished and was interrupted after 2 minutes.
And parsing it on master returning nil. So, limiting :: looks like good idea.

@yrudman yrudman force-pushed the keep-full-model-name-when-parsing-expression-with-tag branch from d6b9717 to 7822c56 Compare October 17, 2017 14:59
@yrudman yrudman force-pushed the keep-full-model-name-when-parsing-expression-with-tag branch 2 times, most recently from 9a6f26d to 1ef3fb0 Compare October 17, 2017 15:56
@miq-bot
Copy link
Member

miq-bot commented Oct 17, 2017

Checked commits yrudman/manageiq@071592a~...1ef3fb0 with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks fine. 🍰

@gtanzillo gtanzillo added this to the Sprint 72 Ending Oct 30, 2017 milestone Oct 19, 2017
@gtanzillo gtanzillo merged commit a9b8c5a into ManageIQ:master Oct 19, 2017
@yrudman yrudman deleted the keep-full-model-name-when-parsing-expression-with-tag branch October 23, 2017 14:04
jrafanie added a commit to jrafanie/manageiq that referenced this pull request Dec 6, 2017
https://bugzilla.redhat.com/show_bug.cgi?id=1519809

This will prevent an infinite loop inside regex when parsing strings
like "ManageIQ::Providers::CloudManager::Vm.miq_custom_attributes-name"

This is a manual partial backport of
b19567a which was in PR:
ManageIQ#16211

Before this change, this will spin at 100% cpu in rails console:
MiqExpression::Tag.parse("ManageIQ::Providers::CloudManager::Vm.miq_custom_attributes-name")

After this change, it returns nil nearly immediately.
d-m-u pushed a commit to d-m-u/manageiq that referenced this pull request Jun 6, 2018
https://bugzilla.redhat.com/show_bug.cgi?id=1519809

This will prevent an infinite loop inside regex when parsing strings
like "ManageIQ::Providers::CloudManager::Vm.miq_custom_attributes-name"

This is a manual partial backport of
b19567a which was in PR:
ManageIQ#16211

Before this change, this will spin at 100% cpu in rails console:
MiqExpression::Tag.parse("ManageIQ::Providers::CloudManager::Vm.miq_custom_attributes-name")

After this change, it returns nil nearly immediately.
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