Skip to content

Conversation

@andrasbacsai
Copy link
Member

Changes

  • Cancel in-progress or queued deployment activities when stopping a service
  • Prevents status from remaining stuck at "starting" after containers are stopped
  • Follows existing pattern used in forceDeploy() method

How to Test

  1. Start a service
  2. Refresh while it's deploying (status shows "starting")
  3. Click stop
  4. Verify status changes to "exited" instead of staying at "starting"

When stopping a service that's currently deploying, mark any IN_PROGRESS or QUEUED activities as CANCELLED. This prevents the status from remaining stuck at "starting" after containers are stopped.

Follows the existing pattern used in forceDeploy().
Copilot AI review requested due to automatic review settings December 4, 2025 07:23
@andrasbacsai andrasbacsai merged commit 4638417 into next Dec 4, 2025
8 checks passed
@andrasbacsai andrasbacsai deleted the fix-service-status-stuck-starting branch December 4, 2025 07:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where a service's status remains stuck at "starting" after stopping the service. The fix cancels any in-progress or queued deployment activities when StopService is invoked, following a similar pattern to the existing forceDeploy() method.

Key Changes:

  • Added logic to cancel in-progress/queued activities before stopping service containers
  • Imported ProcessStatus enum and Activity model to support activity cancellation
  • Activities with IN_PROGRESS or QUEUED status are updated to CANCELLED status

->orWhere('properties->status', ProcessStatus::QUEUED->value);
})
->each(function ($activity) {
$activity->properties = $activity->properties->put('status', ProcessStatus::CANCELLED->value);
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property modification approach is inconsistent with the existing pattern in forceDeploy(). In app/Livewire/Project/Service/Heading.php:115, the code directly assigns to the property:

$activity->properties->status = ProcessStatus::ERROR->value;

This code uses:

$activity->properties = $activity->properties->put('status', ProcessStatus::CANCELLED->value);

Consider using direct assignment for consistency:

$activity->properties->status = ProcessStatus::CANCELLED->value;
Suggested change
$activity->properties = $activity->properties->put('status', ProcessStatus::CANCELLED->value);
$activity->properties->status = ProcessStatus::CANCELLED->value;

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +31
Activity::where('properties->type_uuid', $service->uuid)
->where(function ($q) {
$q->where('properties->status', ProcessStatus::IN_PROGRESS->value)
->orWhere('properties->status', ProcessStatus::QUEUED->value);
})
->each(function ($activity) {
$activity->properties = $activity->properties->put('status', ProcessStatus::CANCELLED->value);
$activity->save();
});
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] For consistency with the existing forceDeploy() pattern (lines 109-117 in app/Livewire/Project/Service/Heading.php), consider using .get() with a foreach loop instead of .each():

$activities = Activity::where('properties->type_uuid', $service->uuid)
    ->where(function ($q) {
        $q->where('properties->status', ProcessStatus::IN_PROGRESS->value)
            ->orWhere('properties->status', ProcessStatus::QUEUED->value);
    })->get();
foreach ($activities as $activity) {
    $activity->properties->status = ProcessStatus::CANCELLED->value;
    $activity->save();
}

This matches the established pattern in the codebase for similar operations.

Suggested change
Activity::where('properties->type_uuid', $service->uuid)
->where(function ($q) {
$q->where('properties->status', ProcessStatus::IN_PROGRESS->value)
->orWhere('properties->status', ProcessStatus::QUEUED->value);
})
->each(function ($activity) {
$activity->properties = $activity->properties->put('status', ProcessStatus::CANCELLED->value);
$activity->save();
});
$activities = Activity::where('properties->type_uuid', $service->uuid)
->where(function ($q) {
$q->where('properties->status', ProcessStatus::IN_PROGRESS->value)
->orWhere('properties->status', ProcessStatus::QUEUED->value);
})
->get();
foreach ($activities as $activity) {
$activity->properties = $activity->properties->put('status', ProcessStatus::CANCELLED->value);
$activity->save();
}

Copilot uses AI. Check for mistakes.
@andrasbacsai andrasbacsai mentioned this pull request Dec 7, 2025
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

Successfully merging this pull request may close these issues.

1 participant