Skip to content

Commit

Permalink
Return RuntimeConfig with Linux.CgroupDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
afbjorklund committed Jan 22, 2024
1 parent 25b124c commit 0956528
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
20 changes: 20 additions & 0 deletions core/docker_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,26 @@ func (ds *dockerService) Status(
return resp, nil
}

// RuntimeConfig returns the config of the runtime.
func (ds *dockerService) RuntimeConfig(
_ context.Context,
r *runtimeapi.RuntimeConfigRequest,
) (*runtimeapi.RuntimeConfigResponse, error) {
resp := &runtimeapi.RuntimeConfigResponse{}
if runtime.GOOS == "linux" {
resp.Linux = &runtimeapi.LinuxRuntimeConfiguration{}
switch ds.cgroupDriver {
case "cgroupfs":
resp.Linux.CgroupDriver = runtimeapi.CgroupDriver_CGROUPFS
case "systemd":
resp.Linux.CgroupDriver = runtimeapi.CgroupDriver_SYSTEMD
default:
return nil, fmt.Errorf("unknown cgroup driver: %s", ds.cgroupDriver)
}
}
return resp, nil
}

func (ds *dockerService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if ds.streamingServer != nil {
ds.streamingServer.ServeHTTP(w, r)
Expand Down
8 changes: 8 additions & 0 deletions core/docker_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ func TestStatus(t *testing.T) {
}, statusResp.Status)
}

// TestRuntimeConfig tests the runtime config logic.
func TestRuntimeConfig(t *testing.T) {
ds, fDocker, _ := newTestDockerService()

Check failure on line 168 in core/docker_service_test.go

View workflow job for this annotation

GitHub Actions / unit-test / unit-tests

fDocker declared and not used

configResp, err := ds.RuntimeConfig(getTestCTX(), &runtimeapi.RuntimeConfigRequest{})

Check failure on line 170 in core/docker_service_test.go

View workflow job for this annotation

GitHub Actions / unit-test / unit-tests

configResp declared and not used
require.NoError(t, err)
}

func TestVersion(t *testing.T) {
ds, _, _ := newTestDockerService()

Expand Down

0 comments on commit 0956528

Please sign in to comment.