Skip to content

[Bug] teardown-fabric in fabricx_dev.mk is not idempotent — fails when fabric_test network is already absent #10

@Prachi194agrawal

Description

@Prachi194agrawal

Bug Report

Description

In samples/tokens/fabricx_dev.mk (line 50), the teardown-fabric target runs:

@$(CONTAINER_CLI) network inspect fabric_test >/dev/null 2>&1 && $(CONTAINER_CLI) network rm fabric_test
Because this uses &&, when fabric_test does not exist:

network inspect exits non-zero

network rm is skipped entirely

The Make recipe line exits non-zero, causing make teardown to fail

This makes teardown-fabric non-idempotent: it fails even when the environment is already clean — which is the exact scenario where teardown should always succeed.

Steps to Reproduce
cd samples/tokens

# 1. Ensure the network does not exist
docker network rm fabric_test 2>/dev/null || true

# 2. Run teardown with xdev platform
export PLATFORM=xdev
make teardown

# 3. Observe non-zero exit even though nothing is left to remove
echo "Exit code: $?"
Expected Behavior
make teardown should succeed (exit 0) regardless of whether fabric_test exists.
Idempotent cleanup is a fundamental requirement for reliable CI and local dev loops.

Actual Behavior
make teardown exits non-zero when fabric_test is already absent, even though the system is in the desired clean state.
make: *** [teardown-fabric] Error 1
make: *** [teardown] Error 2
Suggested Fix
Replace the inspect && rm chain in fabricx_dev.mk with an unconditional remove and a warning fallback:
# Before (non-idempotent)
@$(CONTAINER_CLI) network inspect fabric_test >/dev/null 2>&1 && $(CONTAINER_CLI) network rm fabric_test

# After (idempotent)
@$(CONTAINER_CLI) network rm fabric_test 2>/dev/null || echo "Warning: Docker network 'fabric_test' not found or already removed."
This always exits 0 whether or not the network existed — consistent with how stop-fabric handles missing containers via docker compose down.

Environment
File: samples/tokens/fabricx_dev.mk, line 50

Platform: PLATFORM=xdev

Container CLI: docker (default) or podman

Impact
Medium — CI pipelines and developer machines running repeated make setup / make teardown cycles will hit intermittent failures even when the environment is already fully clean. Particularly disruptive in automated test flows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions