4

I am getting the following error since this morning but nothing changed regarding my code (just added a log.println()... Even getting back to a previous version that was deployed doesn't solve the issue)

trigger.go (entry point)

// The function that runs with the cloud function itself
func HandleUserCreateEvent(ctx context.Context, e my_project.FirestoreEvent) error {

    log.Println("-------------------- oldValue --------------------")
    log.Printf("Name: %s\n", e.OldValue.Name)
    log.Printf("CreateTime: %v\n", e.OldValue.CreateTime)
    log.Printf("Fields: %v\n", e.OldValue.Fields)
    log.Printf("UpdateTime: %v\n", e.OldValue.UpdateTime)
    log.Println("-------------------- newValue --------------------")
    log.Printf("Name: %s\n", e.Value.Name)
    log.Printf("CreateTime: %v\n", e.Value.CreateTime)
    log.Printf("Fields: %v\n", e.Value.Fields)
    log.Printf("UpdateTime: %v\n", e.Value.UpdateTime)
    log.Println("-------------------- jsonValue -------------------")
    jsonB, _ := json.Marshal(e.Value)
    log.Printf("Json: %v\n", string(jsonB))
    log.Println("---------------------- DONE ----------------------")

    // My code

    return nil

deploy.sh (having also a deploy.bat which was working as well as the sh script below)

#!/usr/bin/env bash

# Deployment automation

name="HandleUserCreateEvent"
projectId="my_project"
collection="UsersCollection"

# Must call go vendor as go modules are ignored
go mod vendor
yes Y | gcloud functions deploy ${name} \
    --trigger-event providers/cloud.firestore/eventTypes/document.create \
    --trigger-resource "projects/${projectId}/databases/(default)/documents/${collection}/{pushId}" \
    --region europe-west1 \
    --runtime go113 \
    --allow-unauthenticated \
    --memory 128

As this was working perfectly, now it doesn't anymore (as stated, I just added the jsonValue part of the code you see above)

Error

MacBook-Pro-de-Emixam23:my-project-elasticsearch-creater emixam23$ ./deploy.sh 
Deploying function (may take a while - up to 2 minutes)...
....................................................failed.
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: # serverless_function_app/main
src/serverless_function_app/main/main.go:24:38: cannot use my_project_elasticsearch_creater.HandleUserCreateEvent (type func(context.Context, my_project_elasticsearch.FirestoreEvent) error) as type func(http.ResponseWriter, *http.Request) in argument to funcframework.RegisterHTTPFunction; Error ID: 6191efcd

Any idea? I really think that gcloud has some issues...


Update -> gcloud is really broken

I just redeployed an empty function, with only a simple struct as package with no dependencies (go modules empty)

type FirestoreEvent struct {
    OldValue   interface{} `json:"oldValue"`
    Value      interface{} `json:"value"`
    UpdateMask struct {
        FieldPaths []string `json:"fieldPaths"`
    } `json:"updateMask"`
}

Still the same issue

C:\Workspace\go\src\gitlab-group\my-project-elasticsearch-creater>gcloud --version
Google Cloud SDK 298.0.0
app-engine-go
app-engine-python 1.9.91
bq 2.0.58
cloud-datastore-emulator 2.1.0
core 2020.06.19
gsutil 4.51
Emixam23
  • 3,854
  • 8
  • 50
  • 107
  • 1
    Got exactly the same behavior yesterday but it started working again without changing anything. – Iliès M Jun 24 '20 at 08:34
  • If you think the problem is in the `gcloud` tool, you can always skip using it and deploy the function directly through the API: https://cloud.google.com/functions/docs/reference/rest/v1/projects.locations.functions/create -- If the function deploys, then the issue is with the `gcloud` tool, if not, it's something on the service side. This will not fix the issue, but will help identifying the source. – Jofre Jun 24 '20 at 10:11
  • Hi, thanks for your answer. Could you just help me out configuring this request? :/ because I am not sure about how can I deploy the code part once I configured the json – Emixam23 Jun 24 '20 at 10:23
  • Alright, it started to work again.. Just tried before leaving work and it did work.. As my colleague, it was just not working for a moment but back to normal now... – Emixam23 Jun 24 '20 at 16:14

1 Answers1

0

I tried the exact same at the end of the same day and it worked...

I believe it was a Google Cloud Platform issue related, no idea why we were not able to deploy it during a couple of hours.

Emixam23
  • 3,854
  • 8
  • 50
  • 107