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

Enhance the IAM role binding process #4511

Merged
merged 5 commits into from May 4, 2022

Conversation

colerogers
Copy link
Contributor

  • Changes up the ordering of ensureServiceAgentRoles
  • Creates jump out points so we don't re-try to set permissions
  • Adds better logging & warnings
  • Adds a 60 second sleep to the process

@colerogers colerogers requested review from taeold and inlined May 3, 2022 15:29
"You can either re-run `firebase deploy` as a project owner or manually run the following set of `gcloud` commands:",
"warn"
);
for (const binding of requiredBindings) {
Copy link
Member

Choose a reason for hiding this comment

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

🤯 dedication to DevX!

requiredBindingsPromises.push(service.requiredProjectBindings!(projectNumber));
}
const nestedRequiredBindings = await Promise.all(requiredBindingsPromises);
const requiredBindings = nestedRequiredBindings.reduce((requiredBindings, binding) => {
Copy link
Member

Choose a reason for hiding this comment

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

Is this not just const requiredBindings = functional.flattenArray(nestedRequiredBindings)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤯 🤯 🤯 just realizing that we have this module!

throw new FirebaseError(
"We failed to modify the IAM policy for the project. The functions " +
"deployment requires specific roles to be granted to service agents," +
" otherwise the deployment will fail.",
{ original: err }
);
}

if (!skipSleep) {
Copy link
Member

Choose a reason for hiding this comment

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

  1. What happens if we don't sleep? Do deploys fail or do requests fail?
  2. Is there really nothing we can query to see if this has gone into effect?
  3. Can we get a comment explaining concern 1 & 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this in for unit testing.

After playing around with personal accounts, I opted to remove this sleep since we aren't guaranteed to have everything setup in this timeframe. Looking deeper, there are some corner cases where we must trigger eventarc through a create operation before everything is generated correctly. So I enhanced our error message when we run into this case (it will only be on the first deploy) to have the user re-run the deploy in a few minutes (this is also what Eventarc does)

@colerogers colerogers enabled auto-merge (squash) May 4, 2022 17:17
@colerogers colerogers merged commit 6dd0b84 into master May 4, 2022
@kaibolay kaibolay deleted the colerogers.enhance-iam-permission-bindings branch September 15, 2022 15:32
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 this pull request may close these issues.

None yet

2 participants