Hadron / carthage

Carthage is an Infrastructure as Code (IAC) framework
Other
7 stars 4 forks source link

`!destroy --dry-run` raises at BareMetalMachine from find_deployables #76

Open srak289 opened 2 weeks ago

srak289 commented 2 weeks ago

Attempting to see what !destroy would do with --dry-run I was met with AttributeError: 'BareMetalMachine' object has no attribute 'readonly' which I did not expect.

Of course I was not intending to destroy the BareMetalMachine, but rather an AwsVm that is part of the same layout.

Full trace below:

>>> !destroy --dry-run
Executing <Task pending name='Async dependencies for <carthage_aws.connection.AwsConnection object at 0x7f1b34259250>' coro=<_handle_async_deps() running at /home/srak/projects/carthage/carthage/dependency_injection/base.py:1394> wait_for=<_GatheringFuture pending cb=[Task.task_wakeup()] created at /usr/lib/python3.11/asyncio/tasks.py:699> cb=[Task.task_wakeup()] created at /usr/lib/python3.11/asyncio/tasks.py:670> took 0.363 seconds
Task gen-key last run for <carthage.ssh.SshKey object at 0x7f1b34259a90> at 2024-06-14T07:09:57.577142; re-running not required
Traceback (most recent call last):
  File "/home/srak/projects/carthage/carthage/console.py", line 245, in runsource
    try: future.result()  #concurrent not asyncio future
         ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/concurrent/futures/_base.py", line 456, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/home/srak/projects/carthage/carthage/dependency_injection/base.py", line 1311, in __call__
    return await res
           ^^^^^^^^^
  File "/home/srak/projects/carthage/carthage/dependency_injection/base.py", line 758, in _handle_async
    res = await p
          ^^^^^^^
  File "/home/srak/projects/carthage/carthage/deployment_commands.py", line 43, in run
    deployables = await ainjector(find_deployables, readonly=self.force_readonly or args.dry_run,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/srak/projects/carthage/carthage/dependency_injection/base.py", line 758, in _handle_async
    res = await p
          ^^^^^^^
  File "/home/srak/projects/carthage/carthage/deployment.py", line 559, in find_deployables
    await do_recurse(stop_at=ainjector)
  File "/home/srak/projects/carthage/carthage/deployment.py", line 540, in do_recurse
    if readonly and not r.readonly:
                        ^^^^^^^^^^
AttributeError: 'BareMetalMachine' object has no attribute 'readonly'
hartmans commented 2 weeks ago

Yeah, looks like BareMetalMachine has not fully signed onto the Deployable interface. I guess BareMetalMachines are inherently readonly.