-
Notifications
You must be signed in to change notification settings - Fork 159
Remove old policy bindings so that setup-project is reentrant #73
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
Remove old policy bindings so that setup-project is reentrant #73
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: davidz627 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
deploy/setup-project.sh
Outdated
@@ -10,10 +10,11 @@ if [ -f $SA_FILE ]; then | |||
rm "$SA_FILE" | |||
fi | |||
gcloud iam service-accounts delete "$IAM_NAME" --quiet || true | |||
# TODO: Delete ALL policy bindings | |||
gcloud projects remove-iam-policy-binding "${PROJECT}" --member serviceAccount:"${IAM_NAME}" --role roles/compute.admin --quiet || true |
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.
With this change, can we reduce the compute.admin role?
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.
good point, I will look into it
42d93f1
to
b5a0f14
Compare
role scopes and added custom role for necessary extras
b5a0f14
to
3499c3a
Compare
@msau42 updated so that roles are fairly minimal |
deploy/setup-project.sh
Outdated
# Create or Update Custom Role | ||
if gcloud iam roles describe gcp_compute_persistent_disk_csi_driver_custom_role --project "${PROJECT}"; | ||
then | ||
yes | gcloud iam roles update gcp_compute_persistent_disk_csi_driver_custom_role \ |
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.
does the -q option not work for suppressing interactive mode?
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.
brainfarted
|
||
# Create new Service Account and Keys | ||
gcloud iam service-accounts create "${GCEPD_SA_NAME}" | ||
gcloud iam service-accounts keys create "${SA_FILE}" --iam-account "${IAM_NAME}" | ||
gcloud projects add-iam-policy-binding "${PROJECT}" --member serviceAccount:"${IAM_NAME}" --role roles/compute.admin |
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.
your role-binding teardown logic will not be backwards compatible anymore. maybe it needs to somehow iterate through all the rolebindings the SA has, and delete them
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.
resolved
deploy/setup-project.sh
Outdated
done | ||
# Delete ALL EXISTING Bindings | ||
gcloud projects get-iam-policy "${PROJECT}" --format json > "${PKGDIR}/deploy/iam.json" | ||
sed -i "/${IAM_NAME}/d" "${PKGDIR}/deploy/iam.json" |
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.
Could this accidentally match a substring of the IAM_NAME?
Say you had something called "foobar", and your IAM_NAME was "bar"
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.
good catch, amended with prefix serviceAccount:
d3f87c8
to
6ad9a4b
Compare
deploy/setup-project.sh
Outdated
# Delete ALL EXISTING Bindings | ||
gcloud projects get-iam-policy "${PROJECT}" --format json > "${PKGDIR}/deploy/iam.json" | ||
sed -i "/serviceAccount:${IAM_NAME}/d" "${PKGDIR}/deploy/iam.json" | ||
gcloud projects set-iam-policy "${PROJECT}" "${PKGDIR}/deploy/iam.json" |
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.
hmm although in general I find this kind of scary because it sets all the rolebindings in your entire project to the .json, not just this particular service account. If someone is also modifying the iam policies at the same time, this could override their changes.
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.
theres an etag that is used for consistency. gcloud projects set-iam-policy
will fail if the etag is out of date. I haven't written in any failure handling logic. It shouldn't be too difficult to just run the script again.
/lgtm |
…ncy-openshift-4.19-ose-gcp-pd-csi-driver OCPBUGS-45567: Updating ose-gcp-pd-csi-driver-container image to be consistent with ART for 4.19
Have the
setup-project.sh
script remove old policy bindings so that they can be recreated successfully.Part of: #73
/assign @msau42