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

s3_bucket.py - deal gracefuly with empty bucket policy #1368

Merged

Conversation

magicrobotmonkey
Copy link
Contributor

When using wasabi object storage, the bucket policy can be blank. This was throwing a json decode error. Fix by checking for empty string and returning None.

SUMMARY

Deals gracefully with empty bucket policy (encountered on wasabi storage).

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

s3_bucket

ADDITIONAL INFORMATION

Recreate by attempting to create a new bucket on wasabi:
ENV:
S3_URL=https://s3.us-west-1.wasabisys.com

  • name: create bucket
    s3_bucket:
    name: "thisbucketwillfail"

When using wasabi object storage, the bucket policy can be blank. This was throwing a json decode error. Fix by checking for empty string and returning None.
@ansibullbot
Copy link

@ansibullbot ansibullbot added bug This issue/PR relates to a bug community_review module module needs_triage new_contributor Help guide this first time contributor plugins plugin (any type) small_patch Hopefully easy to review labels Feb 14, 2023
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/3e95b6053a4b4ff9915d3f10baa13213

ansible-galaxy-importer FAILURE in 4m 11s
✔️ build-ansible-collection SUCCESS in 13m 54s
ansible-test-sanity-aws-ansible-python38 RETRY_LIMIT in 1m 27s (non-voting)
ansible-test-sanity-aws-ansible-2.12-python38 FAILURE in 9m 21s
ansible-test-sanity-aws-ansible-2.13-python38 FAILURE in 10m 37s
ansible-test-sanity-aws-ansible-2.14 FAILURE in 11m 39s
ansible-test-units-amazon-aws-python36 RETRY_LIMIT in 16s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 9m 22s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 10m 58s
ansible-test-units-amazon-aws-python310 RETRY_LIMIT in 17s
✔️ cloud-tox-py3 SUCCESS in 7m 58s
ansible-test-changelog FAILURE in 4m 30s
✔️ ansible-test-splitter SUCCESS in 4m 59s
integration-amazon.aws-1 RETRY_LIMIT in 16s
Skipped 43 jobs

fix syntax error
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/8a1c8c08d3c34e55a6c570db7296fd0c

✔️ ansible-galaxy-importer SUCCESS in 3m 37s
✔️ build-ansible-collection SUCCESS in 12m 33s
ansible-test-sanity-aws-ansible-python38 FAILURE in 22m 52s (non-voting)
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 12m 30s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 8m 30s
ansible-test-sanity-aws-ansible-2.14 RETRY_LIMIT in 15s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 9m 15s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 8m 37s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 9m 26s
ansible-test-units-amazon-aws-python310 RETRY_LIMIT in 16s
✔️ cloud-tox-py3 SUCCESS in 7m 44s
ansible-test-changelog FAILURE in 5m 02s
✔️ ansible-test-splitter SUCCESS in 4m 39s
✔️ integration-amazon.aws-1 SUCCESS in 5m 58s
Skipped 43 jobs

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/9c9a034c8d034047911365cb7e51daab

ansible-galaxy-importer RETRY_LIMIT in 3m 43s
✔️ build-ansible-collection SUCCESS in 12m 52s
ansible-test-sanity-aws-ansible-python38 RETRY_LIMIT in 16s (non-voting)
ansible-test-sanity-aws-ansible-2.12-python38 FAILURE in 9m 59s
ansible-test-sanity-aws-ansible-2.13-python38 FAILURE in 9m 18s
ansible-test-sanity-aws-ansible-2.14 FAILURE in 9m 10s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 12m 23s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 8m 52s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 8m 50s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 9m 03s
✔️ cloud-tox-py3 SUCCESS in 7m 45s
ansible-test-changelog FAILURE in 4m 14s
✔️ ansible-test-splitter SUCCESS in 4m 46s
integration-amazon.aws-1 RETRY_LIMIT in 1m 26s
Skipped 43 jobs

Copy link
Contributor

@tremble tremble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to submit this PR. A couple of minor tweaks.

plugins/modules/s3_bucket.py Outdated Show resolved Hide resolved
changelogs/fragments/1368-empty_bucket_policy.yml Outdated Show resolved Hide resolved
@tremble tremble added the backport-5 PR should be backported to the stable-5 branch label Feb 15, 2023
@ansibullbot ansibullbot removed the small_patch Hopefully easy to review label Feb 15, 2023
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/ae5a8cbab7f74330adf33265396d9f3f

✔️ ansible-galaxy-importer SUCCESS in 3m 48s
✔️ build-ansible-collection SUCCESS in 12m 43s
ansible-test-sanity-aws-ansible-python38 FAILURE in 8m 34s (non-voting)
ansible-test-sanity-aws-ansible-2.12-python38 FAILURE in 9m 28s
ansible-test-sanity-aws-ansible-2.13-python38 FAILURE in 9m 44s
ansible-test-sanity-aws-ansible-2.14 FAILURE in 8m 30s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 9m 04s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 8m 37s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 9m 11s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 7m 59s
✔️ cloud-tox-py3 SUCCESS in 8m 12s
ansible-test-changelog FAILURE in 4m 17s
✔️ ansible-test-splitter SUCCESS in 4m 35s
✔️ integration-amazon.aws-1 SUCCESS in 5m 55s
Skipped 43 jobs

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/c161282c53944fcab5c542b136f60fdf

