pacbot icon indicating copy to clipboard operation
pacbot copied to clipboard

Pacbot destroy command did not delete all AWS resources

Open jayeshdub opened this issue 7 years ago • 19 comments

I had some disk space issue due to which the deploy was incomplete.

I first tried to redeploy but that did not work, then I destroyed the pacbot resources from AWS to redeploy but the resources were deleted partially.

Please help.

jayeshdub avatar Feb 19 '19 11:02 jayeshdub

Have you deleted resources manually or using destroy command?

sajeer-nooh avatar Feb 19 '19 14:02 sajeer-nooh

Hi @jayeshdub

The underlying orchestration tool for PacBot setup is terraform. If the installation cease because of any error like this, then terraform would not be able to track the state of the resources creation.

So when you faced the issue, instead of destroying if you would have tried the install command again then sometimes that could have solved the problem. But now since you tried the destroy, terraform state file might not have the exact status of the resources. So it could destroy only the resources whose status are present in the terraform state file.

Please follow the solutions listed below

Solution 1: Step1: In the local.py file or common.py file, change the value of SKIP_RESOURCE_EXISTENCE_CHECK to True i.e. SKIP_RESOURCE_EXISTENCE_CHECK = True Step 2: Try, sudo python3 manager.py install command again Step 3: If this executes successfully then you can proceed with the setup. Step 4: Revert back the change that you have made for SKIP_RESOURCE_EXISTENCE_CHECK i.e. update the value to False, SKIP_RESOURCE_EXISTENCE_CHECK = False

Solution 2: Step 1: If Solution-1 did not solve the issue, then try destroy command 2 or 3 times

Solution 3: Step 1: If both solution 1 & 2, could not resolve the issue, then we need to manually handle this. Destroy the resources manually by going to AWS console Step 2: If you are not aware of what are the resources created then you can try install command, which will not proceed and list down the existing resources. You can pick one by one and delete it from AWS console

Once you destroy everything, do not use redeploy command as it will work only on already installed PacBot stack. So try install command once you destroy everything

In the coming release, we will add the feature to ensure that the destruction occurs for all resources completely even if some errors occur in the middle of installation using AWS APIs directly along with terraform.

sajeer-nooh avatar Feb 20 '19 04:02 sajeer-nooh

Hi,

I was able to manually delete the resources from AWS and redeployed pacbot. please help.

I have checked everything is working but the deployment failed with error:

null_resource.pacbot_app_ecr_UIDockerImageBuild: unexpected EOF

  • aws_elasticsearch_domain.datastore_es_ESDomain: 1 error(s) occurred:

  • aws_elasticsearch_domain.datastore_es_ESDomain: unexpected EOF

  • null_resource.pacbot_app_build_ui_and_api_BuildUiAndApis: unexpected EOF

  • aws_db_instance.datastore_db_MySQLDatabase: 1 error(s) occurred:

But when I check in AWS, I can see the resources are provisioned : SQL db and elastic search domain

jayeshdub avatar Feb 20 '19 12:02 jayeshdub

Have you used python3 manager.py install command after deleting them manually? Also could you please share the log files in the log directory?

sajeer-nooh avatar Feb 20 '19 12:02 sajeer-nooh

Traceback (most recent call last): File "/root/pacbot/installer/core/kernel.py", line 117, in run self.execute(command_class_instance) File "/root/pacbot/installer/core/kernel.py", line 15, in execute self.execute_command(command_class_instance) File "/root/pacbot/installer/core/kernel.py", line 21, in execute_command command_class_instance.execute(self.provider) File "/root/pacbot/installer/core/commands/install.py", line 27, in execute self.dry_run File "/root/pacbot/installer/core/providers/aws/install.py", line 51, in execute raise self.exception File "/root/pacbot/installer/core/providers/aws/install.py", line 65, in execute_terraform self.terraform_apply(resources, terraform_with_targets, dry_run) File "/root/pacbot/installer/core/providers/aws/install.py", line 125, in terraform_apply py_terraform.terraform_apply(apply_resources) File "/root/pacbot/installer/core/terraform/init.py", line 72, in terraform_apply raise Exception(response[2]) Exception:

Error Message: Error: Error applying plan:

5 error(s) occurred:

  • null_resource.pacbot_app_ecr_UIDockerImageBuild: unexpected EOF

  • aws_elasticsearch_domain.datastore_es_ESDomain: 1 error(s) occurred:

  • aws_elasticsearch_domain.datastore_es_ESDomain: unexpected EOF

  • null_resource.pacbot_app_build_ui_and_api_BuildUiAndApis: unexpected EOF

  • aws_db_instance.datastore_db_MySQLDatabase: 1 error(s) occurred:

  • aws_db_instance.datastore_db_MySQLDatabase: unexpected EOF

  • aws_redshift_cluster.datastore_redshift_RedshiftCluster: 1 error(s) occurred:

  • aws_redshift_cluster.datastore_redshift_RedshiftCluster: unexpected EOF

Terraform does not automatically rollback in the face of errors. Instead, your Terraform state file has been partially updated with any resources that successfully completed. Please address the error above and apply again to incrementally change your infrastructure.


This is the error snippet. My vm that I am using to do it is a different one so cannot attach the log file.

Yes I am using python3.6. I executed the command python36 manager.py install

jayeshdub avatar Feb 20 '19 13:02 jayeshdub

This is first time I am seeing such error. Would it be possible to get the terraform_install.log from log directory?

sajeer-nooh avatar Feb 20 '19 13:02 sajeer-nooh

Or can you try to install from an EC2 instance(Amazon Linux, large instance)

sajeer-nooh avatar Feb 20 '19 13:02 sajeer-nooh

I am using RHEL ec2 instance. so yes amazon linux I am using .

