From 7c64ab9cc6041a47cc5f91a074b7077c4257bb92 Mon Sep 17 00:00:00 2001 From: LordMathis Date: Tue, 21 Oct 2025 18:49:49 +0200 Subject: [PATCH] Make StartInstance and StopInstance idempotent --- pkg/manager/operations.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/manager/operations.go b/pkg/manager/operations.go index 4b2e719..09fe06b 100644 --- a/pkg/manager/operations.go +++ b/pkg/manager/operations.go @@ -383,8 +383,9 @@ func (im *instanceManager) StartInstance(name string) (*instance.Instance, error lock.Lock() defer lock.Unlock() + // Idempotent: if already running, just return success if inst.IsRunning() { - return inst, fmt.Errorf("instance with name %s is already running", name) + return inst, nil } // Check max running instances limit for local instances only @@ -446,8 +447,9 @@ func (im *instanceManager) StopInstance(name string) (*instance.Instance, error) lock.Lock() defer lock.Unlock() + // Idempotent: if already stopped, just return success if !inst.IsRunning() { - return inst, fmt.Errorf("instance with name %s is already stopped", name) + return inst, nil } if err := inst.Stop(); err != nil {