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 "could not assert Secret Manager permissions" Cloud Build error #6904

Merged

Conversation

mathu97
Copy link
Contributor

@mathu97 mathu97 commented Mar 22, 2024

Users are often running into this could not assert Secret Manager permissions error when onboarding to apphosting.

This occurs when the user has no Cloud Build repo connections (including the sentinel Oauth connection) and the secret manager admin role has not been granted to the Cloud Build P4SA. So when the user goes to create an Oauth connection first but Cloud Build has no permissions to save the oath token in secret manager, it throws the above error.

To fix this we just need to ensure that the correct secret manager privileges are set to the Cloud Build P4SA before even creating the initial sentinel Oauth connection.

@mathu97 mathu97 requested a review from tonyjhuang March 22, 2024 17:03
@mathu97 mathu97 enabled auto-merge (squash) March 22, 2024 17:55
@mathu97 mathu97 force-pushed the mathusan/fix-secretmanager-admin-permission-required-bug branch from 4baff20 to 8c94eb9 Compare March 25, 2024 18:41
@mathu97 mathu97 requested a review from tonyjhuang March 25, 2024 18:41
@@ -174,7 +173,20 @@ async function getOrCreateOauthConnection(
projectId: string,
location: string,
): Promise<gcb.Connection> {
let conn = await getOrCreateConnection(projectId, location, APPHOSTING_OAUTH_CONN_NAME);
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix! I wonder if we can get rid of getOrCreateConnection now by inlining it in the other callsites (which I believe should just be linkGitHubRepository())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ya we can but I do like that it helps with readability.

Copy link
Contributor

@tonyjhuang tonyjhuang left a comment

Choose a reason for hiding this comment

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

Can we add a test?

@codecov-commenter
Copy link

codecov-commenter commented Mar 25, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 54.52%. Comparing base (4a17ca7) to head (bcf2aa0).

Files Patch % Lines
src/init/features/apphosting/repo.ts 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6904      +/-   ##
==========================================
+ Coverage   54.44%   54.52%   +0.07%     
==========================================
  Files         353      353              
  Lines       24652    24657       +5     
  Branches     5094     5095       +1     
==========================================
+ Hits        13423    13443      +20     
+ Misses      10012     9995      -17     
- Partials     1217     1219       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mathu97 mathu97 force-pushed the mathusan/fix-secretmanager-admin-permission-required-bug branch from 35339f2 to 71b426b Compare March 25, 2024 23:51
@mathu97 mathu97 merged commit 6950829 into master Mar 26, 2024
35 checks passed
@mathu97 mathu97 deleted the mathusan/fix-secretmanager-admin-permission-required-bug branch March 26, 2024 01:40
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

3 participants