admin管理员组

文章数量:1305093

I have a Cloud Run Job on GCP that gets invoked programmatically. The invoker code passes ContainerOverrides to the request like this:

            var request = new RunJobRequest
            {
                JobName = JobName.FromProjectLocationJob(
                    "myproject", "region", "job-name"),
                Overrides = new RunJobRequest.Types.Overrides
                {
                    ContainerOverrides =
                    {
                        new List<RunJobRequest.Types.Overrides.Types.ContainerOverride>()
                        {
                            new()
                            {
                                Name = "pass arguments",
                                ClearArgs = true,
                                Args =
                                {
                                    new List<string>
                                    {
                                        "arg1", "arg2"
                                    }
                                }
                            }
                        }
                    },
                    TaskCount = 1
                }
            };
            var response = this._cloudRunClient.RunJob(request);

I can see the arguments in the request, and I can see them in the Run Job execution in the console:

Command and arguments: (container entrypoint) arg1 arg2

But the problem is the args collection is empty in the Run Job code:

        if (args.Length == 0)
        {
            logger.Log(LogSeverity.Warning, $"No arguments received");
        }

I always get No arguments received. I've also tried making a request manually from GCP console, adding override arguments, but with the same results.

According to this example it should work:

What's missing here?

I have a Cloud Run Job on GCP that gets invoked programmatically. The invoker code passes ContainerOverrides to the request like this:

            var request = new RunJobRequest
            {
                JobName = JobName.FromProjectLocationJob(
                    "myproject", "region", "job-name"),
                Overrides = new RunJobRequest.Types.Overrides
                {
                    ContainerOverrides =
                    {
                        new List<RunJobRequest.Types.Overrides.Types.ContainerOverride>()
                        {
                            new()
                            {
                                Name = "pass arguments",
                                ClearArgs = true,
                                Args =
                                {
                                    new List<string>
                                    {
                                        "arg1", "arg2"
                                    }
                                }
                            }
                        }
                    },
                    TaskCount = 1
                }
            };
            var response = this._cloudRunClient.RunJob(request);

I can see the arguments in the request, and I can see them in the Run Job execution in the console:

Command and arguments: (container entrypoint) arg1 arg2

But the problem is the args collection is empty in the Run Job code:

        if (args.Length == 0)
        {
            logger.Log(LogSeverity.Warning, $"No arguments received");
        }

I always get No arguments received. I've also tried making a request manually from GCP console, adding override arguments, but with the same results.

According to this example it should work: https://github/CharlieDigital/gcr-invoke-job-overrides

What's missing here?

Share Improve this question asked Feb 3 at 20:39 Alex PopescuAlex Popescu 711 silver badge9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I’m trying to replicate your problem but everything seems to be working correctly on my end. The logs from my cloud run job shows that the arguments are received before and after the overrides similar to the example you’ve provided.

It seems like your container is not receiving the arguments properly. You may check your Dockerfile for any misconfiguration then run your container locally to test if the arguments are being passed correctly. However, this doesn’t mean that the container actually receives them and you still need to verify it in the logs.

docker run gcr.io/[PROJECT-ID]/[CLOUD-RUN-JOB] arg1 arg2

本文标签: net coreGCP Cloud Run Job not receiving invocation argumentsStack Overflow