aws_redshift_cluster.datastore_redshift_RedshiftCluster: Still creating... (3m10s elapsed) aws_elasticsearch_domain.datastore_es_ESDomain: Still creating... (3m10s elapsed) null_resource.pacbot_app_ecr_UIDockerImageBuild: Still creating... (40s elapsed) null_resource.pacbot_app_build_ui_and_api_BuildUiAndApis: Still creating... (40s elapsed) aws_db_instance.datastore_db_MySQLDatabase: Still creating... (3m20s elapsed) aws_redshift_cluster.datastore_redshift_RedshiftCluster: Still creating... (3m20s elapsed) aws_db_instance.datastore_db_MySQLDatabase: Still creating... (3m35s elapsed) null_resource.pacbot_app_ecr_UIDockerImageBuild: Still creating... (54s elapsed) aws_redshift_cluster.datastore_redshift_RedshiftCluster: Still creating... (3m39s elapsed) null_resource.pacbot_app_build_ui_and_api_BuildUiAndApis: Still creating... (52s elapsed) aws_elasticsearch_domain.datastore_es_ESDomain: Still creating... (3m20s elapsed) aws_redshift_cluster.datastore_redshift_RedshiftCluster: Still creating... (4m54s elapsed) aws_db_instance.datastore_db_MySQLDatabase: Still creating... (5m0s elapsed) aws_elasticsearch_domain.datastore_es_ESDomain: Still creating... (4m52s elapsed) null_resource.pacbot_app_ecr_UIDockerImageBuild: Still creating... (2m20s elapsed) null_resource.pacbot_app_build_ui_and_api_BuildUiAndApis: Still creating... (2m18s elapsed) null_resource.pacbot_app_ecr_UIDockerImageBuild: Still creating... (2m38s elapsed) aws_db_instance.datastore_db_MySQLDatabase: Still creating... (5m15s elapsed) aws_elasticsearch_domain.datastore_es_ESDomain: Still creating... (5m11s elapsed) null_resource.pacbot_app_build_ui_and_api_BuildUiAndApis: Still creating... (2m35s elapsed) aws_redshift_cluster.datastore_redshift_RedshiftCluster: Still creating... (5m12s elapsed) aws_elasticsearch_domain.datastore_es_ESDomain: Still creating... (5m25s elapsed) null_resource.pacbot_app_build_ui_and_api_BuildUiAndApis: Still creating... (2m50s elapsed) aws_redshift_cluster.datastore_redshift_RedshiftCluster: Still creating... (5m26s elapsed) null_resource.pacbot_app_ecr_UIDockerImageBuild: Still creating... (2m52s elapsed) null_resource.pacbot_app_ecr_UIDockerImageBuild: Still creating... (3m4If s elapsed) null_resource.pacbot_app_build_ui_and_api_BuildUiAndApis: Still creating... (3m1s elapsed) null_resource.pacbot_app_ecr_UIDockerImageBuild: Still creating... (3m15s elapsed) null_resource.pacbot_app_build_ui_and_api_BuildUiAndApis: Still creating... (3m13s elapsed) Releasing state lock. This may take a few moments... null_resource.pacbot_app_build_ui_and_api_BuildUiAndApis: Still creating... (3m25s elapsed) null_resource.pacbot_app_ecr_UIDockerImageBuild: Still creating... (3m27s elapsed)

Snipped from the install log. In this log, you can see that only 3 specific AWS resources are not getting created

jayeshdub avatar Feb 20 '19 13:02 jayeshdub

Normally RDS and ES takes around 10 mins sometimes more than 10 mins and from the error what I guess, AWS returns error Is there any API limit set for AWS?

Also could you please destroy and start fresh installation by cloning fresh code Also keep an eye on Memory and Disk usage

sajeer-nooh avatar Feb 20 '19 13:02 sajeer-nooh

I already did this one as a fresh start. I did not rebase my exisiting git project though. I cloned it yesterday so do I need to to do it again?

AWS API service limits should not be an issue I think. I just checked.

https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html#limits_apigateway

jayeshdub avatar Feb 20 '19 13:02 jayeshdub

If that doesn't work out, we can have a screenshare and debug it

sajeer-nooh avatar Feb 20 '19 13:02 sajeer-nooh

Delete the codebase and everything, clone new one and try it

sajeer-nooh avatar Feb 20 '19 13:02 sajeer-nooh

Also, if possible, get a new t2.large Amazon Linux machine with atleast 20GB and try from the directory /opt/

sajeer-nooh avatar Feb 20 '19 13:02 sajeer-nooh

just tried to reclone, but permission denied getting now.

jayeshdub avatar Feb 20 '19 13:02 jayeshdub

It is opensource, permission should not be an issue Git clone Https://GitHub.com/T-Mobile/pacbot

sajeer-nooh avatar Feb 20 '19 13:02 sajeer-nooh

still I am getting the same issue , I cloned the repo in /opt directory. can we screenshare tomorrow?

jayeshdub avatar Feb 20 '19 13:02 jayeshdub

yes, we can. Tell me the best time we can connect

sajeer-nooh avatar Feb 21 '19 06:02 sajeer-nooh

Please join, https://gitter.im/TMO-OSS/PacBot so that we can have discussion over there

sajeer-nooh avatar Feb 21 '19 06:02 sajeer-nooh

The issue was with AWS micro instance used as the installer but for PacBot to get installed the installer machine should atleast 4GB of ram or t2.medium server. This has been mentioned in the installation document. https://github.com/tmobile/pacbot/wiki/Install

Upgrading the server from t2.micro to t2.medium resolved the issue. We are closing this issue as it is resolved. Please feel free to get back to us if you have more queries.

sajeer-nooh avatar Feb 26 '19 05:02 sajeer-nooh