GoogleCloudPlatform/functions-framework-dotnet

Error deploying function, possibly docker pull related?

jchannon opened this issue · 11 comments

I have Terraform taking the output of a dotnet publish -c Release, zipping it and uploading it to a storage bucket and then telling my function to look in said bucket for said zip file.

The zipping and uploading all works well and the start of the function creation seems to work ok as I can see that in the GCP UI however it then fails with an unhelpful error message with little clue what's wrong

Screenshot 2021-03-05 at 11 03 31

If I look at the logs I have the below, not sure if the docker error is the issue?

Screenshot 2021-03-05 at 11 07 26

It's not clear to me what you mean by "and then telling my function to look in said bucket for said zip file."

Is this about deploying a function which is in a zip file, or a function which is already deployed, and which is looking in a bucket for the zip file? Or do you have one function deploying another?

Note that we don't currently support deploying just from an already-built binary - that's already been requested in #185. Perhaps that's what you're running into? (That would certainly be consistent with there being no appropriate buildpack, because presumably you don't have a csproj file any more...)

My terraform for the function is like so:

resource "google_cloudfunctions_function" "error-notifications" {
  name        = "error-notifications"
  runtime     = "dotnet3"

  available_memory_mb   = 512
  source_archive_bucket = "${var.GCP_PROJECT}-api-sources"
  source_archive_object = google_storage_bucket_object.error-notifications-main-sources.name
  entry_point           = "Notifications.Function"

  event_trigger {
    event_type = "google.pubsub.topic.publish"
    resource = "aggregation-summaries"
  }
 
  depends_on = [
    google_storage_bucket_object.error-notifications-main-sources
  ]
}

This defines a function which looks in a storage bucket for a zip file that contains the result of a dotnet publish

If I use gcloud functions deploy from the source directory of my function all is well so I don't think it's my function that is the issue but something infra related?

Again, it looks like you're trying to just deploy the built binaries, which isn't supported - the deployment infrastructure expects to build the function - it looks for the project file.

If you want to deploy an already-built function, at the moment you'll need to use Cloud Run to deploy it. (You can still use the Functions Framework, of course.)

Hmm that might be it then, we have nodejs functions that do support this approach so assumed we could do the same.

Does nodejs have a distinction between "source representation" and "built representation"? (I haven't done any work in node.) If not, that would presumably be the difference.

I suspect if you deploy the source code for your .NET app, it will work fine - you could still run dotnet publish -c Release separately first as a sort of check (and run any tests etc) but then put the source code in the zip file.

It's possible that there'd be some way of "faking" it via a csproj file that basically said "copy the already-built binaries as the output" but I haven't looked into that.

Uploading the source files instead into a zip etc does work however, when a subsequent deployment is triggered I get an error stating the function already exists

Error: googleapi: Error 409: Function error-notifications in region europe-west1 in project dev-***-*** already exists, alreadyExists

Actually that's my fault

Goodo... at this point, I think everything's covered by #185. Are you happy for this to be closed as a duplicate of that?

I'll bring it up again with the team. Definitely good to get more of an idea of demand for the feature.