✔️ ansible-galaxy-importer SUCCESS in 4m 31s
✔️ build-ansible-collection SUCCESS in 13m 23s
ansible-test-sanity-aws-ansible-python38 RETRY_LIMIT in 1m 28s (non-voting)
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 10m 51s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 8m 37s
✔️ ansible-test-sanity-aws-ansible-2.14 SUCCESS in 11m 30s
ansible-test-units-amazon-aws-python36 RETRY_LIMIT in 16s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 9m 01s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 9m 27s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 8m 31s
✔️ cloud-tox-py3 SUCCESS in 8m 13s
✔️ ansible-test-changelog SUCCESS in 4m 21s
✔️ ansible-test-splitter SUCCESS in 5m 02s
✔️ integration-amazon.aws-1 SUCCESS in 7m 09s
Skipped 43 jobs

@tremble
Copy link
Contributor

tremble commented Feb 15, 2023

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/10da9f3e655c49f6a9aad31e7fe2cd0d

ansible-galaxy-importer RETRY_LIMIT in 15s
✔️ build-ansible-collection SUCCESS in 12m 39s
ansible-test-sanity-aws-ansible-python38 RETRY_LIMIT in 15s (non-voting)
ansible-test-sanity-aws-ansible-2.12-python38 RETRY_LIMIT in 15s
ansible-test-sanity-aws-ansible-2.13-python38 RETRY_LIMIT in 15s
ansible-test-sanity-aws-ansible-2.14 RETRY_LIMIT in 16s
ansible-test-units-amazon-aws-python36 RETRY_LIMIT in 16s
ansible-test-units-amazon-aws-python38 RETRY_LIMIT in 17s
ansible-test-units-amazon-aws-python39 RETRY_LIMIT in 18s
ansible-test-units-amazon-aws-python310 RETRY_LIMIT in 16s
✔️ cloud-tox-py3 SUCCESS in 7m 17s
✔️ ansible-test-changelog SUCCESS in 4m 11s
✔️ ansible-test-splitter SUCCESS in 4m 45s
integration-amazon.aws-1 RETRY_LIMIT in 17s
Skipped 43 jobs

@tremble
Copy link
Contributor

tremble commented Feb 16, 2023

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/d4bf0c831ef34bc1ae35a9e12209a156

✔️ ansible-galaxy-importer SUCCESS in 3m 48s
✔️ build-ansible-collection SUCCESS in 12m 17s
ansible-test-sanity-aws-ansible-python38 RETRY_LIMIT in 1m 28s (non-voting)
ansible-test-sanity-aws-ansible-2.12-python38 RETRY_LIMIT in 16s
ansible-test-sanity-aws-ansible-2.13-python38 RETRY_LIMIT in 16s
✔️ ansible-test-sanity-aws-ansible-2.14 SUCCESS in 9m 32s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 9m 03s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 11m 34s
ansible-test-units-amazon-aws-python39 RETRY_LIMIT in 16s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 10m 56s
✔️ cloud-tox-py3 SUCCESS in 6m 35s
✔️ ansible-test-changelog SUCCESS in 4m 13s
✔️ ansible-test-splitter SUCCESS in 4m 39s
✔️ integration-amazon.aws-1 SUCCESS in 6m 31s
Skipped 43 jobs

@tremble
Copy link
Contributor

tremble commented Feb 17, 2023

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/8dc8536a1be942eeb3942effecdb49bf

✔️ ansible-galaxy-importer SUCCESS in 3m 42s
✔️ build-ansible-collection SUCCESS in 12m 43s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 9m 23s (non-voting)
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 10m 12s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 9m 29s
ansible-test-sanity-aws-ansible-2.14 RETRY_LIMIT in 18s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 9m 15s
ansible-test-units-amazon-aws-python38 RETRY_LIMIT in 17s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 7m 28s
ansible-test-units-amazon-aws-python310 RETRY_LIMIT in 19s
✔️ cloud-tox-py3 SUCCESS in 9m 00s
✔️ ansible-test-changelog SUCCESS in 4m 23s
✔️ ansible-test-splitter SUCCESS in 5m 07s
✔️ integration-amazon.aws-1 SUCCESS in 6m 07s
Skipped 43 jobs

@goneri
Copy link
Member

goneri commented Feb 17, 2023

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/750272888c3641a7b319a81e698a3e93

