Skip to content

Commit 8290d64

Browse files
authored
fix(applier): ensure proper deletion logic for components with updated manifest handling (#575)
1 parent bcdc73b commit 8290d64

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

internal/mcpserver/agent/tool/updateanalysis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (in *UpdateAnalysis) fromRequest(request mcp.CallToolRequest) (result clien
6969
result.Bullets = lo.ToSlicePtr(bullets)
7070
}
7171

72-
return
72+
return result, nil
7373
}
7474

7575
func NewUpdateAnalysis(client console.Client, agentRunID string) Tool {

pkg/streamline/applier/applier.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import (
55
"time"
66

77
"github.com/pluralsh/console/go/client"
8-
discoverycache "github.com/pluralsh/deployment-operator/pkg/cache/discovery"
9-
"github.com/pluralsh/deployment-operator/pkg/common"
108
"github.com/pluralsh/polly/algorithms"
119
"github.com/pluralsh/polly/containers"
1210
"github.com/samber/lo"
@@ -16,6 +14,9 @@ import (
1614
"k8s.io/client-go/dynamic"
1715
"k8s.io/klog/v2"
1816

17+
discoverycache "github.com/pluralsh/deployment-operator/pkg/cache/discovery"
18+
"github.com/pluralsh/deployment-operator/pkg/common"
19+
1920
"github.com/pluralsh/deployment-operator/internal/helpers"
2021
"github.com/pluralsh/deployment-operator/pkg/log"
2122
smcommon "github.com/pluralsh/deployment-operator/pkg/streamline/common"
@@ -280,6 +281,11 @@ func (in *Applier) getDeleteFilterFunc(serviceID string) (func(resources []unstr
280281
return nil, err
281282
}
282283

284+
componentsSet := containers.NewSet[smcommon.Key]()
285+
for _, component := range components {
286+
componentsSet.Add(component.StoreKey().VersionlessKey())
287+
}
288+
283289
hooks, err := in.store.GetHookComponents(serviceID)
284290
if err != nil {
285291
return nil, err
@@ -328,8 +334,8 @@ func (in *Applier) getDeleteFilterFunc(serviceID string) (func(resources []unstr
328334
if ok && hook.HasDesiredState(deletePolicies) && !hook.HasManifestChanged(resource) {
329335
skipApply.Add(key)
330336

331-
if r, exists := keyToResource[key]; exists {
332-
toDelete = append(toDelete, r)
337+
if componentsSet.Has(key) {
338+
toDelete = append(toDelete, resource)
333339
}
334340

335341
continue

0 commit comments

Comments
 (0)