Skip to content

Commit

Permalink
Revert scheduler updates
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeckman314 committed Oct 30, 2023
1 parent 8c4f6e7 commit c76cf4d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions compute/scheduler/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewNodeProcess(ctx context.Context, conf config.Config, factory Worker, log
conf: conf,
client: cli,
log: log,
resources: res,
resources: &res,
workerRun: factory,
workers: newRunSet(),
timeout: timeout,
Expand Down Expand Up @@ -154,7 +154,7 @@ func (n *NodeProcess) sync(ctx context.Context) {

// Node data has been updated. Send back to server for database update.
var derr error
n.resources, derr = detectResources(n.conf.Node, n.conf.Worker.WorkDir)
*n.resources, derr = detectResources(n.conf.Node, n.conf.Worker.WorkDir)
if derr != nil {
n.log.Error("error detecting resources", "error", derr)
}
Expand Down
11 changes: 4 additions & 7 deletions compute/scheduler/testutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func newTestNode(conf config.Config, t *testing.T) testNode {
conf: conf,
client: s,
log: log,
resources: res,
resources: &res,
workerRun: NoopWorker,
workers: newRunSet(),
timeout: util.NewIdleTimeout(time.Duration(conf.Node.Timeout)),
Expand Down Expand Up @@ -81,17 +81,14 @@ func (t *testNode) AddTasks(ids ...string) {

func timeLimit(t *testing.T, d time.Duration) func() {
stop := make(chan struct{})
done := make(chan struct{})
go func() {
select {
case <-time.NewTimer(d).C:
t.Error("time limit expired")
close(stop)
case <-done:
t.Fatal("time limit expired")
case <-stop:
}
}()
return func() {
close(done)
<-stop
close(stop)
}
}
4 changes: 2 additions & 2 deletions compute/scheduler/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func GenNodeID() string {
//
// Upon error, detectResources will return the resources given by the config
// with the error.
func detectResources(conf config.Node, workdir string) (*Resources, error) {
res := &Resources{
func detectResources(conf config.Node, workdir string) (Resources, error) {
res := Resources{
Cpus: conf.Resources.Cpus,
RamGb: conf.Resources.RamGb,
DiskGb: conf.Resources.DiskGb,
Expand Down

0 comments on commit c76cf4d

Please sign in to comment.