Doug Fir
Doug Fir

Reputation: 21292

Get errorType:OK when trying to deploy function

I'm struggling to deploy my cloud function. I'm unsure what information to provide. My set up:

# main.py
def callRequest():
    print("bla")
    return(1)

Entry point for the function is callRequest.

After failing to deploy I see this red highlighted message under details: Deployment failure:

Build failed: {"metrics":{},"error":{"buildpackId":"","buildpackVersion":"","errorType":"OK","canonicalCode":"OK","errorId":"","errorMessage":""},"stats":[{"buildpackId":"google.utils.archive-source","buildpackVersion":"0.0.1","totalDurationMs":47,"userDurationMs":46},{"buildpackId":"google.python.runtime","buildpackVersion":"0.9.1","totalDurationMs":9487,"userDurationMs":6307},{"buildpackId":"google.python.functions-framework","buildpackVersion":"0.9.6","totalDurationMs":53,"userDurationMs":52},{"buildpackId":"google.python.pip","buildpackVersion":"0.9.2","totalDurationMs":5832,"userDurationMs":5822},{"buildpackId":"google.utils.label","buildpackVersion":"0.0.2","totalDurationMs":0,"userDurationMs":0}],"warnings":null,"customImage":false}

In the logs I see a notice related to the attempted deploy:

{
  "protoPayload": {
    "@type": "type.googleapis.com/google.cloud.audit.AuditLog",
    "authenticationInfo": {
      "principalEmail": "[email protected]"
    },
    "requestMetadata": {
      "callerIp": "152.170.106.184",
      "callerSuppliedUserAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0,gzip(gfe),gzip(gfe)",
      "requestAttributes": {
        "time": "2023-01-11T13:15:30.667011Z",
        "auth": {}
      },
      "destinationAttributes": {}
    },
    "serviceName": "cloudfunctions.googleapis.com",
    "methodName": "google.cloud.functions.v1.CloudFunctionsService.UpdateFunction",
    "authorizationInfo": [
      {
        "resource": "projects/my-project/locations/us-central1/functions/ga4-to-s3-1",
        "permission": "cloudfunctions.functions.update",
        "granted": true,
        "resourceAttributes": {}
      }
    ],
    "resourceName": "projects/my-project/locations/us-central1/functions/ga4-to-s3-1",
    "request": {
      "updateMask": "entryPoint,sourceUploadUrl",
      "@type": "type.googleapis.com/google.cloud.functions.v1.UpdateFunctionRequest",
      "function": {
        "name": "projects/my-project/locations/us-central1/functions/ga4-to-s3-1",
        "runtime": "python39",
        "serviceAccountEmail": "[email protected]",
        "availableMemoryMb": 256,
        "maxInstances": 3000,
        "timeout": "60s",
        "eventTrigger": {
          "eventType": "google.pubsub.topic.publish",
          "resource": "projects/my-project/topics/ga4-daily-extract-complete"
        },
        "secretEnvironmentVariables": [
          {
            "version": "latest",
            "key": "PAT",
            "secret": "PAT-GA4-S3-Extract",
            "projectId": "1234567"
          }
        ],
        "sourceUploadUrl": "https://storage.googleapis.com/uploads-1234567.us-central1.cloudfunctions.appspot.com/123-456-789-abc-def.zip?GoogleAccessId=service-123456789@gcf-admin-robot.iam.gserviceaccount.com&Expires=12345&Signature=kjhgfghjkjhg%iuytfrghj8765467uhgfdfghj",
        "entryPoint": "callRequest",
        "ingressSettings": "ALLOW_ALL"
      }
    },
    "resourceLocation": {
      "currentLocations": [
        "us-central1"
      ]
    }
  },
  "insertId": "nlbq4xd9dhq",
  "resource": {
    "type": "cloud_function",
    "labels": {
      "project_id": "my-project",
      "function_name": "ga4-to-s3-1",
      "region": "us-central1"
    }
  },
  "timestamp": "2023-01-11T13:15:30.423213Z",
  "severity": "NOTICE",
  "logName": "projects/my-project/logs/cloudaudit.googleapis.com%2Factivity",
  "operation": {
    "id": "operations/Z2E0LWV4dHJhY3QvdXMtY2VudHJhbDEvZ2E0LXRvLXMzLTEvbHA2QlowNzBTekk",
    "producer": "cloudfunctions.googleapis.com",
    "first": true
  },
  "receiveTimestamp": "2023-01-11T13:15:31.626931279Z"
}

I'm unsure where else to look? Any pointers or advice most welcome.

Upvotes: 0

Views: 118

Answers (1)

Sathi Aiswarya
Sathi Aiswarya

Reputation: 2940

Found the similar issue discussed here and the issue resolved.

cloud build service account was missing the Cloud Build Service Account role.

I tried removing the Cloud Build Service Account role and deployed the function, I also got the same deployment errors

Try adding the Cloud Build Service Account role for the Google Cloud Build Service Account ([email protected]) in the Google Cloud IAM console . This fixed symptom of a cloud function deploy with the message:

message=Build failed: {
   "metrics":{},
   "error":{
      "buildpackId":"",
      "buildpackVersion":"",
      "errorType":"OK",
      "canonicalCode":"OK",
      "errorId":"",
      "errorMessage":""
   }
}

Also have a look at this github link1 & link2 which might help

Upvotes: 1

Related Questions