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

'dict' object has no attribute 'availability_zone' with spilo 2.0-p2 on OpenStack #525

Closed
ekeih opened this issue Dec 19, 2020 · 0 comments · Fixed by #526
Closed

'dict' object has no attribute 'availability_zone' with spilo 2.0-p2 on OpenStack #525

ekeih opened this issue Dec 19, 2020 · 0 comments · Fixed by #526

Comments

@ekeih
Copy link
Contributor

ekeih commented Dec 19, 2020

Hi,

I am running the postgres-operator on OpenStack Queens and updated from 1.5 to 1.6. With 1.6 the operator updated to spilio 2.0-p2, which leads to the following error message:

2020-12-19 21:36:22,674 - bootstrapping - INFO - Figuring out my environment (Google? AWS? Openstack? Local?)
Traceback (most recent call last):
  File "/scripts/configure_spilo.py", line 1012, in <module>
    main()
  File "/scripts/configure_spilo.py", line 890, in main
    placeholders = get_placeholders(provider)
  File "/scripts/configure_spilo.py", line 598, in get_placeholders
    placeholders['instance_data'] = get_instance_metadata(provider)
  File "/scripts/configure_spilo.py", line 392, in get_instance_metadata
    metadata['zone'] = openstack_metadata.availability_zone
AttributeError: 'dict' object has no attribute 'availability_zone'

The culprit seems to be https://github.com/zalando/spilo/pull/486/files#diff-e4dcf964214d58d733ae9874d4a2ab4b8e9eb99213307e1666af5dad21a326bbR392, where requests.get().json() returns a dict but is treated like an object. The following ipython session shows the error and a possible fix:

In [11]: url = 'http://169.254.169.254/openstack/latest/meta_data.json'

In [12]: openstack_metadata = requests.get(url, timeout=5).json()

In [13]: openstack_metadata.availability_zone
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-13-dc68e8a42c4d> in <module>()
----> 1 openstack_metadata.availability_zone

AttributeError: 'dict' object has no attribute 'availability_zone'

In [14]: openstack_metadata['availability_zone']
Out[14]: u'cbk1'

I will open a PR with the fix in a minute.

Cheers
Max

CyberDem0n pushed a commit that referenced this issue Jan 11, 2021
dratzke pushed a commit to Patagona/spilo that referenced this issue May 25, 2021
dratzke pushed a commit to Patagona/spilo that referenced this issue Jul 26, 2021
al-andreev pushed a commit to picodata/stroppy-deploy-references that referenced this issue Oct 11, 2021
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 a pull request may close this issue.

1 participant