Skip to content

Commit

Permalink
command/agent/csi_endpoint: AllocID was missing, JobDescription
Browse files Browse the repository at this point in the history
  • Loading branch information
langmartin committed Aug 21, 2020
1 parent 6266f48 commit 933524f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions command/agent/csi_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,8 @@ func structsCSIPluginToApi(plug *structs.CSIPlugin) *api.CSIPlugin {
func structsJobDescriptionToApi(desc structs.JobDescription) api.JobDescription {
return api.JobDescription{
Namespace: desc.Namespace,
JobID: desc.JobID,
ID: desc.ID,
Version: desc.Version,
Expected: desc.Expected,
}
}

Expand Down Expand Up @@ -378,6 +377,7 @@ func structsCSIInfoToApi(info *structs.CSIInfo) *api.CSIInfo {
}
out := &api.CSIInfo{
PluginID: info.PluginID,
AllocID: info.AllocID,
Healthy: info.Healthy,
HealthDescription: info.HealthDescription,
UpdateTime: info.UpdateTime,
Expand Down
11 changes: 4 additions & 7 deletions command/agent/csi_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/state"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/kr/pretty"
"github.com/stretchr/testify/require"
)

Expand All @@ -33,11 +32,13 @@ func TestHTTP_CSIEndpointPlugin(t *testing.T) {
out, ok := obj.(*api.CSIPlugin)
require.True(t, ok)

require.Equal(t, 1, out.ControllersExpected)
// ControllersExpected is 0 because this plugin was created without a job,
// which sets expected
require.Equal(t, 0, out.ControllersExpected)
require.Equal(t, 1, out.ControllersHealthy)
require.Len(t, out.Controllers, 1)

require.Equal(t, 2, out.NodesExpected)
require.Equal(t, 0, out.NodesExpected)
require.Equal(t, 2, out.NodesHealthy)
require.Len(t, out.Nodes, 2)
})
Expand Down Expand Up @@ -92,11 +93,7 @@ func TestHTTP_CSIEndpointVolume(t *testing.T) {
out, ok := raw.(*api.CSIVolume)
require.True(t, ok)

pretty.Log(out)

require.Equal(t, 1, out.ControllersExpected)
require.Equal(t, 1, out.ControllersHealthy)
require.Equal(t, 2, out.NodesExpected)
require.Equal(t, 2, out.NodesHealthy)
})
}
Expand Down

0 comments on commit 933524f

Please sign in to comment.