nitrictech / cli

Nitric CLI. Manage and run Nitric apps locally and deploy to any cloud.
https://nitric.io
Apache License 2.0
26 stars 10 forks source link

Starter template cannot be brought down cleanly #368

Closed raksiv closed 2 years ago

raksiv commented 2 years ago

This is a starter template - typescript which fails to come down cleanly from the CLI


Log -

? Warning - This operation will destroy your stack, all deployed resources will be removed. Are you sure you want to proceed? Yes ⠽ Refreshing the Pulumi stack (2s)
ERROR : failed to destroy stack: exit status 255
code: 255 stdout: Destroying (jj-abc):

       -  aws:lambda:Permission mainhello deleting 
       -  aws:apigatewayv2:Stage mainDefaultStage deleting 
       -  aws:lambda:Permission mainhello deleted 
       -  aws:apigatewayv2:Stage mainDefaultStage deleted 
       -  aws:apigatewayv2:Api main deleting 
       -  aws:apigatewayv2:Api main deleted 
       -  aws:lambda:Function hello deleting 
       -  aws:lambda:Function hello deleted 
       -  docker-buildkit:index:Image hello-image deleting 
       -  aws:iam:RolePolicyAttachment helloLambdaBasicExecution deleting 
       -  aws:iam:RolePolicy helloListAccess deleting 
       -  docker-buildkit:index:Image hello-image deleted 
       -  aws:iam:RolePolicy helloListAccess deleted 
       -  aws:iam:RolePolicyAttachment helloLambdaBasicExecution deleted 
       -  aws:iam:Role helloLambdaRole deleting 
       -  nitric:Image hello deleting 
       -  aws:iam:Role helloLambdaRole deleted 
       -  nitric:api:AwsApiGateway main deleting 
       -  nitric:func:AWSLambda hello deleting 
       -  aws:resourcegroups:Group jj-abc deleting 
       -  aws:ecr:Repository jj-hello deleting 
       -  aws:ecr:Repository jj-hello deleting error: deleting urn:pulumi:jj-abc::jj::aws:ecr/repository:Repository::jj-hello: 1 error occurred:
       -  aws:ecr:Repository jj-hello **deleting failed** error: deleting urn:pulumi:jj-abc::jj::aws:ecr/repository:Repository::jj-hello: 1 error occurred:
       -  aws:resourcegroups:Group jj-abc deleted 
          pulumi:pulumi:Stack jj-jj-abc  error: update failed
          pulumi:pulumi:Stack jj-jj-abc **failed** 1 error
       -  nitric:Image hello deleted 
       -  nitric:api:AwsApiGateway main deleted 
       -  nitric:func:AWSLambda hello deleted 

      Diagnostics:
        pulumi:pulumi:Stack (jj-jj-abc):
          error: update failed

        aws:ecr:Repository (jj-hello):
          error: deleting urn:pulumi:jj-abc::jj::aws:ecr/repository:Repository::jj-hello: 1 error occurred:
            * ECR Repository (jj-hello-ff8d1d7) not empty, consider using force_delete: RepositoryNotEmptyException: The repository with name 'jj-hello-ff8d1d7' in registry with id '540870751824' cannot be deleted because it still contains images

      Resources:
          - 12 deleted

      Duration: 4s

      stderr:
raksiv commented 2 years ago

This might be environment specific, it does not happen with Nitric Deploy, and it does not happen on my Windows machine. Just Mac - using M1 chipset.

jyecusch commented 2 years ago

Looks like a race condition - the repository deletion is starting before the image deletion finishes, which means the repo isn't empty and fails.

-  nitric:Image hello deleting  # <<< starts deleting image here.
-  aws:iam:Role helloLambdaRole deleted 
-  nitric:api:AwsApiGateway main deleting 
-  nitric:func:AWSLambda hello deleting 
-  aws:resourcegroups:Group jj-abc deleting 
-  aws:ecr:Repository jj-hello deleting # <<< starts deleting the image repository (too soon)
-  aws:ecr:Repository jj-hello deleting error: deleting urn:pulumi:jj-abc::jj::aws:ecr/repository:Repository::jj-hello: 1 error occurred:
-  aws:ecr:Repository jj-hello **deleting failed** error: deleting urn:pulumi:jj-abc::jj::aws:ecr/repository:Repository::jj-hello: 1 error occurred:
-  aws:resourcegroups:Group jj-abc deleted 
  pulumi:pulumi:Stack jj-jj-abc  error: update failed
  pulumi:pulumi:Stack jj-jj-abc **failed** 1 error
-  nitric:Image hello deleted # <<< finishes deleting the image, the repo deletion would have worked after this

A temporary workaround is to run the down command again - the repository should be the only lingering resource and get pulled down on the second attempt.

asalkeld commented 2 years ago

The problem is we need to update pulumi-aws to v5 to get ForceDelete. PR on the way..

nitric-bot commented 2 years ago

:tada: This issue has been resolved in version 1.12.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: