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

Cloud Build Service Email Not Authenticating #199

Open
Adrianf23 opened this issue Aug 17, 2022 · 4 comments
Open

Cloud Build Service Email Not Authenticating #199

Adrianf23 opened this issue Aug 17, 2022 · 4 comments

Comments

@Adrianf23
Copy link
Contributor

I have done the tutorial successfully a few months ago, but I think there have been updates to the package that are causing me to have issues. I follow the tutorial to the T (have tried making clean GCP projects just to check) and when I try to set up the Cloud Build Service email, I run into this comment

Error: Could not authenticate via any gargle cred function

Session Info

R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] googleCloudRunner_0.5.0.9000

loaded via a namespace (and not attached):
[1] zip_2.2.0 pillar_1.7.0 compiler_4.2.1 googleAuthR_2.0.0 prettyunits_1.1.1
[6] remotes_2.4.2 tools_4.2.1 rmsfact_0.0.3 digest_0.6.29 pkgbuild_1.3.1
[11] lifecycle_1.0.1 jsonlite_1.8.0 praise_1.0.0 memoise_2.0.1 gargle_1.2.0
[16] tibble_3.1.7 pkgconfig_2.0.3 rlang_1.0.4 cli_3.3.0 rstudioapi_0.13
[21] curl_4.3.2 yaml_2.3.5 fastmap_1.1.0 withr_2.5.0 httr_1.4.4
[26] googlePubsubR_0.0.3 googleCloudStorageR_0.7.0 vctrs_0.4.1 fs_1.5.2 askpass_1.1
[31] rappdirs_0.3.3 rprojroot_2.0.3 glue_1.6.2 R6_2.5.1 processx_3.5.3
[36] fansi_1.0.3 callr_3.7.0 magrittr_2.0.3 ps_1.7.0 fortunes_1.5-4
[41] ellipsis_0.3.2 assertthat_0.2.1 jose_1.2.0 utf8_1.2.2 cowsay_0.8.0
[46] openssl_2.0.2 cachem_1.0.6 crayon_1.5.1

@Adrianf23
Copy link
Contributor Author

Adding the output from options(googleAuthR.verbose = 2)

options(googleAuthR.scopes.selected=c(' https://www.googleapis.com/auth/cloud-platform '))
options(googleAuthR.client_id=' 99151434606-9anb4d2lfdu74c1fqhqlqpl85aefpt0j.apps.googleusercontent.com ')
options(googleAuthR.client_secret=' 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 ')
options(googleAuthR.webapp.client_id=' ')
options(googleAuthR.webapp.client_secret=' ')
Error: Could not authenticate via any gargle cred function

@MarkEdmondson1234
Copy link
Owner

Hmm it's a generic can't authenticate message. Did you use the same authentication json as you did previously or generate a new one? Did you use the setup function at all - cr_setup() or cr_setup_auth() ?

@Adrianf23
Copy link
Contributor Author

Adrianf23 commented Aug 18, 2022 via email

@MarkEdmondson1234
Copy link
Owner

I just tried it with a completly new R project and GCP project and it worked, I did have to turn on some APIs manually (Cloud IAM, Resource Manager, Cloud Run and Cloud build) so perhaps check they are activated in your project. I added no scopes to the client authentication screen. I was using a project only .Renviron

History of my setup below, in case it helps:

> library(googleCloudRunner)
Error in library(googleCloudRunner) : 
  there is no package calledgoogleCloudRunner> remotes::install_github("MarkEdmondson1234/googleCloudRunner")
Using github PAT from envvar GITHUB_PAT
Downloading GitHub repo MarkEdmondson1234/googleCloudRunner@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

1: All                              
2: CRAN packages only               
3: None                             
4: rlang   (1.0.2   -> 1.0.4) [CRAN]
5: httr    (1.4.3   -> 1.4.4) [CRAN]
6: Rcpp    (1.0.8.3 -> 1.0.9) [CRAN]
7: gert    (1.6.0   -> 1.7.0) [CRAN]
8: stringi (1.7.6   -> 1.7.8) [CRAN]

Enter one or more numbers, or an empty line to skip updates: 1
rlang        (1.0.2   -> 1.0.4 ) [CRAN]
httr         (1.4.3   -> 1.4.4 ) [CRAN]
Rcpp         (1.0.8.3 -> 1.0.9 ) [CRAN]
gert         (1.6.0   -> 1.7.0 ) [CRAN]
swagger      (NA      -> 3.33.1) [CRAN]
webutils     (NA      -> 1.1   ) [CRAN]
stringi      (1.7.6   -> 1.7.8 ) [CRAN]
plumber      (NA      -> 1.2.0 ) [CRAN]
jose         (NA      -> 1.2.0 ) [CRAN]
googlePub... (NA      -> 0.0.3 ) [CRAN]
Installing 10 packages: rlang, httr, Rcpp, gert, swagger, webutils, stringi, plumber, jose, googlePubsubR

  There is a binary version available but the source version is later:
     binary source needs_compilation
httr  1.4.3  1.4.4             FALSE

trying URL 'https://cloud.r-project.org/bin/macosx/contrib/4.2/rlang_1.0.4.tgz'
Content type 'application/x-gzip' length 1812913 bytes (1.7 MB)
==================================================
downloaded 1.7 MB

trying URL 'https://cloud.r-project.org/bin/macosx/contrib/4.2/Rcpp_1.0.9.tgz'
Content type 'application/x-gzip' length 3277777 bytes (3.1 MB)
==================================================
downloaded 3.1 MB

trying URL 'https://cloud.r-project.org/bin/macosx/contrib/4.2/gert_1.7.0.tgz'
Content type 'application/x-gzip' length 2137930 bytes (2.0 MB)
==================================================
downloaded 2.0 MB

trying URL 'https://cloud.r-project.org/bin/macosx/contrib/4.2/swagger_3.33.1.tgz'
Content type 'application/x-gzip' length 562515 bytes (549 KB)
==================================================
downloaded 549 KB

trying URL 'https://cloud.r-project.org/bin/macosx/contrib/4.2/webutils_1.1.tgz'
Content type 'application/x-gzip' length 38700 bytes (37 KB)
==================================================
downloaded 37 KB

trying URL 'https://cloud.r-project.org/bin/macosx/contrib/4.2/stringi_1.7.8.tgz'
Content type 'application/x-gzip' length 14439459 bytes (13.8 MB)
==================================================
downloaded 13.8 MB

trying URL 'https://cloud.r-project.org/bin/macosx/contrib/4.2/plumber_1.2.0.tgz'
Content type 'application/x-gzip' length 1074713 bytes (1.0 MB)
==================================================
downloaded 1.0 MB

trying URL 'https://cloud.r-project.org/bin/macosx/contrib/4.2/jose_1.2.0.tgz'
Content type 'application/x-gzip' length 519060 bytes (506 KB)
==================================================
downloaded 506 KB

trying URL 'https://cloud.r-project.org/bin/macosx/contrib/4.2/googlePubsubR_0.0.3.tgz'
Content type 'application/x-gzip' length 650795 bytes (635 KB)
==================================================
downloaded 635 KB


The downloaded binary packages are in
	/var/folders/94/4rb8rsbd3bqbh0y67cvpq4q00000gn/T//RtmpVgYO5x/downloaded_packages
installing the source packagehttrtrying URL 'https://cloud.r-project.org/src/contrib/httr_1.4.4.tar.gz'
Content type 'application/x-gzip' length 161140 bytes (157 KB)
==================================================
downloaded 157 KB


# Welcome Mark! Today is Thu Aug 18 08:51:07 2022 

* installing *source* packagehttr...
** packagehttrsuccessfully unpacked and MD5 sums checked
** using staged installation
** R
** demo
** inst
** byte-compile and prepare package for lazy loading

# Welcome Mark! Today is Thu Aug 18 08:51:08 2022 

Goodbye Mark atThu Aug 18 08:51:11 2022

** help
*** installing help indices
** building package indices

# Welcome Mark! Today is Thu Aug 18 08:51:11 2022 


Goodbye Mark atThu Aug 18 08:51:11 2022

** installing vignettes
** testing if installed package can be loaded from temporary location

# Welcome Mark! Today is Thu Aug 18 08:51:11 2022 

Goodbye Mark atThu Aug 18 08:51:11 2022

** testing if installed package can be loaded from final location

# Welcome Mark! Today is Thu Aug 18 08:51:12 2022 

Goodbye Mark atThu Aug 18 08:51:12 2022

** testing if installed package keeps a record of temporary installation path
* DONE (httr)

Goodbye Mark atThu Aug 18 08:51:12 2022


The downloaded source packages are in/private/var/folders/94/4rb8rsbd3bqbh0y67cvpq4q00000gn/T/RtmpVgYO5x/downloaded_packages’
✔  checking for file/private/var/folders/94/4rb8rsbd3bqbh0y67cvpq4q00000gn/T/RtmpVgYO5x/remotesc8bb4b7a17c0/MarkEdmondson1234-googleCloudRunner-b124b97/DESCRIPTION...preparinggoogleCloudRunner: (1.5s)
✔  checking DESCRIPTION meta-information ...checking for LF line-endings in source and make files and shell scriptschecking for empty or unneeded directoriesbuildinggoogleCloudRunner_0.5.0.9000.tar.gz# Welcome Mark! Today is Thu Aug 18 08:51:15 2022 

* installing *source* packagegoogleCloudRunner...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading

# Welcome Mark! Today is Thu Aug 18 08:51:15 2022 


Goodbye Mark atThu Aug 18 08:51:18 2022

** help
*** installing help indices
** building package indices

# Welcome Mark! Today is Thu Aug 18 08:51:19 2022 

Goodbye Mark atThu Aug 18 08:51:19 2022

** testing if installed package can be loaded from temporary location