✔️ ansible-galaxy-importer SUCCESS in 4m 22s
✔️ build-ansible-collection SUCCESS in 14m 07s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 8m 36s (non-voting)
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 11m 15s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 10m 53s
✔️ ansible-test-sanity-aws-ansible-2.14 SUCCESS in 11m 14s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 11m 19s
ansible-test-units-amazon-aws-python38 RETRY_LIMIT in 4m 38s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 9m 45s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 9m 01s
✔️ cloud-tox-py3 SUCCESS in 9m 14s
✔️ ansible-test-changelog SUCCESS in 4m 08s
✔️ ansible-test-splitter SUCCESS in 4m 38s
✔️ integration-amazon.aws-1 SUCCESS in 8m 13s
Skipped 43 jobs

@goneri
Copy link
Member

goneri commented Feb 17, 2023

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/dcf24c8cb4844080b05c585f61ec6181

✔️ ansible-galaxy-importer SUCCESS in 4m 32s
✔️ build-ansible-collection SUCCESS in 12m 54s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 8m 34s (non-voting)
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 11m 25s
ansible-test-sanity-aws-ansible-2.13-python38 RETRY_LIMIT in 16s
ansible-test-sanity-aws-ansible-2.14 RETRY_LIMIT in 16s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 11m 24s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 10m 17s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 10m 10s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 10m 47s
✔️ cloud-tox-py3 SUCCESS in 7m 58s
✔️ ansible-test-changelog SUCCESS in 4m 37s
✔️ ansible-test-splitter SUCCESS in 4m 36s
integration-amazon.aws-1 RETRY_LIMIT in 17s
Skipped 43 jobs

@goneri
Copy link
Member

goneri commented Feb 17, 2023

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/d3dd4bd50c50491bac8f5833b85f21e5

✔️ ansible-galaxy-importer SUCCESS in 4m 30s
✔️ build-ansible-collection SUCCESS in 12m 21s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 12m 41s (non-voting)
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 12m 32s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 12m 51s
✔️ ansible-test-sanity-aws-ansible-2.14 SUCCESS in 12m 31s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 10m 52s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 10m 54s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 10m 28s
✔️ ansible-test-units-amazon-aws-python310 SUCCESS in 12m 03s
✔️ cloud-tox-py3 SUCCESS in 6m 54s
✔️ ansible-test-changelog SUCCESS in 4m 15s
✔️ ansible-test-splitter SUCCESS in 4m 42s
✔️ integration-amazon.aws-1 SUCCESS in 8m 20s
Skipped 43 jobs

@tremble tremble added the mergeit Merge the PR (SoftwareFactory) label Feb 18, 2023
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).
https://ansible.softwarefactory-project.io/zuul/buildset/d4d06d5b125b4fbf9f8d4c480c097c73

✔️ ansible-galaxy-importer SUCCESS in 3m 56s
✔️ build-ansible-collection SUCCESS in 12m 43s
✔️ ansible-test-splitter SUCCESS in 4m 54s
✔️ integration-amazon.aws-1 SUCCESS in 7m 38s
Skipped 43 jobs

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 6948eb5 into ansible-collections:main Feb 18, 2023
@patchback
Copy link

patchback bot commented Feb 18, 2023

Backport to stable-5: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-5/6948eb577d17e29e6da11f08bcaa92e95aa5f73e/pr-1368

Backported as #1371

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Feb 18, 2023
s3_bucket.py - deal gracefuly with empty bucket policy

When using wasabi object storage, the bucket policy can be blank. This was throwing a json decode error. Fix by checking for empty string and returning None.
SUMMARY
Deals gracefully with empty bucket policy (encountered on wasabi storage).
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
s3_bucket
ADDITIONAL INFORMATION
Recreate by attempting to create a new bucket on wasabi:
ENV:
S3_URL=https://s3.us-west-1.wasabisys.com

name: create bucket
s3_bucket:
name: "thisbucketwillfail"

Reviewed-by: Mark Chappell
Reviewed-by: magicrobotmonkey
Reviewed-by: Alina Buzachis
(cherry picked from commit 6948eb5)
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Feb 18, 2023
[PR #1368/6948eb57 backport][stable-5] s3_bucket.py - deal gracefuly with empty bucket policy

This is a backport of PR #1368 as merged into main (6948eb5).
When using wasabi object storage, the bucket policy can be blank. This was throwing a json decode error. Fix by checking for empty string and returning None.
SUMMARY
Deals gracefully with empty bucket policy (encountered on wasabi storage).
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
s3_bucket
ADDITIONAL INFORMATION
Recreate by attempting to create a new bucket on wasabi:
ENV:
S3_URL=https://s3.us-west-1.wasabisys.com

name: create bucket
s3_bucket:
name: "thisbucketwillfail"

Reviewed-by: Mark Chappell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-5 PR should be backported to the stable-5 branch bug This issue/PR relates to a bug community_review mergeit Merge the PR (SoftwareFactory) module module new_contributor Help guide this first time contributor plugins plugin (any type)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants