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

Fix fence-create google-bucket-create #1077

Merged
merged 1 commit into from
Mar 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions fence/scripting/fence_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,12 @@ def _create_or_update_google_bucket_and_db(
project_db_entry = (
db_session.query(Project).filter_by(auth_id=project_auth_id).first()
)
if project_db_entry:
if not project_db_entry:
logger.info(
"No project with auth_id {} found. No linking "
"occured.".format(project_auth_id)
)
else:
project_linkage = (
db_session.query(ProjectToBucket)
.filter_by(
Expand All @@ -1487,26 +1492,23 @@ def _create_or_update_google_bucket_and_db(
"Successfully linked project with auth_id {} "
"to the bucket.".format(project_auth_id)
)
else:
logger.info(
"No project with auth_id {} found. No linking "
"occured.".format(project_auth_id)
)

# Add StorageAccess if it doesn't exist for the project
storage_access = (
db_session.query(StorageAccess)
.filter_by(
project_id=project_db_entry.id, provider_id=google_cloud_provider.id
)
.first()
)
if not storage_access:
storage_access = StorageAccess(
project_id=project_db_entry.id, provider_id=google_cloud_provider.id
# Add StorageAccess if it doesn't exist for the project
storage_access = (
db_session.query(StorageAccess)
.filter_by(
project_id=project_db_entry.id,
provider_id=google_cloud_provider.id,
)
.first()
)
db_session.add(storage_access)
db_session.commit()
if not storage_access:
storage_access = StorageAccess(
project_id=project_db_entry.id,
provider_id=google_cloud_provider.id,
)
db_session.add(storage_access)
db_session.commit()

return bucket_db_entry

Expand Down