Skip to content

Commit

Permalink
update from code review and mapping of older subscribe response to ne…
Browse files Browse the repository at this point in the history
…w one.
  • Loading branch information
nullfunc committed Jul 5, 2024
1 parent 3d25299 commit 00d3a07
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 173 deletions.
3 changes: 2 additions & 1 deletion src/cmd/cli/command/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -848,11 +848,12 @@ var composeUpCmd = &cobra.Command{
if err := waitServiceState(ctx, defangv1.ServiceState_SERVICE_COMPLETED, serviceInfos); err != nil && !errors.Is(err, context.Canceled) {
if errors.Is(err, ErrDeploymentFailed) {
term.Warn("Deployment FAILED. Service(s) not running.")
cancelTail()
return err
} else {
term.Warnf("failed to wait for service status: %v", err)
}

wg.Wait() // Wait for tail ctrl + c
}
cancelTail()
wg.Wait() // Wait for tail to finish
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/cli/command/deploymentinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func printEndpoints(serviceInfos []*defangv1.ServiceInfo) {
}

serviceConditionText := "has status " + serviceInfo.Status
if serviceInfo.State != defangv1.ServiceState_SERVICE_STATE_UNSPECIFIED {
if serviceInfo.State != defangv1.ServiceState_NOT_SPECIFIED {
serviceConditionText = "is in state " + serviceInfo.State.String()
}

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/cli/command/servicemonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func waitServiceState(ctx context.Context, targetState defangv1.ServiceState, se

serviceState := make(map[string]defangv1.ServiceState, len(serviceList))
for _, name := range serviceList {
serviceState[name] = defangv1.ServiceState_SERVICE_STATE_UNSPECIFIED
serviceState[name] = defangv1.ServiceState_NOT_SPECIFIED
}

// monitor for when all services are completed to end this command
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/cli/client/byoc/aws/byoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ func (b *ByocAws) update(ctx context.Context, service *defangv1.Service) (*defan
si.State = defangv1.ServiceState_UPDATE_QUEUED
if si.Service.Build != nil {
si.Status = "BUILD_QUEUED" // in SaaS, this gets overwritten by the ECS events for "kaniko"
si.State = defangv1.ServiceState_BUILD_PENDING
si.State = defangv1.ServiceState_BUILD_QUEUED
}
return si, nil
}
Expand Down
13 changes: 13 additions & 0 deletions src/pkg/cli/compose/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,3 +321,16 @@ func convertPorts(ports []compose.ServicePortConfig) []*defangv1.Port {
}
return pbports
}

func ConvertServiceState(state string) defangv1.ServiceState {
switch strings.ToUpper(state) {
default:
return defangv1.ServiceState_NOT_SPECIFIED
case "IN_PROGRESS", "STARTING":
return defangv1.ServiceState_SERVICE_PENDING
case "COMPLETED":
return defangv1.ServiceState_SERVICE_COMPLETED
case "FAILED":
return defangv1.ServiceState_SERVICE_FAILED
}
}
3 changes: 2 additions & 1 deletion src/pkg/cli/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/DefangLabs/defang/src/pkg/cli/client"
"github.com/DefangLabs/defang/src/pkg/cli/compose"
"github.com/DefangLabs/defang/src/pkg/term"
defangv1 "github.com/DefangLabs/defang/src/protos/io/defang/v1"
)
Expand Down Expand Up @@ -64,7 +65,7 @@ func Subscribe(ctx context.Context, client client.Client, services []string) (<-
if subStatus.Name == "" && (servInfo != nil && servInfo.Service != nil) {
subStatus.Name = servInfo.Service.Name
subStatus.Status = servInfo.Status
subStatus.State = servInfo.State
subStatus.State = compose.ConvertServiceState(servInfo.Status)
}

statusChan <- subStatus
Expand Down
334 changes: 167 additions & 167 deletions src/protos/io/defang/v1/fabric.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/protos/io/defang/v1/fabric.proto
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ message UploadURLResponse { string url = 1; }


enum ServiceState {
SERVICE_STATE_UNSPECIFIED = 0;
NOT_SPECIFIED = 0;

// Build states (initial state for build)
BUILD_QUEUED = 1;
Expand Down

0 comments on commit 00d3a07

Please sign in to comment.