Skip to content

Commit

Permalink
fix: prevent possible busy loop
Browse files Browse the repository at this point in the history
Failure to remove old deployments should not be a fatal error.

fixes: #2885
  • Loading branch information
stuartwdouglas committed Oct 1, 2024
1 parent 5bac043 commit c6450c1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion backend/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ func manageDeploymentDirectory(logger *log.Logger, config Config) error {

err := os.RemoveAll(old)
if err != nil {
return fmt.Errorf("failed to remove old deployment: %w", err)
// This is not a fatal error, just log it.
logger.Errorf(err, "Failed to remove old deployment: %w", deployment.Name())
}
}
}
Expand Down Expand Up @@ -212,8 +213,16 @@ func (s *Service) Call(ctx context.Context, req *connect.Request[ftlv1.CallReque
}
response, err := deployment.plugin.Client.Call(ctx, req)
if err != nil {
deploymentLogger := s.getDeploymentLogger(ctx, deployment.key)
deploymentLogger.Errorf(err, "Call to deployments %s failed to perform gRPC call", deployment.key)
return nil, connect.NewError(connect.CodeOf(err), err)
} else if response.Msg.GetError() != nil {
// This is a user level error (i.e. something wrong in the users app)
// Log it to the deployment logger
deploymentLogger := s.getDeploymentLogger(ctx, deployment.key)
deploymentLogger.Errorf(fmt.Errorf("%v", response.Msg.GetError().GetMessage()), "Call to deployments %s failed", deployment.key)
}

return connect.NewResponse(response.Msg), nil
}

Expand Down Expand Up @@ -413,6 +422,7 @@ func (s *Service) registrationLoop(ctx context.Context, send func(request *ftlv1

func (s *Service) streamLogsLoop(ctx context.Context, send func(request *ftlv1.StreamDeploymentLogsRequest) error) error {
delay := time.Millisecond * 500
logger := log.FromContext(ctx)

select {
case entry := <-s.deploymentLogQueue:
Expand All @@ -430,6 +440,9 @@ func (s *Service) streamLogsLoop(ctx context.Context, send func(request *ftlv1.S
if reqStr, ok := entry.Attributes["request"]; ok {
request = &reqStr
}
// We also just output the log normally, so it shows up in the pod logs and gets synced to DD etc.
// It's not clear if we should output this here on or on the controller side.
logger.Log(entry)

err := send(&ftlv1.StreamDeploymentLogsRequest{
RequestKey: request,
Expand Down

0 comments on commit c6450c1

Please sign in to comment.