0

It appears that you cannot deploy a Gen2 cloud function using gcloud from a cloud source repo unless it is at the top level.

Here's a sample redacted deploy command for a gen 1 python function that works:

gcloud beta functions deploy funcname --source https://source.developers.google.com/projects/projectname/repos/reponame/moveable-aliases/main/paths/pathname --runtime python310 --trigger-http --project=projectname

if you add the -gen2 flag, it fails because it can't find main.py. Error is:

OperationError: code=3, message=Build failed with status: FAILURE and message: missing main.py and GOOGLE_FUNCTION_SOURCE not specified. Either create the function in main.py or specify GOOGLE_FUNCTION_SOURCE to point to the file that contains the function.

If you add main.py to the root of the repo and run the same command, it finds main.py, which indicates to me that it isn't honoring the paths.

There is an additional problem which doesn't matter unless the first one is fixed, which is that if pathname is below the top level (folder/subfolder) gcloud sees that as a syntax error when the gen2 flag is set, but not without it.

Is there any way around this? It is very inconvenient.

4
  • I suspect this may be a problem with the gcloud version. I will update if that turns out to be true. Commented Sep 20, 2022 at 18:01
  • Nope, tried with the 2022.9.12 version of gcloud beta, still can't find main.py unless I move it to the root of the repo. Commented Sep 20, 2022 at 19:15
  • I suspect an unsupported feature because gen2 is still in preview. Open a case to the support to track the bug and have a fix in the future. Commented Sep 21, 2022 at 7:29
  • issuetracker.google.com/issues/248110968 Commented Sep 28, 2022 at 22:33

1 Answer 1

1

Answering as community wiki.As per above comments

There is a bug raised for this at issue tracker. Which is still open further progress can be tracked there.

1
  • yeah still not solved ...
    – harold
    Commented Jan 13, 2023 at 16:43

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.