Skip to content

Commit

Permalink
fix: unlock mutex for experiment ResourcePool() [RM-152] (#9119)
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinaecalderon authored Apr 8, 2024
1 parent e70d38e commit 8a7832a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docs/release-notes/experiment-deadlock.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:orphan:

**Bug Fixes**

- API: Fix a bug where calling ``det job update`` could prevent jobs from being scheduled and ``det
job ls`` to hang.
1 change: 1 addition & 0 deletions master/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ linters-settings:
- 'bundebug.WithVerbose'
- 'http.Client' # Use cleanhttp instead.
- 'http.Transport' # Use cleanhttp instead.
- 'defer .*\.Lock\(\)'
staticcheck:
go: "1.20"

Expand Down
6 changes: 4 additions & 2 deletions master/internal/api_project_intg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ import (
"github.com/determined-ai/determined/proto/pkg/userv1"
)

const mockType = "mock"

var pAuthZ *mocks.ProjectAuthZ

func isMockAuthZ() bool {
return config.GetMasterConfig().Security.AuthZ.Type == "mock"
return config.GetMasterConfig().Security.AuthZ.Type == mockType
}

// pgdb can be nil to use the singleton database for testing.
Expand All @@ -45,7 +47,7 @@ func setupProjectAuthZTest(

if pAuthZ == nil {
pAuthZ = &mocks.ProjectAuthZ{}
project.AuthZProvider.Register("mock", pAuthZ)
project.AuthZProvider.Register(mockType, pAuthZ)
}
return api, pAuthZ, workspaceAuthZ, curUser, ctx
}
Expand Down
2 changes: 1 addition & 1 deletion master/internal/experiment_job_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (e *internalExperiment) SetResourcePool(resourcePool string) error {
// ResourcePool gets the experiment's resource pool.
func (e *internalExperiment) ResourcePool() string {
e.mu.Lock()
defer e.mu.Lock()
defer e.mu.Unlock()

return e.activeConfig.Resources().ResourcePool()
}
24 changes: 24 additions & 0 deletions master/internal/experiment_job_service_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package internal

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/determined-ai/determined/master/pkg/schemas/expconf"
)

func TestResourcePool(t *testing.T) {
rp := "mock"
//nolint:exhaustruct
e := &internalExperiment{
activeConfig: expconf.ExperimentConfigV0{
RawResources: &expconf.ResourcesConfigV0{
RawResourcePool: &rp,
},
},
}

rpName := e.ResourcePool()
require.Equal(t, rp, rpName)
}

0 comments on commit 8a7832a

Please sign in to comment.