From 3c0d5fcfd39b31acd18ad76f114894d6d89adfec Mon Sep 17 00:00:00 2001 From: mitchell Date: Thu, 7 Nov 2024 16:08:41 -0500 Subject: [PATCH] `state commit` should not poll for build result. --- internal/runners/commit/commit.go | 2 +- pkg/platform/model/buildplanner/build.go | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/runners/commit/commit.go b/internal/runners/commit/commit.go index 1ac478ce50..4b7b208ccc 100644 --- a/internal/runners/commit/commit.go +++ b/internal/runners/commit/commit.go @@ -160,7 +160,7 @@ func (c *Commit) Run() (rerr error) { } // Get old buildplan. - oldCommit, err := bp.FetchCommit(localCommitID, proj.Owner(), proj.Name(), nil) + oldCommit, err := bp.FetchCommitNoPoll(localCommitID, proj.Owner(), proj.Name(), nil) if err != nil { return errs.Wrap(err, "Failed to fetch old commit") } diff --git a/pkg/platform/model/buildplanner/build.go b/pkg/platform/model/buildplanner/build.go index feef9b1a28..867e056396 100644 --- a/pkg/platform/model/buildplanner/build.go +++ b/pkg/platform/model/buildplanner/build.go @@ -57,6 +57,14 @@ func (c *client) Run(req gqlclient.Request, resp interface{}) error { const fetchCommitCacheExpiry = time.Hour * 12 func (b *BuildPlanner) FetchCommit(commitID strfmt.UUID, owner, project string, target *string) (*Commit, error) { + return b.fetchCommit(commitID, owner, project, target, true) +} + +func (b *BuildPlanner) FetchCommitNoPoll(commitID strfmt.UUID, owner, project string, target *string) (*Commit, error) { + return b.fetchCommit(commitID, owner, project, target, false) +} + +func (b *BuildPlanner) fetchCommit(commitID strfmt.UUID, owner, project string, target *string, poll bool) (*Commit, error) { logging.Debug("FetchCommit, commitID: %s, owner: %s, project: %s", commitID, owner, project) resp := &response.ProjectCommitResponse{} @@ -92,7 +100,7 @@ func (b *BuildPlanner) FetchCommit(commitID strfmt.UUID, owner, project string, // The BuildPlanner will return a build plan with a status of // "planning" if the build plan is not ready yet. We need to // poll the BuildPlanner until the build is ready. - if resp.Project.Commit.Build.Status == raw.Planning { + if poll && resp.Project.Commit.Build.Status == raw.Planning { resp.Project.Commit.Build, err = b.pollBuildPlanned(commitID.String(), owner, project, target) if err != nil { return nil, errs.Wrap(err, "failed to poll build plan")