-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
OpenShift and k8s inventory plugins: fix "resource field is not json serializable" #46145
OpenShift and k8s inventory plugins: fix "resource field is not json serializable" #46145
Conversation
|
||
for service in obj.items: | ||
service_name = service.metadata.name | ||
service_labels = {} if not service.metadata.labels else dict(service.metadata.labels) |
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.
service.metadata.labels
and service.metadata.annotations
should have a .to_dict()
method defined, I think that will have a better guarantee of correct behavior
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.
service.metadata.labels
and service.metadata.annotations
are ResourceField
instances, ResourceField
class doesn't have a to_dict
method - but ResourceInstance
has, should service.metadata.labels
and service.metadata.annotations
be ResourceInstance
instances ?
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.
Nope, I'm just wrong, my bad
1544523
to
7f8a1e6
Compare
Rebased |
shipit |
bot_status |
Componentslib/ansible/plugins/inventory/k8s.py lib/ansible/plugins/inventory/openshift.py Metadatawaiting_on: maintainer |
rebuild_merge |
…#46145) Fixes ansible#44408 (cherry picked from commit 15d46ce)
SUMMARY
Note that this fix requires #45826 (first three commits come from #45826, last commit contains the fix) #45826 should be merged first.
Fix
TypeError: Object of type 'ResourceField' is not JSON serializable
Test command:
ANSIBLE_INVENTORY_ENABLED=openshift ansible-inventory -i test.yml --list -vvv
Exception was:
Python 3.6:
Python 2.7
Fixes #44408
ISSUE TYPE
COMPONENT NAME
openshift and k8s inventory plugins
ANSIBLE VERSION