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

Can't successfully destroy provisioned VM based on contrainfra/linchpin #1744

Open
chuanchang opened this issue Jun 18, 2020 · 4 comments
Open

Comments

@chuanchang
Copy link

chuanchang commented Jun 18, 2020

Describe the bug
Failed to destroy provisioned VM based on contrainfra/linchpin (linchpin 2.0.0).

BTW, could users destroy provisioned VM instance w/ Target_uHash? and cloud users can list all of existing provisioned VM instance?

$ podman run --rm -v /home/ajia/workspace/linchpin:/workdir:rw -v /sys/fs/cgroup:/sys/fs/cgroup:ro -e CREDS_PATH=/workdir/credentials --name linchpin docker.io/contrainfra/linchpin -- linchpin --no-monitor -p PinFile/PinFile.rhel8.2 -vw /workdir destroy rhel-8.2
Traceback (most recent call last):
  File "/usr/local/bin/linchpin", line 10, in <module>
    sys.exit(runcli())
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/linchpin/shell/__init__.py", line 400, in destroy
    env_vars=env_vars)
  File "/usr/local/lib/python3.7/site-packages/linchpin/cli/__init__.py", line 498, in lp_destroy
    tx_id=tx_id)
  File "/usr/local/lib/python3.7/site-packages/linchpin/cli/__init__.py", line 565, in _execute_action
    run_id=run_id)
  File "/usr/local/lib/python3.7/site-packages/linchpin/cli/__init__.py", line 742, in _execute
    tx_id=tx_id)
  File "/usr/local/lib/python3.7/site-packages/linchpin/__init__.py", line 529, in do_action
    rundb_id = self.prepare_rundb(target, action, run_id, tx_id)
  File "/usr/local/lib/python3.7/site-packages/linchpin/__init__.py", line 695, in prepare_rundb
    run_id=run_id)
  File "/usr/local/lib/python3.7/site-packages/linchpin/rundb/basedb.py", line 41, in get_record
    return self.driver.get_record(table, action=action, run_id=run_id)
  File "/usr/local/lib/python3.7/site-packages/linchpin/rundb/__init__.py", line 10, in func_wrapper
    x = func(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/linchpin/rundb/tinydb.py", line 120, in get_record
    run_id = self.get_run_id(table, action)
  File "/usr/local/lib/python3.7/site-packages/linchpin/rundb/__init__.py", line 10, in func_wrapper
    x = func(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/linchpin/rundb/tinydb.py", line 105, in get_run_id
    record = t.get(eid=int(rid))
TypeError: get() got an unexpected keyword argument 'eid'

To Reproduce
Steps to reproduce the behavior:

  1. please see 'Describe the bug' section.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: RHEL-8.2
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
And rebuilt contrainfra/linchpin w/ linchpin 2.0.2, it's still failure.

---------------------8<--------------------

TASK [openstack : Get topology output data from RunDB] *************************
ok: [localhost] => {"changed": false, "output": "[]"}

TASK [openstack : debug: set topo_output_resources fact rundb] *****************
ok: [localhost] => {"ansible_facts": {"topo_output_json": []}, "changed": false}

TASK [openstack : set topo_output_resources fact rundb] ************************
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: list object has no element 0\n\nThe error appears to be in '/usr/local/lib/python3.7/site-packages/linchpin/provision/roles/openstack/tasks/teardown_resource_group.yml': line 76, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"set topo_output_resources fact rundb\"\n  ^ here\n"}

PLAY RECAP *********************************************************************
localhost                  : ok=11   changed=1    unreachable=0    failed=1    skipped=7    rescued=0    ignored=0


ID: 1
Action: destroy

Target                  Run ID  uHash   Exit Code
-------------------------------------------------
rhel-8.2                     1                  2

In non-container environment, although I got a successfully output from cmdline, but in fact, this VM instance doesn't exist.

---------------------8<--------------------
PLAY RECAP ******************************************************************************************************************************************************************************************
localhost                  : ok=25   changed=4    unreachable=0    failed=0    skipped=41   rescued=0    ignored=0

Action 'destroy' on Target 'rhel-8.2' is complete

ID: 8
Action: destroy

Target                  Run ID  uHash   Exit Code
-------------------------------------------------
rhel-8.2                    10  51afdf          0
@Dannyb48
Copy link
Collaborator

From what I can gather, the RunDB that Linchpin uses to store the resource state info was empty for that target:

TASK [openstack : Get topology output data from RunDB] *************************
ok: [localhost] => {"changed": false, "output": "[]"}

Not sure if that is left over from the prior failed deletion attempt.

Can you try reproduce this again now that you upgraded the contra container to linchpin 2.0.2?

  • provsion your VM
  • destroy your VM

@chuanchang
Copy link
Author

chuanchang commented Jun 19, 2020

Can you try reproduce this again now that you upgraded the contra container to linchpin 2.0.2?

* provsion your VM

* destroy your VM

As you seen, I have done this, please see previous comments, please let me know if you need extra information.

BTW, I had ever removed manually several provisioned VM instances from Openstack webUI, I guess it may be reason, it will be better if there is a command like linchpin list --provisioned/fresh to get latest provisioned VM instances information.

@Dannyb48
Copy link
Collaborator

I reproduced it in a non-container environment.

TASK [openstack : debug: set topo_output_resources fact rundb] ****************************************************************************************************************************************************
task path: /home/dbaez/.virtualenvs/cbn_linchpin_plugin/lib/python2.7/site-packages/linchpin/provision/roles/openstack/tasks/teardown_resource_group.yml:71
ok: [localhost] => {
    "ansible_facts": {
        "topo_output_json": []
    }, 
    "changed": false
}

TASK [openstack : set topo_output_resources fact rundb] ***********************************************************************************************************************************************************
task path: /home/dbaez/.virtualenvs/cbn_linchpin_plugin/lib/python2.7/site-packages/linchpin/provision/roles/openstack/tasks/teardown_resource_group.yml:76
fatal: [localhost]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The error was: list object has no element 0\n\nThe error appears to be in '/home/dbaez/.virtualenvs/cbn_linchpin_plugin/lib/python2.7/site-packages/linchpin/provision/roles/openstack/tasks/teardown_resource_group.yml': line 76, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"set topo_output_resources fact rundb\"\n  ^ here\n"
}

Without provisioning anything I just ran:

linchpin --no-monitor -vvvv destroy

``

As I suspect nothing is there in the database related to that target for it retrieve hence it fails.

It's a valid feature suggestion linchpin list --provisioned/fresh but unfortunately Linchpin is in maintenance mode right now. So we are only really providing support and fixes to already existing functionality.

@Dannyb48
Copy link
Collaborator

Dannyb48 commented Jul 3, 2020

@chuanchang Any chance we can close this out?

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

2 participants