# Welcome Mark! Today is Thu Aug 18 08:51:19 2022 Setting scopes to https://www.googleapis.com/auth/cloud-platformFailed! Auto-authentication via  GCE_AUTH_FILE = /xxxx.auth.json  - error was:   Bad Request (HTTP 400).

Goodbye Mark atThu Aug 18 08:51:20 2022

** testing if installed package can be loaded from final location

# Welcome Mark! Today is Thu Aug 18 08:51:20 2022 Setting scopes to https://www.googleapis.com/auth/cloud-platformFailed! Auto-authentication via  GCE_AUTH_FILE = /xxxx.auth.json  - error was:   Bad Request (HTTP 400).

Goodbye Mark atThu Aug 18 08:51:20 2022

** testing if installed package keeps a record of temporary installation path
* DONE (googleCloudRunner)

Goodbye Mark atThu Aug 18 08:51:20 2022

> library(googleCloudRunner)
✔ Setting scopes to https://www.googleapis.com/auth/cloud-platformFailed! Auto-authentication via  GCE_AUTH_FILE = /xxxx.auth.json  - error was:   Bad Request (HTTP 400).

Restarting R session...


# Welcome Mark! Today is Thu Aug 18 08:52:36 2022 

> library(googleCloudRunner)
> cr_setup()
ℹ ==Welcome to googleCloudRunner v0.5.0.9000 setup==
This wizard will scan your system for setup options and help you with any that are missing. 
Hit 0 or ESC to cancel. 

1: Configure/check all googleCloudRunner settings
2: Configure GCP Project Id
3: Configure Authentication JSON file
4: Configure Cloud Storage bucket
5: Configure Cloud Run region
6: Configure Cloud Scheduler build email
7: Configure Cloud Build service account

Selection: 1
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Do you want to configure for all R sessions or just this project? 

1: All R sessions (Recommended)
2: Project only

Selection: 2Created local .Renviron file - please restart R then rerun setup.
Error: Need R restart

Restarting R session...


# Welcome Mark! Today is Thu Aug 18 08:53:03 2022 


> library(googleCloudRunner)
> cr_setup()
ℹ ==Welcome to googleCloudRunner v0.5.0.9000 setup==
This wizard will scan your system for setup options and help you with any that are missing. 
Hit 0 or ESC to cancel. 

1: Configure/check all googleCloudRunner settings
2: Configure GCP Project Id
3: Configure Authentication JSON file
4: Configure Cloud Storage bucket
5: Configure Cloud Run region
6: Configure Cloud Scheduler build email
7: Configure Cloud Build service account

Selection: 1
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Using local project .RenvironNo environment argument detected: GCE_DEFAULT_PROJECT_ID
Do you have a Google Cloud project-id to use?

1: Yes
2: No

Selection: 1
project-id: your-project-idSelected project-id: your-project-idConfiguring your .Renviron...
GCE_DEFAULT_PROJECT_ID=your-project-idWriting to /Users/mark/dev/cloudrunner_test/.RenvironAdded GCE_DEFAULT_PROJECT_ID=your-project-id to .Renviron and set via Sys.setenv()
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✖ No environment argument detected: GCE_AUTH_FILECould not find a OAuth 2.0 Client ID via GAR_CLIENT_JSON
Have you downloaded a Client ID file?

1: No
2: Yes

Selection: 1
! You must have a client ID file to proceed.Download via https://console.cloud.google.com/apis/credentials/oauthclient :Desktop app > Name > Create >OAuth 2.0 Client IDs >Click Download Arrow to the right >Download to your computer
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Rerun this wizard once you have your Client ID file
Open up service credentials URL?

1: Yeah
2: Nope
3: No way

Selection: 1Need a clientId to be set before configuring further
Error: Setting is required
> cr_setup()
ℹ ==Welcome to googleCloudRunner v0.5.0.9000 setup==
This wizard will scan your system for setup options and help you with any that are missing. 
Hit 0 or ESC to cancel. 

1: Configure/check all googleCloudRunner settings
2: Configure GCP Project Id
3: Configure Authentication JSON file
4: Configure Cloud Storage bucket
5: Configure Cloud Run region
6: Configure Cloud Scheduler build email
7: Configure Cloud Build service account

Selection: 2
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Using local project .RenvironFound: GCE_DEFAULT_PROJECT_ID=your-project-id
Do you want to edit this setting? 

1: Yes
2: No, leave it as it is

Selection: 2
> cr_setup()
ℹ ==Welcome to googleCloudRunner v0.5.0.9000 setup==
This wizard will scan your system for setup options and help you with any that are missing. 
Hit 0 or ESC to cancel. 

1: Configure/check all googleCloudRunner settings
2: Configure GCP Project Id
3: Configure Authentication JSON file
4: Configure Cloud Storage bucket
5: Configure Cloud Run region
6: Configure Cloud Scheduler build email
7: Configure Cloud Build service account

Selection: 1
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Using local project .RenvironFound: GCE_DEFAULT_PROJECT_ID=your-project-id
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✖ No environment argument detected: GCE_AUTH_FILECould not find a OAuth 2.0 Client ID via GAR_CLIENT_JSON
Have you downloaded a Client ID file?

1: No
2: Yes

Selection: 2
Select location of your client ID file:

1: Cancel
2: Ready

Selection: 2Validated Client ID file /Users/mark/dev/cloudrunner_test/client.jsonFound Client ID project: your-project-idConfiguring your .Renviron...
GAR_CLIENT_JSON=/Users/mark/dev/cloudrunner_test/client.jsonWriting to /Users/mark/dev/cloudrunner_test/.RenvironAdded GAR_CLIENT_JSON=/Users/mark/dev/cloudrunner_test/client.json to .Renviron and set via Sys.setenv()
Do you want to provision a service account for your project?

1: No, I already have one downloaded
2: Yes, I need a service account key

Selection: 2Creating service key file - choose service account name (Push enter for default 'googlecloudrunner')
service account name:Creating service account googlecloudrunnerSetting client.id from /Users/mark/dev/cloudrunner_test/client.json
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.2022-08-18 08:58:15 > Request Status Code:  4042022-08-18 08:58:15 > Creating new service account:  googlecloudrunner@your-project-id.iam.gserviceaccount.com2022-08-18 08:58:15 > Creating service accountId -  googlecloudrunner2022-08-18 08:58:16 > Request Status Code:  403
Error: http_403 Identity and Access Management (IAM) API has not been used in project 12345678 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/iam.googleapis.com/overview?project=12345678 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry. http_404 Unknown service account
> cr_setup()
ℹ ==Welcome to googleCloudRunner v0.5.0.9000 setup==
This wizard will scan your system for setup options and help you with any that are missing. 
Hit 0 or ESC to cancel. 

1: Configure/check all googleCloudRunner settings
2: Configure GCP Project Id
3: Configure Authentication JSON file
4: Configure Cloud Storage bucket
5: Configure Cloud Run region
6: Configure Cloud Scheduler build email
7: Configure Cloud Build service account

Selection: 1
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Using local project .RenvironFound: GCE_DEFAULT_PROJECT_ID=your-project-id
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✖ No environment argument detected: GCE_AUTH_FILEValidated Client ID file /Users/mark/dev/cloudrunner_test/client.jsonFound Client ID project: your-project-idUsing Client ID via GAR_CLIENT_JSON=/Users/mark/dev/cloudrunner_test/client.json
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Do you want to provision a service account for your project?

1: Yes, I need a service account key
2: No, I already have one downloaded

Selection: 1Creating service key file - choose service account name (Push enter for default 'googlecloudrunner')
service account name:Creating service account googlecloudrunnerSetting client.id from /Users/mark/dev/cloudrunner_test/client.json
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.2022-08-18 08:59:12 > Request Status Code:  4042022-08-18 08:59:12 > Creating new service account:  googlecloudrunner@your-project-id.iam.gserviceaccount.com2022-08-18 08:59:12 > Creating service accountId -  googlecloudrunner2022-08-18 08:59:12 > Checking existing roles2022-08-18 08:59:13 > Request Status Code:  403
Error in `abort_http()`:
! http_403 Cloud Resource Manager API has not been used in project 12345678 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudresourcemanager.googleapis.com/overview?project=12345678 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
Run `rlang::last_error()` to see where the error occurred.
> cr_setup()
ℹ ==Welcome to googleCloudRunner v0.5.0.9000 setup==
This wizard will scan your system for setup options and help you with any that are missing. 
Hit 0 or ESC to cancel. 

1: Configure/check all googleCloudRunner settings
2: Configure GCP Project Id
3: Configure Authentication JSON file
4: Configure Cloud Storage bucket
5: Configure Cloud Run region
6: Configure Cloud Scheduler build email
7: Configure Cloud Build service account

Selection: 1
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Using local project .RenvironFound: GCE_DEFAULT_PROJECT_ID=your-project-id
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✖ No environment argument detected: GCE_AUTH_FILEValidated Client ID file /Users/mark/dev/cloudrunner_test/client.jsonFound Client ID project: your-project-idUsing Client ID via GAR_CLIENT_JSON=/Users/mark/dev/cloudrunner_test/client.json
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Do you want to provision a service account for your project?

1: No, I already have one downloaded
2: Yes, I need a service account key

Selection: 2Creating service key file - choose service account name (Push enter for default 'googlecloudrunner')
service account name:Creating service account googlecloudrunnerSetting client.id from /Users/mark/dev/cloudrunner_test/client.json
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.2022-08-18 09:00:03 > Checking existing roles2022-08-18 09:00:03 > Granting roles:  roles/cloudbuild.builds.builder roles/secretmanager.secretAccessor roles/cloudscheduler.admin roles/iam.serviceAccountUser roles/run.admin roles/storage.admin roles/serviceusage.serviceUsageConsumer roles/pubsub.admin roles/viewer to accountIds:  googlecloudrunner@your-project-id.iam.gserviceaccount.com2022-08-18 09:00:04 > Creating secret auth key for service account googlecloudrunner  for project  your-project-id2022-08-18 09:00:05 > Writing secret auth JSON key to  googlecloudrunner-auth-key.json  and adding to .gitignoreMove googlecloudrunner-auth-key.json to a secure folder location outside of your working directory
Have you moved the file?

1: Yes
2: Absolutely not
3: No way

Selection: 1Service JSON key is now createdConfigure any authentication environment args to point at this service JSON key
Ready to browse to the file to be used for authentication?

1: Cancel
2: Ready

Selection: 2Validated authentication JSON fileConfiguring your .Renviron...
GCE_AUTH_FILE=/xxxx.auth.jsonWriting to /Users/mark/dev/cloudrunner_test/.RenvironAdded GCE_AUTH_FILE=/xxxx.auth.json to .Renviron and set via Sys.setenv()
✔ Successfully auto-authenticated via /xxxx.auth.jsonValidated authentication in GCE_AUTH_FILE
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✖ No environment argument detected: GCS_DEFAULT_BUCKET
Do you want to setup a Cloud Storage bucket?

1: No way
2: Yes
3: Absolutely not

Selection: 2
Do you have an existing Cloud Storage bucket you want to use?

1: Absolutely not
2: I agree
3: No way

Selection: 1
Do you want to make a new Cloud Storage bucket?

1: Absolutely
2: No
3: Absolutely not

Selection: 1
What name will the bucket be? :your-project-id-bucket20222022-08-18 09:01:22 > Bucket created successfully: your-project-id-bucket2022  in  USSuccessfully created bucket your-project-id-bucket2022Configuring your .Renviron...
GCS_DEFAULT_BUCKET=your-project-id-bucket2022Writing to /Users/mark/dev/cloudrunner_test/.RenvironAdded GCS_DEFAULT_BUCKET=your-project-id-bucket2022 to .Renviron and set via Sys.setenv()
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✖ No environment argument detected: CR_REGION
Do you want to setup a Cloud Run region?

1: No
2: Definitely
3: No way

Selection: 2
Which region shall Cloud Run perform in? 

 1: asia-east1                2: asia-east2                3: asia-northeast1        
 4: asia-northeast2           5: asia-northeast3           6: asia-south1            
 7: asia-south2               8: asia-southeast1           9: asia-southeast2        
10: australia-southeast1     11: australia-southeast2     12: europe-central2        
13: europe-north1            14: europe-west1             15: europe-west2           
16: europe-west3             17: europe-west4             18: europe-west6           
19: northamerica-northeast1  20: northamerica-northeast2  21: southamerica-east1     
22: us-central1              23: us-east1                 24: us-east4               
25: us-west1                 26: us-west2                 27: us-west3               
28: us-west4                 

Selection: 16Selected region: europe-west3Configuring your .Renviron...
CR_REGION=europe-west3Writing to /Users/mark/dev/cloudrunner_test/.RenvironAdded CR_REGION=europe-west3 to .Renviron and set via Sys.setenv()
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✖ No environment argument detected: CR_BUILD_EMAIL
Do you want to setup a Cloud Scheduler email?

1: Nope
2: Absolutely not
3: For sure

Selection: 3
Ensure that Cloud Scheduler is activated in your GCP console at https://console.cloud.google.com/cloudscheduler. Do you want to use the email from your JSON service account auth key?

1: Yes (Recommended)
2: No

Selection: 1Using email: googlecloudrunner@your-project-id.iam.gserviceaccount.comConfiguring your .Renviron...
CR_BUILD_EMAIL=googlecloudrunner@your-project-id.iam.gserviceaccount.comWriting to /Users/mark/dev/cloudrunner_test/.RenvironAdded CR_BUILD_EMAIL=googlecloudrunner@your-project-id.iam.gserviceaccount.com to .Renviron and set via Sys.setenv()
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Checking Cloud Build service email...Setting client.id from /Users/mark/dev/cloudrunner_test/client.json
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.2022-08-18 09:02:30 > Checking existing roles
Error: Could not find any roles for serviceAccount:12345678@cloudbuild.gserviceaccount.com
> cr_setup()
ℹ ==Welcome to googleCloudRunner v0.5.0.9000 setup==
This wizard will scan your system for setup options and help you with any that are missing. 
Hit 0 or ESC to cancel. 

1: Configure/check all googleCloudRunner settings
2: Configure GCP Project Id
3: Configure Authentication JSON file
4: Configure Cloud Storage bucket
5: Configure Cloud Run region
6: Configure Cloud Scheduler build email
7: Configure Cloud Build service account

