-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fix Boolean values defaulting to False in collection #14493
Conversation
I want to test this, but my only concern is that if the user passes "" as a value, does it get popped, and will it interfere when we start doing things with the enforced state in the future. |
It should not, this is the reason for the But I should probably give a quick test to confirm that Ansible allows passing empty strings and carries it through the various contracts. |
Confirmed. Passing in empty string for description: - name: Create a Host with exists
host:
name: foobar
description: ""
inventory: "Demo Inventory" And then inspecting
So this shows the distinction between empty string inputs and inputs which are not provided. |
It Seems good, and you are right for description it works. However for the Boolean that this originated on, #14461, it has the following behavior with your above task (name,descrip,inventory) Host does not exist If you turn it on in the GUI, and then run again, it again disables the host. Did another test, where input was null, but where we set the default to '' in python, and it did pass and was not affected by this, which is what I was originally concerned about. So you are right on the enforced state, but found a 2nd bug. |
I'm going to be honest that I'm not understanding your steps. Could you share tasks that accomplish this reproducer? Sure, we should consider whether True / False values are distinguished from None. ---
- name: Issue replication
hosts: localhost
gather_facts: false
collections:
- awx.awx
tasks:
- name: Create a Host with exists
host:
name: foobar
description: ""
inventory: "Demo Inventory"
enabled: false Running this, I find that
So if you created a new host with that task, and then viewed it in the UI, it will be disabled. That's correct, the user intent in this case is to have a disabled host. |
Oh I see ---
- name: Issue replication
hosts: localhost
gather_facts: false
collections:
- awx.awx
tasks:
- name: Create a Host with exists
host:
name: foobar
description: ""
inventory: "Demo Inventory"
- name: Should change nothing
host:
name: foobar
description: ""
inventory: "Demo Inventory" The second task still disables the host. |
Ok, I see. This goes deep, and we seem to formally have a choice between different wrong behaviors. |
yep, Sorry didn't see the notifications earlier today, dealing with different fun quirky behaviors. I'm going to see about a PR to fix the BOOL issue, I think the enabled is one of the few trues we have, but going to double check. I think this PR is good, just doesn't solve the BOOL issue :) |
@sean-m-sullivan after the last commits I pushed, I really do think it solves the "BOOL issue" you reference. This fixes it defaulting to False on creation, and being over-opinionated on edits. Any time an existing object exists, it will not change the |
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.
Tested, working as expected, Awesome!
This failed on
In my previous PR I came accross this and switched to this to fix it
|
- name: Newly created host should have API default value for enabled | ||
assert: | ||
that: | ||
- "lookup('awx.awx.controller_api', 'hosts/{{result.id}}/').enabled" |
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.
Failure is here, I tried to find out where this changed in ansible, but newer ansible does not like lookups in asserts.
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.
yeah you're right, I'll use the test from your patch
* Fix Boolean values defaulting to False in collection * Remove null values in other cases, fix null handling for WFJT nodes * Only remove null values if it is a boolean field * Reset changes to WFJT node field processing * Use test content from sean-m-sullivan to fix lookups in assert
* Fix Boolean values defaulting to False in collection * Remove null values in other cases, fix null handling for WFJT nodes * Only remove null values if it is a boolean field * Reset changes to WFJT node field processing * Use test content from sean-m-sullivan to fix lookups in assert
SUMMARY
Connect #14461
Execution of the proposal
I can confirm the new assertion here fails in devel without this patch.
ISSUE TYPE
COMPONENT NAME