O Cloud Deployment Manager vai chegar ao fim do suporte em 31 de dezembro de 2025. Se você usa o Deployment Manager, migre para o Infrastructure Manager ou uma tecnologia de implantação alternativa até 31 de dezembro de 2025 para garantir que seus serviços continuem sem interrupções.
Como gerenciar operações de longa duração com a API Deployment Manager
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Quando você faz uma solicitação de API ao Deployment Manager, ele
faz solicitações correspondentes a outras Google Cloud APIs. Por exemplo,
quando você cria uma implantação que inclui uma instância do Compute Engine,
o Deployment Manager envia uma solicitação instances.insert
para a API Compute Engine.
Ao criar, atualizar ou excluir implantações ou usar outros métodos de API que podem levar vários minutos ou mais para serem concluídos, as solicitações de API para o Deployment Manager retornam operações de longa duração.
Esta página descreve as diretrizes para gerenciar operações de longa duração com a API Deployment Manager.
Para verificar o status de uma operação, use o campo name da operação para
fazer uma solicitação operations.get()
e verificar o status ou progress da operação.
Quando o status for DONE, o progress for 100 e o objeto error estiver vazio, a implantação será concluída e os recursos estarão prontos para uso.
Se houver erros durante a operação, eles serão listados no objeto error,
neste formato:
"error":{"errors":[{"code":"error code"#string,"location":"location of the error"#string,"message":"error message"#string},...]}
Como prática recomendada, recomendamos consultar o status da operação com uma
espera exponencial. Por exemplo, faça a primeira solicitação após 5 segundos, a
próxima após 10 segundos, a terceira após 20 segundos e assim por diante. Recomendamos
definir um tempo de espera máximo de alguns minutos. Depois de atingir o tempo máximo
de espera, não é necessário continuar aumentando o tempo de espera.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-04-21 UTC."],[[["\u003cp\u003eDeployment Manager sends requests to other Google Cloud APIs, like Compute Engine, when you interact with it, and some of these API requests result in long-running operations.\u003c/p\u003e\n"],["\u003cp\u003eLong-running operations are triggered by actions like \u003ccode\u003einsert\u003c/code\u003e, \u003ccode\u003eupdate\u003c/code\u003e, or \u003ccode\u003edelete\u003c/code\u003e and return an Operation resource.\u003c/p\u003e\n"],["\u003cp\u003eThe status and progress of a long-running operation can be tracked using the \u003ccode\u003eoperations.get()\u003c/code\u003e method with the operation's name.\u003c/p\u003e\n"],["\u003cp\u003eWhen the operation's \u003ccode\u003estatus\u003c/code\u003e is \u003ccode\u003eDONE\u003c/code\u003e and \u003ccode\u003eprogress\u003c/code\u003e is \u003ccode\u003e100\u003c/code\u003e, the requested deployment is complete, if the \u003ccode\u003eerror\u003c/code\u003e field is not empty, there are errors listed within it.\u003c/p\u003e\n"],["\u003cp\u003eIt's recommended to poll the status of operations using exponential backoff, starting with a few seconds and increasing up to a maximum backoff time of a few minutes.\u003c/p\u003e\n"]]],[],null,["# Managing long-running operations with the Deployment Manager API\n\nWhen you make an API request to Deployment Manager, Deployment Manager\nmakes corresponding requests to other Google Cloud APIs. For example,\nwhen you create a deployment that includes a Compute Engine instance,\nDeployment Manager sends an [`instances.insert`](/compute/docs/reference/rest/v1/instances/insert)\nrequest to the Compute Engine API.\n\nWhen you are creating, updating, or deleting deployments, or using other\nAPI methods that might take several minutes or longer to complete,\nAPI requests to Deployment Manager return *long-running operations*.\n\nThis page describes the guidelines for managing long-running operations with\nthe Deployment Manager API.\n\nBefore you begin\n----------------\n\n- If you want to use the command-line examples in this guide, install the [\\`gcloud\\` command-line tool](/sdk).\n- If you want to use the API examples in this guide, set up [API access](/deployment-manager/docs/reference/latest).\n\nMethods that might start long-running operations include:\n\n- `insert` operations, such as [`deployments.insert()`](/deployment-manager/docs/reference/latest/deployments/insert), [`typeProviders.insert()`](/deployment-manager/docs/reference/v2beta/typeProviders/insert), and so on.\n- `update` operations, such as [`deployments.update()`](/deployment-manager/docs/reference/latest/deployments/update).\n- `delete` operations, such as [`deployments.delete()`](/deployment-manager/docs/reference/latest/deployments/delete).\n\nIn these requests, the response is an [Operation resource](/deployment-manager/docs/reference/latest/operations),\nwhich looks like this example: \n\n {\n \"kind\": \"deploymentmanager#operation\",\n \"id\": \"7123423453456654321\", # generated ID\n \"name\": \"operation-11233234311678-587af2c0xyz9c-0987fa54-baccd59f\", # generated name\n \"operationType\": \"insert\",\n \"targetLink\": \"https://www.googleapis.com/deploymentmanager/v2/projects/example-project/global/deployments/wordpress-1\",\n \"targetId\": \"5123321654456321123\",\n \"status\": \"DONE\", # possible values: RUNNING, PENDING, DONE\n \"user\": \"example@example.com\",\n \"progress\": 100,\n \"insertTime\": \"2019-04-29T11:08:32.190-07:00\",\n \"startTime\": \"2019-04-29T11:08:32.200-07:00\",\n \"endTime\": \"2019-04-29T11:09:38.176-07:00\",\n \"selfLink\": \"https://www.googleapis.com/deploymentmanager/v2/projects/example-project/global/operations/operation-11233234311678-587af2c0xyz9c-0987fa54-baccd59f\"\n }\n\nGet the status of an operation\n------------------------------\n\nTo check the status of an operation, use the operation's `name` field to\nmake an [`operations.get()`](/deployment-manager/docs/reference/latest/operations/get)\nrequest, and check the `status` or `progress` of the operation.\n\nWhen the `status` is `DONE`, `progress` is `100`, and the `error` object is\nempty, your deployment is complete and your resources are ready to use.\n\nIf there are errors during the operation, they are listed in the `error` object,\nin the following format: \n\n \"error\": {\n \"errors\": [\n {\n \"code\": \"error code\" # string,\n \"location\": \"location of the error\" # string,\n \"message\": \"error message\" # string\n },\n ...\n ]\n }\n\nAs a best practice, we recommend polling the operation's status with an\nexponential backoff. For example, make the first request after 5 seconds, the\nnext after 10 seconds, the third after 20 seconds, and so on. We recommend\nsetting a maximum backoff time of a few minutes. After you reach the maximum\nbackoff time, you do not need to continue increasing the backoff time."]]