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

clab destroy fails when clab folder isn't present #2514

Open
marion-qacafe opened this issue Mar 13, 2025 · 3 comments
Open

clab destroy fails when clab folder isn't present #2514

marion-qacafe opened this issue Mar 13, 2025 · 3 comments

Comments

@marion-qacafe
Copy link

When the folder created by clab for a topology (clab-) is no longer there, clab destroy fails. I have worked around this by creating an empty folder with the expected name. Then, clab destroy succeeds. Since the folder I create is empty, does it really need to exist for clab destroy to work?

I am using containerlab in a CI/CD gitlab runner, which is why directories get destroyed before the clab is destroyed.

Directory not present:

Cleaning up JobID 9310129195
Destroying Clab
11:47:25 INFO Parsing & checking topology file=prplos.clab.yml
11:47:25 INFO Parsing & checking topology file=prplos.clab.yml
Error: folder /root/gitlab-runner/builds/t3_oo6825/1/qacafe/cdrouter/nightly-tests/prplos/clab-9310129195 does not exist or is not accessible

Empty directory created:

mkdir /root/gitlab-runner/builds/t3_oo6825/1/qacafe/cdrouter/nightly-tests/prplos/clab-9310129195
Cleaning up JobID 9310129195
Destroying Clab
11:47:37 INFO Parsing & checking topology file=prplos.clab.yml
11:47:37 INFO Parsing & checking topology file=prplos.clab.yml
11:47:37 INFO Destroying lab name=9310129195
11:47:37 INFO Removed container name=clab-9310129195-cdrouter.py
11:47:39 INFO Removed container name=clab-9310129195-cdrouter
11:47:39 INFO Removing host entries path=/etc/hosts
11:47:39 INFO Removing SSH config path=/etc/ssh/ssh_config.d/clab-9310129195.conf
@SanderDelden
Copy link

Perhaps this can be resolved by retrieving the clab- folder from the previous stage by leveraging the dependencies functionality in Gitlab: https://docs.gitlab.com/ci/yaml/#dependencies

Quick example:

deploy-containerlab:
  stage: deploy
  script: containerlab deploy
  artifacts:
    paths:
      - clab-<lab_name>/

destroy-containerlab:
  stage: destroy
  script: containerlab destroy
  dependencies:
    - deploy-containerlab

@marion-qacafe
Copy link
Author

Perhaps this can be resolved by retrieving the clab- folder from the previous stage by leveraging the dependencies functionality in Gitlab: https://docs.gitlab.com/ci/yaml/#dependencies

Quick example:

deploy-containerlab:
stage: deploy
script: containerlab deploy
artifacts:
paths:
- clab-<lab_name>/

destroy-containerlab:
stage: destroy
script: containerlab destroy
dependencies:
- deploy-containerlab

Thanks for the suggestion. Currently, gitlab isn't handling the cleanup of the clab instances, but I may be able to use this workaround in the future.

@hellt
Copy link
Member

hellt commented Mar 13, 2025

Yes, I think we should solve it gracefully. There are no hard dependencies on the contents of the lab dir that as far as I remember

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

3 participants