ObrienlabsDev / biometric-gcp-functions

biometric http endpoint in gcp cloud functions
Apache License 2.0
0 stars 0 forks source link

GCP Cloud Functions Endpoint #1

Open obriensystems opened 4 months ago

obriensystems commented 4 months ago
obriensystems commented 4 months ago

testing automated deployment 4 min

michael@cloudshell:~/functions-old/biometric-gcp-functions (functions-old)$ ./deployment.sh -c true -d false -p true -b functions-old 
existing project: 
Date: Tue May 21 12:49:59 AM UTC 2024
Timestamp: 1716252599
old
running with create=true delete=false boot_project_id=functions-old
Creating project: biometric-gcp-functions-8519
STREAM_PROJECT_ID: biometric-gcp-functions-8519
Updated property [core/project].
Creating project: biometric-gcp-functions-8519 on folder: 205060695395
Create in progress for [https://cloudresourcemanager.googleapis.com/v1/projects/biometric-gcp-functions-8519].
Waiting for [operations/cp.7172439024531334493] to finish...done.                                                                                          
Enabling service [cloudapis.googleapis.com] on project [biometric-gcp-functions-8519]...
Operation "operations/acat.p2-183057211041-fd5b721a-2f51-488c-b173-88c8a9febfce" finished successfully.
Updated property [core/project] to [biometric-gcp-functions-8519].
billingAccountName: billingAccounts/019283-6F1AB5-7AD576
billingEnabled: true
name: projects/biometric-gcp-functions-8519/billingInfo
projectId: biometric-gcp-functions-8519
Updated property [core/project].
Operation "operations/acf.p2-183057211041-d7ef379e-b1a0-4e98-88b5-3057de2c65a2" finished successfully.
Operation "operations/acf.p2-183057211041-4ff5f1de-cd91-468b-acc2-2c29c96bed8a" finished successfully.
Operation "operations/acf.p2-183057211041-01a881fc-0acd-4917-918a-8e4b38ceaec6" finished successfully.
provisioning to biometric-gcp-functions-8519
Preparing function...done.                                                                                                                                 
X  Deploying function...                                                                                                                                   
     [Build] Logs are available at [https://console.cloud.google.com/cloud-build/builds;region=us-central1/8952f9cf-5e17-462e-82e1-bfa58655fa7f?project=183
  057211041]                                                                                                                                               
  OK [Service]                                                                                                                                             
  .  [ArtifactRegistry]                                                                                                                                    
  .  [Healthcheck]                                                                                                                                         
  .  [Triggercheck]                                                                                                                                        
Completed with warnings:                                                                                                                                   
  [WARNING] Failed to find vendored functions-framework dependency. Installing version 1.3.1:
<nil>
You can view your function in the Cloud Console here: https://console.cloud.google.com/functions/details/us-central1/java-http-function?project=biometric-gcp-functions-8519

buildConfig:
  build: projects/183057211041/locations/us-central1/builds/8952f9cf-5e17-462e-82e1-bfa58655fa7f
  dockerRegistry: ARTIFACT_REGISTRY
  dockerRepository: projects/biometric-gcp-functions-8519/locations/us-central1/repositories/gcf-artifacts
  entryPoint: gcfv2.HelloHttpFunction
  runtime: java17
  source:
    storageSource:
      bucket: gcf-v2-sources-183057211041-us-central1
      generation: '1716252662027596'
      object: java-http-function/function-source.zip
  sourceProvenance:
    resolvedStorageSource:
      bucket: gcf-v2-sources-183057211041-us-central1
      generation: '1716252662027596'
      object: java-http-function/function-source.zip
createTime: '2024-05-21T00:51:02.939884321Z'
environment: GEN_2
labels:
  deployment-tool: cli-gcloud
name: projects/biometric-gcp-functions-8519/locations/us-central1/functions/java-http-function
serviceConfig:
  allTrafficOnLatestRevision: true
  availableCpu: '0.3333'
  availableMemory: 512M
  ingressSettings: ALLOW_ALL
  maxInstanceCount: 100
  maxInstanceRequestConcurrency: 1
  revision: java-http-function-00001-wok
  service: projects/biometric-gcp-functions-8519/locations/us-central1/services/java-http-function
  serviceAccountEmail: 183057211041-compute@developer.gserviceaccount.com
  timeoutSeconds: 60
  uri: https://java-http-function-ldhdsmfe6a-uc.a.run.app
state: ACTIVE
updateTime: '2024-05-21T00:53:11.653205595Z'
url: https://us-central1-biometric-gcp-functions-8519.cloudfunctions.net/java-http-function
Updated property [core/project].
Total Duration: 1716252794 sec
Date: Tue May 21 12:53:14 AM UTC 2024
Timestamp: 1716252794
Screenshot 2024-05-20 at 20 56 14

rename - by shutdown, redeploy

michael@cloudshell:~/functions-old/biometric-gcp-functions (functions-old)$ ./deployment.sh -c false -d true -p false -b functions-old -s biometric-gcp-functions-8519
existing project: 
Date: Tue May 21 12:59:01 AM UTC 2024
Timestamp: 1716253141
old
running with create=false delete=true boot_project_id=functions-old
Reusing project: biometric-gcp-functions-8519
STREAM_PROJECT_ID: biometric-gcp-functions-8519
billingAccountName: ''
billingEnabled: false
name: projects/biometric-gcp-functions-8519/billingInfo
projectId: biometric-gcp-functions-8519
Deleted [https://cloudresourcemanager.googleapis.com/v1/projects/biometric-gcp-functions-8519].

You can undo this operation for a limited period by running the command below.
    $ gcloud projects undelete biometric-gcp-functions-8519

See https://cloud.google.com/resource-manager/docs/creating-managing-projects for information on shutting down projects.
Updated property [core/project].
Total Duration: 1716253148 sec
Date: Tue May 21 12:59:08 AM UTC 2024
Timestamp: 1716253148
**** Done ****

redeploy

michael@cloudshell:~/functions-old/biometric-gcp-functions (functions-old)$ ./deployment.sh -c true -d false -p true -b functions-old 
existing project: 
Date: Tue May 21 01:01:13 AM UTC 2024
Timestamp: 1716253273
old
running with create=true delete=false boot_project_id=functions-old
Creating project: biometric-gcp-functions-7278
STREAM_PROJECT_ID: biometric-gcp-functions-7278
Updated property [core/project].
Creating project: biometric-gcp-functions-7278 on folder: 205060695395
Create in progress for [https://cloudresourcemanager.googleapis.com/v1/projects/biometric-gcp-functions-7278].
Waiting for [operations/cp.4819459672408868824] to finish...done.                                                                                          
Enabling service [cloudapis.googleapis.com] on project [biometric-gcp-functions-7278]...
Operation "operations/acat.p2-1044890481595-dfbfa68c-5a81-4673-823e-27b84d6a0190" finished successfully.
Updated property [core/project] to [biometric-gcp-functions-7278].
billingAccountName: billingAccounts/019283-6F1AB5-7AD576
billingEnabled: true
name: projects/biometric-gcp-functions-7278/billingInfo
projectId: biometric-gcp-functions-7278
Updated property [core/project].
Operation "operations/acf.p2-1044890481595-d68c67f1-90ac-4dda-a55f-47e5f758e7f4" finished successfully.
Operation "operations/acf.p2-1044890481595-2b3e4990-6152-45bf-a772-4dc6a2c99694" finished successfully.
Operation "operations/acf.p2-1044890481595-e6ef1c89-22ac-4cb0-b51d-4e2f3a506126" finished successfully.
provisioning to biometric-gcp-functions-7278
Preparing function...done.                                                                                                                                 
X  Deploying function...                                                                                                                                   
     [Build] Logs are available at [https://console.cloud.google.com/cloud-build/builds;region=us-central1/b16f972c-7cdc-416e-84fd-31ba37613774?project=104
  4890481595]                                                                                                                                              
  OK [Service]                                                                                                                                             
  .  [ArtifactRegistry]                                                                                                                                    
  .  [Healthcheck]                                                                                                                                         
  .  [Triggercheck]                                                                                                                                        
Completed with warnings:                                                                                                                                   
  [WARNING] Failed to find vendored functions-framework dependency. Installing version 1.3.1:
<nil>
You can view your function in the Cloud Console here: https://console.cloud.google.com/functions/details/us-central1/biometric?project=biometric-gcp-functions-7278

buildConfig:
  build: projects/1044890481595/locations/us-central1/builds/b16f972c-7cdc-416e-84fd-31ba37613774
  dockerRegistry: ARTIFACT_REGISTRY
  dockerRepository: projects/biometric-gcp-functions-7278/locations/us-central1/repositories/gcf-artifacts
  entryPoint: gcfv2.HelloHttpFunction
  runtime: java17
  source:
    storageSource:
      bucket: gcf-v2-sources-1044890481595-us-central1
      generation: '1716253338929000'
      object: biometric/function-source.zip
  sourceProvenance:
    resolvedStorageSource:
      bucket: gcf-v2-sources-1044890481595-us-central1
      generation: '1716253338929000'
      object: biometric/function-source.zip
createTime: '2024-05-21T01:02:19.938930743Z'
environment: GEN_2
labels:
  deployment-tool: cli-gcloud
name: projects/biometric-gcp-functions-7278/locations/us-central1/functions/biometric
serviceConfig:
  allTrafficOnLatestRevision: true
  availableCpu: '0.3333'
  availableMemory: 512M
  ingressSettings: ALLOW_ALL
  maxInstanceCount: 100
  maxInstanceRequestConcurrency: 1
  revision: biometric-00001-nuc
  service: projects/biometric-gcp-functions-7278/locations/us-central1/services/biometric
  serviceAccountEmail: 1044890481595-compute@developer.gserviceaccount.com
  timeoutSeconds: 60
  uri: https://biometric-4y3rrqs4ya-uc.a.run.app
state: ACTIVE
updateTime: '2024-05-21T01:04:57.502745858Z'
url: https://us-central1-biometric-gcp-functions-7278.cloudfunctions.net/biometric
Updated property [core/project].
Total Duration: 1716253501 sec
Date: Tue May 21 01:05:01 AM UTC 2024
Timestamp: 1716253501
**** Done ****
obriensystems commented 3 months ago

Getting a periodic issue with the logWriter role on the compute service account when running the cloud build under the cloud functions deployment

image

image

adding

# The service account running this build does not have permission to write logs. To fix this, grant the Logs Writer (roles/logging.logWriter) role to the service account.
# set roles/logging.logWriter on project id service account - -compute@developer.gserviceaccount.com

 PROJECT_NUMBER=$(gcloud projects list --filter="${STREAM_PROJECT_ID}" '--format=value(PROJECT_NUMBER)')
 echo "PROJECT_NUMBER: $PROJECT_NUMBER"
 SA_EMAIL=$PROJECT_NUMBER-compute@developer.gserviceaccount.com
 echo "bind $SA_EMAIL"
 gcloud organizations add-iam-policy-binding "${ORG_ID}" --member="serviceAccount:${SA_EMAIL}" --role=roles/logging.logWriter --condition=None --quiet

 echo "wait 60 sec"
 sleep 60

results

wait 60 sec
provisioning to biometric-gcp-functions-6260
Preparing function...
.done.
Deploying function...
[Build]...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................warning
[Service]...........................................................................................................................................................................................................................................................................................................................................................................done
Completed with warnings:
  [WARNING] Failed to find vendored functions-framework dependency. Installing version 1.3.1:
<nil>
You can view your function in the Cloud Console here: https://console.cloud.google.com/functions/details/us-central1/ptlm?project=biometric-gcp-functions-6260

buildConfig:
  automaticUpdatePolicy: {}
  build: projects/264963702235/locations/us-central1/builds/f9af975c-bf93-4be6-a443-4c4e51e991fe
  dockerRegistry: ARTIFACT_REGISTRY
  dockerRepository: projects/biometric-gcp-functions-6260/locations/us-central1/repositories/gcf-artifacts
  entryPoint: gcfv2.PeriodicTableLMHttpFunction
  runtime: java17
  source:
    storageSource:
      bucket: gcf-v2-sources-264963702235-us-central1
      generation: '1718908716321611'
      object: ptlm/function-source.zip
  sourceProvenance:
    resolvedStorageSource:
      bucket: gcf-v2-sources-264963702235-us-central1
      generation: '1718908716321611'
      object: ptlm/function-source.zip
createTime: '2024-06-20T18:38:36.554564406Z'
environment: GEN_2
labels:
  deployment-tool: cli-gcloud
name: projects/biometric-gcp-functions-6260/locations/us-central1/functions/ptlm
serviceConfig:
  allTrafficOnLatestRevision: true
  availableCpu: '0.3333'
  availableMemory: 512M
  ingressSettings: ALLOW_ALL
  maxInstanceCount: 100
  maxInstanceRequestConcurrency: 1
  revision: ptlm-00001-niq
  service: projects/biometric-gcp-functions-6260/locations/us-central1/services/ptlm
  serviceAccountEmail: 264963702235-compute@developer.gserviceaccount.com
  timeoutSeconds: 60
  uri: https://ptlm-f5c34n5jta-uc.a.run.app
state: ACTIVE
updateTime: '2024-06-20T18:40:32.665603906Z'
url: https://us-central1-biometric-gcp-functions-6260.cloudfunctions.net/ptlm
Updated property [core/project].
Total Duration: 1718908839 sec
Date: Thu Jun 20 14:40:39 EDT 2024
Timestamp: 1718908839