Skip to content

internal: Fix failed deployment cleanup#346

Merged
timflannagan merged 1 commit intoagentregistry-dev:mainfrom
timflannagan:fix/deploy-failed-state
Mar 13, 2026
Merged

internal: Fix failed deployment cleanup#346
timflannagan merged 1 commit intoagentregistry-dev:mainfrom
timflannagan:fix/deploy-failed-state

Conversation

@timflannagan
Copy link
Copy Markdown
Collaborator

Description

We stop treating failed or cancelled deployment rows as active deployments and allow those rows to be removed without invoking platform undeploy.

Previously, list and metadata surfaces counted any matching deployment row, including failed and cancelled records. Deleting a failed deployment also still tried to undeploy platform resources first, which could fail even when nothing had been created.

Now, only deployed rows contribute to deployment status displays, and failed or cancelled records are removed directly from the database during delete.

Fixes #326.

Change Type

/kind fix

Changelog

NONE

Additional Notes

We stop treating failed or cancelled deployment rows as active deployments and allow
those rows to be removed without invoking platform undeploy.

Previously, list and metadata surfaces counted any matching deployment row,
including failed and cancelled records. Deleting a failed deployment also still
tried to undeploy platform resources first, which could fail even when nothing
had been created.

Now, only deployed rows contribute to deployment status displays, and failed
or cancelled records are removed directly from the database during delete.

Fixes agentregistry-dev#326.

Signed-off-by: timflannagan <[email protected]>
if deployment == nil || deployment.ResourceType != resourceType {
continue
}
if deployment.Status != models.DeploymentStatusDeployed {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

TODO: confirm whether we care about the legacy (afaik) "active" column. There was internal/registry/database/migrations/004_unified_deployments_provider.sql and I thought we ripped this out in Scott's refactor a couple of weeks back.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

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 aims to improve handling of non-successful deployments by standardizing deployment status values and ensuring “deployment presence” surfaces only reflect successfully deployed rows.

Changes:

  • Introduces shared models.DeploymentStatus* constants and replaces several hardcoded status strings with these constants.
  • Updates catalog metadata bridging and CLI deployment counting to only include deployed status rows.
  • Updates/adds tests to reflect the new “only deployed counts” behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/models/deployment.go Adds canonical deployment status constants (deploying, deployed, failed, cancelled, discovered).
internal/registry/service/registry_service.go Switches service-side default status strings to use the new constants.
internal/registry/platforms/local/deployment_adapter_local.go Uses the deployed status constant in adapter deploy result.
internal/registry/platforms/kubernetes/deployment_adapter_kubernetes.go Uses the deployed status constant in adapter deploy result.
internal/registry/platforms/kubernetes/deployment_adapter_kubernetes_platform.go Uses the deployed status constant for discovered deployment rows.
internal/registry/api/handlers/v0/deployment_meta_bridge.go Filters deployment metadata indexing to only include deployed rows.
internal/registry/api/handlers/v0/deployment_meta_bridge_test.go Updates tests to expect only deployed rows in the deployment index.
internal/cli/common/deployments.go Updates deployment counting logic to ignore non-deployed statuses.
internal/cli/mcp/list_test.go Updates MCP CLI tests to include status and validate deployed-only counting.
internal/cli/agent/list_test.go Updates agent CLI tests to include status and validate deployed-only counting.
internal/registry/service/registry_service_test.go Adds a test around undeploy behavior for failed/cancelled deployments (currently contradicts PR intent).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@timflannagan timflannagan added this pull request to the merge queue Mar 13, 2026
Merged via the queue into agentregistry-dev:main with commit a0439a2 Mar 13, 2026
11 checks passed
@timflannagan timflannagan deleted the fix/deploy-failed-state branch March 13, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed deployment records cannot be deleted

3 participants