Skip to content

Commit e55a2d7

Browse files
nullfunclionello
andauthored
remove need to get execution name (#1005)
Co-authored-by: Lio李歐 <[email protected]>
1 parent 797ecad commit e55a2d7

File tree

2 files changed

+0
-57
lines changed

2 files changed

+0
-57
lines changed

src/pkg/cli/client/byoc/gcp/byoc.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -765,18 +765,6 @@ func (b *ByocGcp) query(ctx context.Context, query string) ([]*loggingpb.LogEntr
765765
}
766766

767767
func (b *ByocGcp) Query(ctx context.Context, req *defangv1.DebugRequest) error {
768-
// if there is no execution info then get from execution list
769-
if req.Etag != "" && b.cdExecution == "" {
770-
b.cdEtag = req.Etag
771-
772-
execution, err := b.driver.FindExecutionWithEtag(req.Etag)
773-
if err != nil {
774-
return fmt.Errorf("could not find job with etag %s: %v", req.Etag, annotateGcpError(err))
775-
}
776-
b.cdExecution = execution.Name
777-
req.Since = execution.CreateTime
778-
}
779-
780768
logEntries, err := b.query(ctx, b.createDeploymentLogQuery(req))
781769
if err != nil {
782770
return annotateGcpError(err)

src/pkg/clouds/gcp/cloudrun.go

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package gcp
22

33
import (
44
"context"
5-
"errors"
65
"fmt"
76
"math"
87
"os"
@@ -14,7 +13,6 @@ import (
1413
"cloud.google.com/go/run/apiv2/runpb"
1514
"github.com/DefangLabs/defang/src/pkg"
1615
"github.com/DefangLabs/defang/src/pkg/types"
17-
"google.golang.org/api/iterator"
1816
"google.golang.org/protobuf/types/known/durationpb"
1917
)
2018

@@ -97,49 +95,6 @@ func (gcp Gcp) SetupJob(ctx context.Context, jobId, serviceAccount string, conta
9795
}
9896
}
9997

100-
func (gcp Gcp) FindExecutionWithEtag(etag string) (*runpb.Execution, error) {
101-
ctx := context.Background()
102-
103-
// Create a Cloud Run Job Executions client
104-
client, err := run.NewExecutionsClient(ctx)
105-
if err != nil {
106-
return nil, fmt.Errorf("failed to create Cloud Run client: %v", err)
107-
}
108-
defer client.Close()
109-
110-
// List jobs in the region
111-
req := &runpb.ListExecutionsRequest{
112-
Parent: fmt.Sprintf("projects/%s/locations/%s/jobs/%s", gcp.ProjectId, gcp.Region, JobNameCD),
113-
}
114-
115-
//FIXME: This may need refactoring or architecture changes as we have to scour all
116-
// executions to find the matching etag. For any job there may be a large number of
117-
// executions to look through which may not scale well.
118-
119-
// Iterate through executions and filter by environment variable
120-
it := client.ListExecutions(ctx, req)
121-
var execution *runpb.Execution
122-
for {
123-
execution, err = it.Next()
124-
if err == iterator.Done {
125-
break
126-
}
127-
if err != nil {
128-
return nil, fmt.Errorf("error listing execution: %v", err)
129-
}
130-
131-
// Check if the execution has the target environment variable
132-
for _, container := range execution.Template.Containers {
133-
for _, entry := range container.Env {
134-
if entry.GetName() == "DEFANG_ETAG" && entry.GetValue() == etag {
135-
return execution, nil
136-
}
137-
}
138-
}
139-
}
140-
return nil, errors.New("no job found with matching etag")
141-
}
142-
14398
func (gcp Gcp) Run(ctx context.Context, jobId string, env map[string]string, cmd ...string) (string, error) {
14499
client, err := run.NewJobsClient(ctx)
145100
if err != nil {

0 commit comments

Comments
 (0)