Selection: 1
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Using local project .RenvironFound: GCE_DEFAULT_PROJECT_ID=your-project-id
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ Found: GCE_AUTH_FILE=/xxxx.auth.jsonSuccessfully auto-authenticated via /xxxx.auth.jsonValidated authentication in GCE_AUTH_FILE
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ Found: GCS_DEFAULT_BUCKET=your-project-id-bucket2022
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ Found: CR_REGION=europe-west3
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ Found: CR_BUILD_EMAIL=googlecloudrunner@your-project-id.iam.gserviceaccount.com
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Checking Cloud Build service email...Setting client.id from /Users/mark/dev/cloudrunner_test/client.json
The googleAuthR package is requesting access to your Google account.
Select a pre-authorised account or enter '0' to obtain a new token.
Press Esc/Ctrl + C to cancel.

1: my@email.com

Selection: 12022-08-18 09:03:01 > Checking existing roles
Error: Could not find any roles for serviceAccount:12345678@cloudbuild.gserviceaccount.com

#####
Here I had to activate the Cloud Build API in the GCP console
#####

> cr_setup()
ℹ ==Welcome to googleCloudRunner v0.5.0.9000 setup==
This wizard will scan your system for setup options and help you with any that are missing. 
Hit 0 or ESC to cancel. 

1: Configure/check all googleCloudRunner settings
2: Configure GCP Project Id
3: Configure Authentication JSON file
4: Configure Cloud Storage bucket
5: Configure Cloud Run region
6: Configure Cloud Scheduler build email
7: Configure Cloud Build service account

Selection: 1
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Using local project .RenvironFound: GCE_DEFAULT_PROJECT_ID=your-project-id
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ Found: GCE_AUTH_FILE=/xxxx.auth.jsonSuccessfully auto-authenticated via /xxxx.auth.jsonValidated authentication in GCE_AUTH_FILE
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ Found: GCS_DEFAULT_BUCKET=your-project-id-bucket2022
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ Found: CR_REGION=europe-west3
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ Found: CR_BUILD_EMAIL=googlecloudrunner@your-project-id.iam.gserviceaccount.com
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Checking Cloud Build service email...Setting client.id from /Users/mark/dev/cloudrunner_test/client.json
The googleAuthR package is requesting access to your Google account.
Select a pre-authorised account or enter '0' to obtain a new token.
Press Esc/Ctrl + C to cancel.

1: my@email.com

Selection: 12022-08-18 09:04:53 > Checking existing rolesThe Cloud Build service account (12345678@cloudbuild.gserviceaccount.com) has Cloud Build Access.The Cloud Build service account (12345678@cloudbuild.gserviceaccount.com) will need permissions during builds for certain operations calling other APIs.  This is distinct from the local authentication file you have setup.  Ensure Cloud Build is enabled at https://console.cloud.google.com/marketplace/product/google/cloudbuild.googleapis.com?project=your-project-id
What services do you want to setup for the Cloud Build service account? (Esc or 0 to skip) 

1: Skip or something not listed below
2: All of the below (Recommended)
3: Cloud Run deployments
4: Secret Manager
5: BigQuery operations
6: Cloud Storage operations

Selection: 2Configuring 12345678@cloudbuild.gserviceaccount.com for Cloud Run deploymentsSetting client.id from /Users/mark/dev/cloudrunner_test/client.jsonAdding 12345678@cloudbuild.gserviceaccount.com for project your-project-id with roles: roles/run.admin roles/iam.serviceAccountUser roles/serverless.serviceAgent
The googleAuthR package is requesting access to your Google account.
Select a pre-authorised account or enter '0' to obtain a new token.
Press Esc/Ctrl + C to cancel.

1: my@email.com

Selection: 12022-08-18 09:05:06 > Checking existing roles2022-08-18 09:05:06 > Granting roles:  roles/run.admin roles/iam.serviceAccountUser roles/serverless.serviceAgent to accountIds:  12345678@cloudbuild.gserviceaccount.comConfigured 12345678@cloudbuild.gserviceaccount.com with roles: roles/run.admin roles/iam.serviceAccountUser roles/serverless.serviceAgentConfiguring 12345678@cloudbuild.gserviceaccount.com to be able to access Secret ManagerSetting client.id from /Users/mark/dev/cloudrunner_test/client.jsonAdding 12345678@cloudbuild.gserviceaccount.com for project your-project-id with roles: roles/secretmanager.secretAccessor
The googleAuthR package is requesting access to your Google account.
Select a pre-authorised account or enter '0' to obtain a new token.
Press Esc/Ctrl + C to cancel.

1: my@email.com

Selection: 12022-08-18 09:05:09 > Checking existing roles2022-08-18 09:05:09 > Granting roles:  roles/secretmanager.secretAccessor to accountIds:  12345678@cloudbuild.gserviceaccount.comConfigured 12345678@cloudbuild.gserviceaccount.com with roles: roles/secretmanager.secretAccessorConfiguring 12345678@cloudbuild.gserviceaccount.com for BigQuery API tasksSetting client.id from /Users/mark/dev/cloudrunner_test/client.jsonAdding 12345678@cloudbuild.gserviceaccount.com for project your-project-id with roles: roles/bigquery.admin
The googleAuthR package is requesting access to your Google account.
Select a pre-authorised account or enter '0' to obtain a new token.
Press Esc/Ctrl + C to cancel.

