Skip to content

Commit

Permalink
only acquire connection if connection is nil but cloud config is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
bashar-515 committed Feb 13, 2025
1 parent b9b69ef commit c6a7cb3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion robot/impl/local_robot.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ func newWithResources(
ctx context.Context,
cfg *config.Config,
resources map[resource.Name]resource.Resource,
conn rpc.ClientConn,
logger logging.Logger,
opts ...Option,
) (robot.LocalRobot, error) {
Expand Down Expand Up @@ -434,6 +435,10 @@ func newWithResources(
r.packageManager = packages.NewDeferredPackageManager(
ctx,
func(ctx context.Context) (packagespb.PackageServiceClient, error) {
if conn != nil {
return packagespb.NewPackageServiceClient(conn), err
}

_, cloudConn, err := r.cloudConnSvc.AcquireConnection(ctx)
return packagespb.NewPackageServiceClient(cloudConn), err
},
Expand Down Expand Up @@ -548,10 +553,11 @@ func newWithResources(
func New(
ctx context.Context,
cfg *config.Config,
conn rpc.ClientConn,
logger logging.Logger,
opts ...Option,
) (robot.LocalRobot, error) {
return newWithResources(ctx, cfg, nil, logger, opts...)
return newWithResources(ctx, cfg, nil, conn, logger, opts...)
}

// removeOrphanedResources is called by the module manager to remove resources
Expand Down
2 changes: 1 addition & 1 deletion web/server/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ func (s *robotServer) serveWeb(ctx context.Context, cfg *config.Config) (err err
// state of initializing until reconfigured with full config.
minimalProcessedConfig.Initial = true

myRobot, err := robotimpl.New(ctx, &minimalProcessedConfig, s.logger, robotOptions...)
myRobot, err := robotimpl.New(ctx, &minimalProcessedConfig, s.appConn, s.logger, robotOptions...)
if err != nil {
cancel()
return err
Expand Down

0 comments on commit c6a7cb3

Please sign in to comment.