Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/pkg/cli/client/byoc/aws/byoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ func (b *ByocAws) deploy(ctx context.Context, req *client.DeployRequest, cmd str
command: []string{cmd, payloadString},
delegateDomain: req.DelegateDomain,
delegationSetId: req.DelegationSetId,
etag: etag,
mode: req.Mode,
project: project.Name,
statesUrl: req.StatesUrl,
Expand Down Expand Up @@ -515,6 +516,7 @@ type cdCommand struct {
command []string
delegateDomain string
delegationSetId string
etag types.ETag
mode defangv1.DeploymentMode
project string

Expand All @@ -539,6 +541,10 @@ func (b *ByocAws) runCdCommand(ctx context.Context, cmd cdCommand) (ecs.TaskArn,
} else {
env["DOMAIN"] = "dummy.domain"
}
if cmd.etag != "" {
env["DEFANG_ETAG"] = cmd.etag
}

env["DEFANG_MODE"] = strings.ToLower(cmd.mode.String())
if cmd.dockerHubUsername != "" && cmd.dockerHubAccessToken != "" {
arn, err := b.putDockerHubSecret(ctx, cmd.project, cmd.dockerHubUsername, cmd.dockerHubAccessToken)
Expand Down Expand Up @@ -789,7 +795,7 @@ func (b *ByocAws) getLogGroupInputs(etag types.ETag, projectName, service, filte
} else {
cdTail := cw.LogGroupInput{LogGroupARN: b.driver.LogGroupARN, LogEventFilterPattern: pattern}
// If we know the CD task ARN, only tail the logstream for that CD task; FIXME: store the task ID in the project's ProjectUpdate in S3 and use that
if b.cdTaskArn != nil && b.cdEtag == etag {
if b.cdTaskArn != nil && (b.cdEtag == etag || ecs.GetTaskID(b.cdTaskArn) == etag) {
cdTail.LogStreamNames = []string{ecs.GetCDLogStreamForTaskID(ecs.GetTaskID(b.cdTaskArn))}
}
groups = append(groups, cdTail)
Expand Down Expand Up @@ -843,17 +849,18 @@ func (b *ByocAws) CdCommand(ctx context.Context, req client.CdCommandRequest) (s
if err := b.SetUpCD(ctx); err != nil {
return "", err
}
etag := types.NewEtag()
cmd := cdCommand{
project: req.Project,
command: []string{string(req.Command)},
etag: etag,
project: req.Project,
statesUrl: req.StatesUrl,
eventsUrl: req.EventsUrl,
}
cdTaskArn, err := b.runCdCommand(ctx, cmd) // TODO: make domain optional for defang cd
cdTaskArn, err := b.runCdCommand(ctx, cmd)
if err != nil {
return "", AnnotateAwsError(err)
}
etag := ecs.GetTaskID(cdTaskArn) // TODO: this is the CD task ID, not the etag
b.cdEtag = etag
b.cdStart = time.Now()
b.cdTaskArn = cdTaskArn
Expand Down
9 changes: 7 additions & 2 deletions src/pkg/cli/client/byoc/do/byoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func (b *ByocDo) deploy(ctx context.Context, req *client.DeployRequest, cmd stri
cdCmd := cdCommand{
command: []string{cmd, payloadString},
delegateDomain: req.DelegateDomain,
etag: etag,
mode: req.Mode,
project: project.Name,
statesUrl: req.StatesUrl,
Expand Down Expand Up @@ -230,9 +231,11 @@ func (b *ByocDo) CdCommand(ctx context.Context, req client.CdCommandRequest) (st
return "", err
}

etag := types.NewEtag()
cmd := cdCommand{
command: []string{string(req.Command)},
delegateDomain: "dummy.domain",
etag: etag,
project: req.Project,
statesUrl: req.StatesUrl,
eventsUrl: req.EventsUrl,
Expand All @@ -242,7 +245,6 @@ func (b *ByocDo) CdCommand(ctx context.Context, req client.CdCommandRequest) (st
return "", err
}

etag := types.NewEtag()
b.cdEtag = etag
return etag, nil
}
Expand Down Expand Up @@ -621,6 +623,7 @@ func (b *ByocDo) PrepareDomainDelegation(ctx context.Context, req client.Prepare

type cdCommand struct {
command []string
etag types.ETag
project string
delegateDomain string
mode defangv1.DeploymentMode
Expand All @@ -638,10 +641,12 @@ func (b *ByocDo) runCdCommand(ctx context.Context, cmd cdCommand) (*godo.App, er
if cmd.statesUrl != "" {
env = append(env, &godo.AppVariableDefinition{Key: "DEFANG_STATES_UPLOAD_URL", Value: cmd.statesUrl, Type: godo.AppVariableType_Secret})
}

if cmd.eventsUrl != "" {
env = append(env, &godo.AppVariableDefinition{Key: "DEFANG_EVENTS_UPLOAD_URL", Value: cmd.eventsUrl, Type: godo.AppVariableType_Secret})
}
if cmd.etag != "" {
env = append(env, &godo.AppVariableDefinition{Key: "DEFANG_ETAG", Value: cmd.etag})
}

if term.DoDebug() {
// Convert the environment to a human-readable array of KEY=VALUE strings for debugging
Expand Down