Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 ofparent
is always set viaforeman-ansible-modules/plugins/module_utils/foreman_helper.py
Line 1655 in 2864f87
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?!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @mdellweg :)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
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
There was a problem hiding this comment.
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?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1725
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ;)