Skip to content

Commit 5584b55

Browse files
committed
internal/gomote: remove default create timeout
This change removes the default timeout set for gomote instance creation. It also cleans up some gomote instance destruction logic. Updates golang/go#48742 Change-Id: I888142facae23fbb12352c45e3740826b921f61a Reviewed-on: https://go-review.googlesource.com/c/build/+/374114 Trust: Carlos Amedee <[email protected]> Run-TryBot: Carlos Amedee <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Alex Rakoczy <[email protected]>
1 parent 686a728 commit 5584b55

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

internal/gomote/gomote.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ func (s *Server) Authenticate(ctx context.Context, req *protos.AuthenticateReque
6262

6363
// CreateInstance will create a gomote instance for the authenticated user.
6464
func (s *Server) CreateInstance(req *protos.CreateInstanceRequest, stream protos.GomoteService_CreateInstanceServer) error {
65-
ctx, cancel := context.WithTimeout(stream.Context(), 5*time.Minute)
66-
defer cancel()
67-
68-
creds, err := access.IAPFromContext(ctx)
65+
creds, err := access.IAPFromContext(stream.Context())
6966
if err != nil {
7067
log.Printf("CreateInstance access.IAPFromContext(ctx) = nil, %s", err)
7168
return status.Errorf(codes.Unauthenticated, "request does not contain the required authentication")
@@ -90,14 +87,14 @@ func (s *Server) CreateInstance(req *protos.CreateInstanceRequest, stream protos
9087
}
9188
rc := make(chan result, 1)
9289
go func() {
93-
bc, err := s.scheduler.GetBuildlet(ctx, si)
90+
bc, err := s.scheduler.GetBuildlet(stream.Context(), si)
9491
rc <- result{bc, err}
9592
}()
9693
ticker := time.NewTicker(5 * time.Second)
9794
defer ticker.Stop()
9895
for {
9996
select {
100-
case <-ctx.Done():
97+
case <-stream.Context().Done():
10198
return status.Errorf(codes.DeadlineExceeded, "timed out waiting for gomote instance to be created")
10299
case <-ticker.C:
103100
st := s.scheduler.WaiterState(si)
@@ -149,21 +146,19 @@ func (s *Server) ListInstances(ctx context.Context, req *protos.ListInstancesReq
149146
log.Printf("ListInstances access.IAPFromContext(ctx) = nil, %s", err)
150147
return nil, status.Errorf(codes.Unauthenticated, "request does not contain the required authentication")
151148
}
152-
var instances []*protos.Instance
149+
res := &protos.ListInstancesResponse{}
153150
for _, s := range s.buildlets.List() {
154151
if s.OwnerID != creds.ID {
155152
continue
156153
}
157-
instances = append(instances, &protos.Instance{
154+
res.Instances = append(res.Instances, &protos.Instance{
158155
GomoteId: s.ID,
159156
BuilderType: s.BuilderType,
160157
HostType: s.HostType,
161158
Expires: s.Expires.Unix(),
162159
})
163160
}
164-
return &protos.ListInstancesResponse{
165-
Instances: instances,
166-
}, nil
161+
return res, nil
167162
}
168163

169164
// DestroyInstance will destroy a gomote instance. It will ensure that the caller is authenticated and is the owner of the instance

0 commit comments

Comments
 (0)