Skip to content

Commit

Permalink
Make platform details optional (#285)
Browse files Browse the repository at this point in the history
* Make platform details optional

* Put the validate check in a better place

---------

Co-authored-by: Alexander Garbett <[email protected]>
  • Loading branch information
Garbett1 and Alexander Garbett authored Mar 6, 2024
1 parent cf810d0 commit 7764055
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mettle/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ func serve(opts grpcutil.Opts, name string, queueOpts PubSubOpts, apiURL string,
client: client,
numPollers: queueOpts.NumPollers,
deleteJobsTicker: time.NewTicker(10 * time.Minute),
actuallyValidate: len(allowedPlatform) > 0,
}

// _Technically_ this won't happen more than once in normal running, as we'd only run 1 server, but it does happen in tests.
Expand Down Expand Up @@ -213,6 +214,7 @@ type server struct {
mutex sync.Mutex
numPollers int
deleteJobsTicker *time.Ticker
actuallyValidate bool
}

// ServeExecutions serves a list of currently executing jobs over GRPC.
Expand Down Expand Up @@ -602,6 +604,9 @@ func shouldDeleteJob(j *job) bool {

// validatePlatform fetches the platform requirements for this request and checks them.
func (s *server) validatePlatform(req *pb.ExecuteRequest) (map[string]string, error) {
if !s.actuallyValidate {
return map[string]string{}, nil
}
action := &pb.Action{}
if _, err := s.client.ReadProto(context.Background(), digest.NewFromProtoUnvalidated(req.ActionDigest), action); err != nil {
return nil, err
Expand Down

0 comments on commit 7764055

Please sign in to comment.