Skip to content

Extra calls to check_completed_func after SetupTask is run #118

@srak289

Description

@srak289

It appears the check_completed_func is called again after carthage has just run a setup task. This seems wrong.

Output detailing multiple calls to check_completed_func from running layout:

PYTHONPATH=/home/srak/project/locallayout/carthage: /home/srak/project/locallayout/carthage/bin/carthage-runner --no-pull-plugins --no-tmux . --command-verbose --tasks-verbose --generate
Carthage console.  Type Python expressions or use !help for Carthage commands.
>>> !deploy localhost -y
<Command '/usr/bin/ls /tmp/foo', pid 1035400>: process started
Task Touch a file source modified at 2025-07-11T04:57:32.178738 more recently than last run of 1969-12-31T19:00:00.
Running cust task for <LocalMachine name:localhost ip_address:127.0.0.1>
<Command '/usr/bin/ls /tmp/foo', pid 1035405>: process started
Task Touch a file source modified at 2025-07-11T04:57:32.178738 more recently than last run of 1969-12-31T19:00:00.
Running Touch a file task for <cust description:"cust" for localhost>
<Command '/usr/bin/touch /tmp/foo', pid 1035410>: process started
Finished running Touch a file task for <cust description:"cust" for localhost> from 05:00:44.766125 to 05:00:44.771827 (0:00:00.005702)
Finished running cust task for <LocalMachine name:localhost ip_address:127.0.0.1> from 05:00:44.753085 to 05:00:44.774049 (0:00:00.020964)
<Command '/usr/bin/ls /tmp/foo', pid 1035415>: process started
Task Touch a file for <cust description:"cust" for localhost> determined complete by check_completed_func(); no timestamp provided
Running cust task for <LocalMachine name:localhost ip_address:127.0.0.1>
<Command '/usr/bin/ls /tmp/foo', pid 1035420>: process started
Task Touch a file for <cust description:"cust" for localhost> determined complete by check_completed_func(); no timestamp provided
Finished running cust task for <LocalMachine name:localhost ip_address:127.0.0.1> from 05:00:44.785275 to 05:00:44.795789 (0:00:00.010514)

# Deployment Report 

Ran deploy on the following objects successfully:

* <LocalMachine name:localhost ip_address:127.0.0.1>

Successful deploy successes:1
>>> 

MVE layout to reproduce:

import sh

from carthage import *
from carthage.modeling import *
from carthage.network import V4Config
from carthage.local import LocalMachine

class layout(CarthageLayout):
    layout_name = "testlayout"

    add_provider(machine_implementation_key, dependency_quote(LocalMachine))

    class localhost(MachineModel):
        name = "localhost"

        class cust(MachineCustomization):
            @setup_task("Touch a file")
            async def touch_file(self):
                await self.run_command("touch", "/tmp/foo")
            @touch_file.check_completed()
            async def touch_file(self):
                try:
                    await self.run_command("ls", "/tmp/foo")
                    return True
                except sh.ErrorReturnCode_2:
                    return False

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions