From 66d1615d3ca233990b3719aea9559a658a9c96cc Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Mon, 19 Oct 2026 15:46:07 +0000 Subject: [PATCH] Stamp a first deployment's id inside createOrUpdateDeployment The deploy phase stamped the id of a newly created deployment into the plan right after calling createOrUpdateDeployment. Do it inside the helper, which is where the id is created, so the next caller (DMS bind) gets it too. No behavior change. Co-authored-by: Isaac --- bundle/phases/deploy.go | 7 ------- bundle/phases/dms.go | 8 +++++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/bundle/phases/deploy.go b/bundle/phases/deploy.go index 13c5121f569..8194afa535b 100644 --- a/bundle/phases/deploy.go +++ b/bundle/phases/deploy.go @@ -321,17 +321,10 @@ func Deploy(ctx context.Context, b *bundle.Bundle, outputHandler sync.OutputHand // A first deploy's id did not exist at plan time - the version and any existing id were stamped // then - so stamp the one just created into the plan the apply reads. if b.DeploymentBundle.StateDB.IsDeploymentMetadataService() { - firstDeploy := b.DeploymentBundle.StateDB.DeploymentID == "" createOrUpdateDeployment(ctx, b, dmsDeployment) if logdiag.HasError(ctx) { return } - if firstDeploy { - if err := b.DeploymentBundle.StampDeploymentIdForFirstVersion(b.DeploymentBundle.StateDB.DeploymentID); err != nil { - logdiag.LogError(ctx, err) - return - } - } // Only create a version when the plan has at least one operation to record, so it moves // with serial. Done after the prompt, so a declined deploy never claims a number. diff --git a/bundle/phases/dms.go b/bundle/phases/dms.go index abd89f03f2f..b351c04640d 100644 --- a/bundle/phases/dms.go +++ b/bundle/phases/dms.go @@ -79,7 +79,8 @@ func createOrUpdateDeployment(ctx context.Context, b *bundle.Bundle, current *bu return } deploymentID := db.StateDB.DeploymentID - if deploymentID == "" { + firstDeploy := deploymentID == "" + if firstDeploy { dep := metadata.Deployment() dep.InitialParentPath = b.Config.Workspace.StatePath created, err := w.BundleDeployments.CreateDeployment(ctx, bundledeployments.CreateDeploymentRequest{Deployment: dep}) @@ -110,6 +111,11 @@ func createOrUpdateDeployment(ctx context.Context, b *bundle.Bundle, current *bu bundle.ApplyFuncContext(ctx, b, func(_ context.Context, b *bundle.Bundle) { b.Config.Bundle.Deployment.DeploymentID = deploymentID }) + if firstDeploy { + if err := db.StampDeploymentIdForFirstVersion(deploymentID); err != nil { + logdiag.LogError(ctx, err) + } + } } // startVersion claims the version the run settled on and opens the buffer that records