Definir el número máximo de reintentos de las tareas
Organízate con las colecciones
Guarda y clasifica el contenido según tus preferencias.
Un trabajo de Cloud Run consta de una o varias tareas. El ajuste de reintentos máximos especifica el número de veces que se permite reiniciar una tarea en caso de fallo antes de que falle de forma permanente. El valor predeterminado es 3.
Este ajuste se aplica por tarea, no por trabajo. Si le asignas el valor 0, las tareas solo se ejecutan una vez y no se vuelven a intentar si fallan.
Roles obligatorios
Para obtener los permisos que necesitas para configurar los trabajos de Cloud Run, pide a tu administrador que te conceda los siguientes roles de gestión de identidades y accesos:
Seleccione Trabajos en el menú y haga clic en Implementar contenedor para rellenar la página de configuración inicial del trabajo. Si vas a configurar un trabajo que ya existe, selecciona el trabajo y haz clic en Editar.
Haz clic en Contenedores, volúmenes, conexiones y seguridad para desplegar la página de propiedades del trabajo.
Haz clic en la pestaña General.
Especifica el número de reintentos con un número entero del 0 al 10.
resource"google_cloud_run_v2_job""default"{name="cloud-run-job-retries"location="us-central1"deletion_protection=false # set to "true" in productiontemplate{template{max_retries=3containers{image="us-docker.pkg.dev/cloudrun/container/job:latest"}}}}
Ver la configuración de reintentos máximos
Para ver la configuración actual del número máximo de reintentos de tu trabajo de Cloud Run, sigue estos pasos:
Consola
En la Google Cloud consola, ve a la página de trabajos de Cloud Run:
[[["Es fácil de entender","easyToUnderstand","thumb-up"],["Me ofreció una solución al problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Es difícil de entender","hardToUnderstand","thumb-down"],["La información o el código de muestra no son correctos","incorrectInformationOrSampleCode","thumb-down"],["Me faltan las muestras o la información que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-08-21 (UTC)."],[],[],null,["# Set maximum retries for jobs\n\nA Cloud Run job consists of one or more tasks. The maximum retries\nsetting specifies the number of times a task is allowed to restart in case of\nfailure before being failed permanently. The default is\n3.\n\nThis setting applies per-task, not per-job. If you set this to 0, tasks only run\nonce and are not retried on failure.\n\nRequired roles\n--------------\n\n\nTo get the permissions that\nyou need to configure Cloud Run jobs,\n\nask your administrator to grant you the\nfollowing IAM roles:\n\n- [Cloud Run Developer](/iam/docs/roles-permissions/run#run.developer) (`roles/run.developer`) on the Cloud Run job\n- [Service Account User](/iam/docs/roles-permissions/iam#iam.serviceAccountUser) (`roles/iam.serviceAccountUser`) on the service identity\n\n\nFor a list of IAM roles and permissions that are associated with\nCloud Run, see\n[Cloud Run IAM roles](/run/docs/reference/iam/roles)\nand [Cloud Run IAM permissions](/run/docs/reference/iam/permissions).\nIf your Cloud Run job interfaces with\nGoogle Cloud APIs, such as Cloud Client Libraries, see the\n[service identity configuration guide](/run/docs/configuring/jobs/service-identity).\nFor more information about granting roles, see\n[deployment permissions](/run/docs/reference/iam/roles#additional-configuration)\nand [manage access](/iam/docs/granting-changing-revoking-access).\n\nConfigure maximum retries\n-------------------------\n\nTo specify maximum retries: \n\n### Console\n\n\n1. In the Google Cloud console, go to the Cloud Run jobs page:\n\n [Go to Cloud Run](https://console.cloud.google.com/run)\n2. Select **Jobs** from the menu, and click **Deploy container** to fill out\n the initial job settings page. If you are configuring an existing job,\n select the job, then click **Edit**.\n\n3. Click **Container(s), Volumes, Connections, Security** to expand the job properties page.\n\n4. Click the **General** tab.\n\n - Specify the number of retries using an integer from 0 to 10.\n5. Click **Create** or **Update**.\n\n### gcloud\n\n1. For a job you are creating:\n\n ```bash\n gcloud run jobs create JOB_NAME --image IMAGE_URL --max-retries RETRY\n ```\n\n Replace\n - \u003cvar translate=\"no\"\u003eJOB_NAME\u003c/var\u003e with the name of your job.\n - \u003cvar translate=\"no\"\u003eIMAGE_URL\u003c/var\u003e: a reference to the [container image](/run/docs/building/containers)---for example, `us-docker.pkg.dev/cloudrun/container/job:latest`.\n - \u003cvar translate=\"no\"\u003eRETRY\u003c/var\u003e with the number of retries: specify an integer from 0 to 10.\n2. For a job you are updating:\n\n ```bash\n gcloud run jobs update JOB_NAME --max-retries RETRY\n ```\n\n### YAML\n\n1. If you are creating a new job, skip this step.\n If you are updating an existing job, download its [YAML configuration](/run/docs/reference/yaml/v1#job):\n\n ```bash\n gcloud run jobs describe JOB_NAME --format export \u003e job.yaml\n ```\n2. Update the `maxRetries:` attribute:\n\n ```yaml\n apiVersion: run.googleapis.com/v1\n kind: Job\n metadata:\n name: JOB\n spec:\n template:\n spec:\n template:\n spec:\n containers:\n - image: IMAGE\n maxRetries: RETRIES\n ```\n\n Replace \u003cvar translate=\"no\"\u003eRETRIES\u003c/var\u003e with the number of retries: specify an integer\n from `0` to `10`.\n\n You can also specify more configuration such as environment variables or\n memory limits.\n3. Update the existing job configuration:\n\n ```bash\n gcloud run jobs replace job.yaml\n ```\n\n### Terraform\n\n\u003cbr /\u003e\n\nTo learn how to apply or remove a Terraform configuration, see\n[Basic Terraform commands](/docs/terraform/basic-commands).\nAdd the following to a [`google_cloud_run_v2_job`](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/cloud_run_v2_job) resource in your Terraform configuration: \n\n\u003cbr /\u003e\n\n resource \"google_cloud_run_v2_job\" \"default\" {\n name = \"cloud-run-job-retries\"\n location = \"us-central1\"\n\n deletion_protection = false # set to \"true\" in production\n\n template {\n template {\n max_retries = 3\n\n containers {\n image = \"us-docker.pkg.dev/cloudrun/container/job:latest\"\n }\n }\n }\n }\n\nView maximum retries settings\n-----------------------------\n\nTo view the current maximum retries settings for your\nCloud Run job: \n\n### Console\n\n1. In the Google Cloud console, go to the Cloud Run jobs page:\n\n [Go to Cloud Run jobs](https://console.cloud.google.com/run/jobs)\n2. Click the job you are interested in to open the **Job details** page.\n\n3. Click **View and Edit job configuration**.\n\n4. Locate the maximum retries setting in the configuration\n details.\n\n### gcloud\n\n1. Use the following command:\n\n ```bash\n gcloud run jobs describe JOB_NAME\n ```\n2. Locate the maximum retries setting in the returned\n configuration."]]