1: my@email.com

Selection: 12022-08-18 09:05:12 > Checking existing roles2022-08-18 09:05:12 > Granting roles:  roles/bigquery.admin to accountIds:  12345678@cloudbuild.gserviceaccount.comConfigured 12345678@cloudbuild.gserviceaccount.com with roles: roles/bigquery.adminConfiguring 12345678@cloudbuild.gserviceaccount.com for Cloud Storage API tasksSetting client.id from /Users/mark/dev/cloudrunner_test/client.jsonAdding 12345678@cloudbuild.gserviceaccount.com for project your-project-id with roles: roles/storage.admin roles/viewer
The googleAuthR package is requesting access to your Google account.
Select a pre-authorised account or enter '0' to obtain a new token.
Press Esc/Ctrl + C to cancel.

1: my@email.com

Selection: 12022-08-18 09:05:14 > Checking existing roles2022-08-18 09:05:14 > Granting roles:  roles/storage.admin roles/viewer to accountIds:  12345678@cloudbuild.gserviceaccount.comConfigured 12345678@cloudbuild.gserviceaccount.com with roles: roles/storage.admin roles/viewer
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔ Setup complete! You can test it with cr_setup_test()
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
> cr_setup_test()
ℹ Perform deployments to test your setup is working. Takes around 5mins.  ESC or 0 to skip.Successfully auto-authenticated via /xxxx.auth.jsonValidated authentication in GCE_AUTH_FILE
Select which deployments to test 

1: All tests
2: Cloud Build - Docker
3: Cloud Run - plumber API with Pub/Sub
4: Cloud Build - R script
5: Cloud Scheduler - R script

Selection: 1

── Attempting Docker deployment on Cloud Build via cr_deploy_docker() ──

ℹ 2022-08-18 09:05:23 > No objects found2022-08-18 09:05:23 > Dockerfile found in /Library/Frameworks/R.framework/Versions/4.2/Resources/library/googleCloudRunner/example/ - using it and ignoring dockerfile argument

── # Deploy docker build for image: gcr.io/your-project-id/example ─────────────────────────────────────────────────

── # Uploading /Library/Frameworks/R.framework/Versions/4.2/Resources/library/googleCloudRunner/example/ to gs://ma2022-08-18 09:05:23 > Tarring files in tmpdir:api.RDockerfileserver.R2022-08-18 09:05:23 > Uploading example.tar.gz to your-project-id-bucket2022/example.tar.gz2022-08-18 09:05:23 > File size detected as 885 bytes2022-08-18 09:05:24 > StorageSource available for builds in directory: /workspace/deploy2022-08-18 09:05:24 > See ?cr_buildstep_source_move for a buildstep to move files into /workspace/Cloud Build started - logs:
<https://console.cloud.google.com/cloud-build/builds/6a941694-ccb6-4368-beab-5650eb53be6b?project=12345678>Build finished with status: SUCCESS and took ~[01m29s]
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Last 10 lines of build log.  Use cr_build_logs() to read more
Step #2: INFO[0026] COPY ["./", "./"]                            
Step #2: INFO[0026] Taking snapshot of files...                  
Step #2: INFO[0026] ENTRYPOINT ["Rscript", "server.R"]           
Step #2: INFO[0026] No files changed in this command, skipping snapshotting. 
Step #2: INFO[0026] Pushing image to gcr.io/your-project-id/example:6a941694-ccb6-4368-beab-5650eb53be6b 
Step #2: INFO[0028] Pushed image to 1 destinations               
Finished Step #2
PUSH
DONE

── # Docker images pushed: ────────────────────────────────────────────────────────────────────────────────────────
<gcr.io/your-project-id/example:latest>
<gcr.io/your-project-id/example:6a941694-ccb6-4368-beab-5650eb53be6b>Cloud Build Docker deployment successful

── Attempting deployment of plumber API on Cloud Run via cr_deploy_plumber() ──

ℹ 2022-08-18 09:06:58 > Uploading /Library/Frameworks/R.framework/Versions/4.2/Resources/library/googleCloudRunner/example/ folder for Cloud Run2022-08-18 09:06:58 > Dockerfile found in /Library/Frameworks/R.framework/Versions/4.2/Resources/library/googleCloudRunner/example/ - using it and ignoring dockerfile argument

── # Deploy docker build for image: gcr.io/your-project-id/example ─────────────────────────────────────────────────

