Skip to content

kaos doesn't rollback correctly from failed cloud deployments #80

@aalhour

Description

@aalhour

What is the current behaviour?

When a kaos build deploy command fails, it results in a .kaos/<CLOUD>/None file, which then would make kaos think that a backend was already build for that cloud. When the user tries to truly build the backend for that same cloud, the following gets reported back:

➜ kaos build deploy -c GCP -vy
Aborting - kaos backend is already built.

Even though the .kaos directory doesn't contain a valid backend and the list of backends reports only one:

➜ kaos build list
+-------+---------+----------+-------+
| index | context | provider |  env  |
+-------+---------+----------+-------+
|   0   |  DOCKER |  DOCKER  | local |
+-------+---------+----------+-------+

➜ tree .kaos
.kaos
├── config
└── state
    ├── AWS
    │   └── None
    ├── DOCKER
    │   ├── config.json
    │   └── terraform.tfstate
    └── GCP
        └── None

6 directories, 3 files

Trying to destroy the GCP backend would result in the following error (valid scenario):

➜ kaos destroy -c GCP -vy
Warning - kaos [prod] backend in GCP has not been deployed!

What is the expected behaviour?

When kaos fails to build a backend, the None file should be removed, the .kaos/<CLOUD> should be correctly removed.

How to reproduce? (e.g. logs, minimal example, etc...)

  • Move your GCP credentials file somewhere else or just empty the GOOGLE_APPLICATION_CREDENTIALS environment variable
  • Try to build kaos backend on GCP: kaos build deploy -c GCP -vy
  • Make sure that the failure led to the creation of .kaos/GCP/None file
  • Re-run GCP build command: kaos build deploy -c GCP -vy
  • Get the Aborting - kaos backend is already built. error back

Context (Environment)

  • kaos Cloud Provider: LOCAL, AWS and GCP
  • Operating System: mac OS

Additional Details

  • The kaos build deploy command could search for the terraform.tfstate inside the cloud directory rather than asserting that the directory exists

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions