Search code examples
google-cloud-platformgoogle-cloud-functionsgoogle-cloud-source-repos

Google cloud functions deployment through Cloud Source repositories stopped working


I managed to have a script deploying a GCP Function using the following command :

gcloud beta functions deploy pipeline-helper --set-env-vars PROPFILE_BUCKET=${my_bucket},PROPFILE_PATH=${some_property} --source https://source.developers.google.com/projects/{PROJECT}/repos/{REPO}/fixed-aliases/1.0.1/paths/ --entry-point onFlagFileCreation --runtime nodejs6 --trigger-resource ${my_bucket} --trigger-event google.storage.object.finalize --region europe-west1 --memory 1G --timeout 300s

That worked for a few days, the last one being December 4th. Then, when launched on December 27th ... the command failed with the following output (with debug option added) :

    Deploying function (may take a while - up to 2 minutes)...
..failed.
DEBUG: (gcloud.beta.functions.deploy) OperationError: code=13, message=Failed to retrieve function source code
Traceback (most recent call last):
  File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 841, in Execute
    resources = calliope_command.Run(cli=self, args=args)
  File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 770, in Run
    resources = command_instance.Run(args)
  File "/usr/lib/google-cloud-sdk/lib/surface/functions/deploy.py", line 203, in Run
    return _Run(args, track=self.ReleaseTrack(), enable_env_vars=True)
  File "/usr/lib/google-cloud-sdk/lib/surface/functions/deploy.py", line 157, in _Run
    return api_util.PatchFunction(function, updated_fields)
  File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/util.py", line 308, in CatchHTTPErrorRaiseHTTPExceptionFn
    return func(*args, **kwargs)
  File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/util.py", line 364, in PatchFunction
    operations.Wait(op, messages, client, _DEPLOY_WAIT_NOTICE)
  File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 126, in Wait
    _WaitForOperation(client, request, notice)
  File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 101, in _WaitForOperation
    sleep_ms=SLEEP_MS)
  File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/util/retry.py", line 219, in RetryOnResult
    result = func(*args, **kwargs)
  File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 65, in _GetOperationStatus
    raise exceptions.FunctionsError(OperationErrorToString(op.error))
FunctionsError: OperationError: code=13, message=Failed to retrieve function source code
ERROR: (gcloud.beta.functions.deploy) OperationError: code=13, message=Failed to retrieve function source code
Build step 'Execute shell' marked build as failure
Finished: FAILURE

My problem relates to the use of the --source option of this command when it points to a Google Source repository url (it works with gcs bucket or local directory)

I tried using the minimal valid source repository url https://source.developers.google.com/projects/PROJECT/repos/REPO as mentioned in the official doc here ... with no success (same error)

After that, i cloned the official sample « Google cloud functions - hello world sample to GC Repositories and tried to deploy it using an equivalent command ... with no more success (same error). However, i was able to deploy it via a zip uploaded to a gcs bucket in my project or from a local repository but not from Google Source repositories ...

The account used to deploy the Function ([email protected]) has the following right :

  • Stackdriver Debugger Agent
  • Cloud Functions Developer
  • Cloud Functions Service Agent
  • Editor
  • Service Account User
  • Source Repository Writer
  • Cloud Source Repositories Service Agent
  • Storage Object Creator
  • Storage Object Viewer

Any help would be greatly appreciated


Solution

  • As mentioned in my last comment to @Raj, the problem was due to a bug in GCP ... that is now fixed. Support « people » where kind and reactive. All is working as expected now !