── # Uploading /Library/Frameworks/R.framework/Versions/4.2/Resources/library/googleCloudRunner/example/ to gs://ma2022-08-18 09:06:58 > Tarring files in tmpdir:api.RDockerfileserver.R2022-08-18 09:06:58 > Uploading example.tar.gz to your-project-id-bucket2022/example.tar.gz2022-08-18 09:06:58 > File size detected as 887 bytes2022-08-18 09:06:58 > StorageSource available for builds in directory: /workspace/deploy2022-08-18 09:06:58 > See ?cr_buildstep_source_move for a buildstep to move files into /workspace/Cloud Build started - logs:
<https://console.cloud.google.com/cloud-build/builds/e5e92c97-a55f-4e59-bd6c-33005d2fd052?project=12345678>Build finished with status: SUCCESS and took ~[38s]
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Last 10 lines of build log.  Use cr_build_logs() to read more
Step #1: INFO[0022] COPY ["./", "./"]                            
Step #1: INFO[0022] Taking snapshot of files...                  
Step #1: INFO[0022] ENTRYPOINT ["Rscript", "server.R"]           
Step #1: INFO[0022] No files changed in this command, skipping snapshotting. 
Step #1: INFO[0022] Pushing image to gcr.io/your-project-id/example:e5e92c97-a55f-4e59-bd6c-33005d2fd052 
Step #1: INFO[0023] Pushed image to 1 destinations               
Finished Step #1
PUSH
DONE

── # Docker images pushed: ────────────────────────────────────────────────────────────────────────────────────────
<gcr.io/your-project-id/example:e5e92c97-a55f-4e59-bd6c-33005d2fd052>2022-08-18 09:07:38 > Built Docker image:  gcr.io/your-project-id/example:e5e92c97-a55f-4e59-bd6c-33005d2fd052

── #> Launching CloudRun image:  gcr.io/your-project-id/example:e5e92c97-a55f-4e59-bd6c-33005d2fd052 ───────────────Cloud Build started - logs:
<https://console.cloud.google.com/cloud-build/builds/8cae14d9-a950-4f6c-ab92-80b46439693c?project=12345678>Build failed with status: FAILURE and took ~[26s]
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Last 10 lines of build log.  Use cr_build_logs() to read more
Step #1 - "deploy cloudrun": - '@type': type.googleapis.com/google.rpc.ErrorInfo
Step #1 - "deploy cloudrun":   domain: googleapis.com
Step #1 - "deploy cloudrun":   metadata:
Step #1 - "deploy cloudrun":     consumer: projects/12345678
Step #1 - "deploy cloudrun":     service: run.googleapis.com
Step #1 - "deploy cloudrun":   reason: SERVICE_DISABLED
Finished Step #1 - "deploy cloudrun"
ERROR
ERROR: build step 1 "gcr.io/google.com/cloudsdktool/cloud-sdk:alpine" failed: step exited with non-zero status: 1

── #Problem deploying to Cloud Run ────────────────────────────────────────────────────────────────────────────────Something is wrong with Cloud Run setup

####
Here I needed to activate the Cloud Run API in the GCP console

####

── Testing Cloud Build R scripts deployments via cr_deploy_r() ──

ℹ 2022-08-18 09:08:07 > Deploy R script cr_rscript_2022081660806487090807 to Cloud BuildCloud Build started - logs:
<https://console.cloud.google.com/cloud-build/builds/01aabbe8-c771-422a-a504-e182282ead4e?project=12345678>Build finished with status: SUCCESS and took ~[01m08s]
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Last 10 lines of build log.  Use cr_build_logs() to read more

loaded via a namespace (and not attached):
 [1] fansi_1.0.3      assertthat_0.2.1 utf8_1.2.2       R6_2.5.1        
 [5] DBI_1.1.3        lifecycle_1.0.1  magrittr_2.0.3   pillar_1.8.0    
 [9] rlang_1.0.4      cli_3.3.0        ellipsis_0.3.2   vctrs_0.4.1     
[13] generics_0.1.3   glue_1.6.2       purrr_0.3.4      compiler_4.2.1  
[17] pkgconfig_2.0.3  tidyselect_1.1.2 tibble_3.1.8    
PUSH
DONECloud Build R scripts deployed successfully

── Testing scheduling R script deployments via cr_deploy_r(schedule = '* * * * *') ──

ℹ 2022-08-18 09:09:17 > Deploy R script cr_rscript_2022081660806557090917 to Cloud Build2022-08-18 09:09:17 > Scheduling R script on cron schedule: * * * * *2022-08-18 09:09:17 > Creating PubSub topic: cr_rscript_2022081660806557090917-topicprojects/your-project-id/topics/cr_rscript_2022081660806557090917-topic succesfully created2022-08-18 09:09:24 > Creating BuildTrigger subscription: cr-rscript-2022081660806557090917-topic-trigger
! No sourceToBuild detected for event based trigger2022-08-18 09:09:25 > Creating Cloud Schedule to trigger PubSub topicName: projects/your-project-id/topics/cr_rscript_2022081660806557090917-topicScheduled Cloud Build R scripts deployed successfully
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────

── Test summary ───────────────────────────────────────────────────────────────────────────────────────────────────
ℹ Cloud Build Docker deployment successfulSomething is wrong with Cloud Run setupCloud Build R scripts deployed successfullyScheduled Cloud Build R scripts deployed successfullyDeployment tests complete!
[1] TRUE

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

No branches or pull requests

2 participants