Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion go/internal/controller/reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ func (a *kagentReconciler) ReconcileKagentAgent(ctx context.Context, req ctrl.Re
}

func (a *kagentReconciler) handleAgentDeletion(req ctrl.Request) error {
if err := a.dbClient.DeleteAgent(req.String()); err != nil {
id := utils.ConvertToPythonIdentifier(req.String())
if err := a.dbClient.DeleteAgent(id); err != nil {
return fmt.Errorf("failed to delete agent %s: %w",
req.String(), err)
}
Expand Down
16 changes: 16 additions & 0 deletions go/internal/controller/reconciler/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package reconciler
import (
"testing"

"github.com/kagent-dev/kagent/go/internal/utils"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)

// TestComputeStatusSecretHash_Output verifies the output of the hash function
Expand Down Expand Up @@ -191,3 +193,17 @@ func TestComputeStatusSecretHash_Deterministic(t *testing.T) {
})
}
}

func TestAgentIDConsistency(t *testing.T) {
req := reconcile.Request{
NamespacedName: types.NamespacedName{
Namespace: "test-namespace",
Name: "my-agent",
},
}

storeID := utils.ConvertToPythonIdentifier(utils.ResourceRefString(req.Namespace, req.Name))
deleteID := utils.ConvertToPythonIdentifier(req.String())

assert.Equal(t, storeID, deleteID)
}
Loading