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

Change typo resouce_type to resource_type #1684

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/module_utils/foreman_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ def __init__(self, **kwargs):
))[0])

if 'parent' in self.foreman_spec and self.foreman_spec['parent'].get('type') == 'entity':
if 'resouce_type' not in self.foreman_spec['parent']:
if 'resource_type' not in self.foreman_spec['parent']:
Copy link
Member

Choose a reason for hiding this comment

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

heh, this uncovers an interesting bug. 🙈

the resource_type attribute of parent is always set via

foreman_value['resource_type'] = HAS_APYPIE and inflector.pluralize(key)

but it's always parents.

What we need to check here is not the current foreman_spec (as that has been enriched already), but the original one passed to __init__. But then again, I see absolutely no reason for setting this, as I can't think of a situation where a parent would be of a different type than the child?!

Copy link
Member

Choose a reason for hiding this comment

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

cc @mdellweg :)

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 think you are saying this chunk of code might be useless?

Copy link
Member

Choose a reason for hiding this comment

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

that's what I am saying.

Copy link
Member Author

Choose a reason for hiding this comment

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

How do we figure out if it's useless?

Copy link
Member

Choose a reason for hiding this comment

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

The line below this reads:

self.foreman_spec['parent']['resource_type'] = self.foreman_spec['entity']['resource_type']

That means we're using the type of the main entity (the one we're currently executing). As I can't think of a situation where the parent would be a different type, this works just fine

Copy link
Member

Choose a reason for hiding this comment

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

So we can safely assume that the condition always evaluated true and we always set the parent type to match the current ones type. I guess that is at the very least better than "parents".

So if I understand your comment correctly, that means "fixing" this condition will make it false always, now leaving the parent's type to be "parents"? Is this breaking anything? What do we use that resource_type for? Do we need it to access apypie apis properly?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Does #1725 replace this PR?

Copy link
Member

Choose a reason for hiding this comment

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

It does, and that's why it had a "closes" on this one ;)

self.foreman_spec['parent']['resource_type'] = self.foreman_spec['entity']['resource_type']
if 'failsafe' not in self.foreman_spec['parent']:
self.foreman_spec['parent']['failsafe'] = True
Expand Down
Loading