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

Conversation

ehelms
Copy link
Member

@ehelms ehelms commented Nov 20, 2023

No description provided.

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 ;)

evgeni added a commit to evgeni/foreman-ansible-modules that referenced this pull request Apr 8, 2024
there is no way those can be different, but if left unset, other code
sets it to "parents" which is obviously wrong

Closes: theforeman#1684
evgeni added a commit to evgeni/foreman-ansible-modules that referenced this pull request Apr 8, 2024
there is no way those can be different, but if left unset, other code
sets it to "parents" which is obviously wrong

Closes: theforeman#1684
@evgeni evgeni closed this in #1725 Apr 8, 2024
evgeni added a commit that referenced this pull request Apr 8, 2024
there is no way those can be different, but if left unset, other code
sets it to "parents" which is obviously wrong

Closes: #1684
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants