Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Skip destroy if no resource is actually created #346

Open
chivalryq opened this issue Sep 19, 2022 · 2 comments
Open

[Feature request] Skip destroy if no resource is actually created #346

chivalryq opened this issue Sep 19, 2022 · 2 comments

Comments

@chivalryq
Copy link
Member

chivalryq commented Sep 19, 2022

Feature Request

Now we will dispatch destroy job if Configuration is deleted. However, sometimes no resources is created due to the wrong Configuration. In this case, we should detect the resource creation phase and skip the destroy phase depends on the situation.

1. What kubevela/kubevela#3929 do

In deletion part, kubevela#3929 will set configuration.spec.forceDelete to true. Anything else is dealt with terraform-controller.

Origin Post

Hey, I know this is merged, but I realized when you have something wrong the deletion don't complete. For example, Imagine you go to the Cloud provider portal and delete the resource, terraform will fail to delete saying the resource doesn't exist, like this:

Error: Error: Subnet: (Name "subnet-1" / Virtual Network Name "vnet-1" / Resource Group "example1") was not found

The same happen if I accidentally make a mistake in a HCL and apply some components in an application, but try to delete after realize I did a mistake, the delete never happen.

I just did it on my test environment and can't delete the application even using force.

image

I receive a:

Deleting Application "vm-1"
force deleted the resources created by application
successfully cleanup the resources created by application, but fail to delete the application
Error: timed out waiting for the condition

Originally posted by @alisson276 in kubevela/kubevela#3929 (comment)

@chivalryq
Copy link
Member Author

chivalryq commented Sep 19, 2022

Try two wrong applications below. vela delete -f works fine. No destroy Job will be created.

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: wrong-rds-db
spec:
  components:
    - name: wrong-rds-db
      type: alibaba-rds-database
      properties:
        region: cn-hangzhou
        existing_instance_id: FAKE_ID
        database_name: first_database
        password: U34rfwefwefffaked
        account_name: first_db_account

Also see https://github.com/kubevela/terraform-controller/blob/master/controllers/configuration_controller.go#L365-L376

When forceDelete is set. No destroy Job is expected to be created.

@chivalryq
Copy link
Member Author

chivalryq commented Feb 10, 2023

After v0.7.10, Configuration can be deleted before it is fully created. PR #354 has supportted DeleteProvisioningResources feature gate.
This makes vela delete can works properly with wrong terraform Configuration.

DeleteProvisioningResources solves the second problem mentioned. The first case should be re-evaluate since the deleting resource in vendor portal is not a predictable action even with terraform itself. This kind of case should requires ops to get involved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant