Skip to content

Commit

Permalink
Add basic crictl info config with sandboxImage
Browse files Browse the repository at this point in the history
  • Loading branch information
afbjorklund committed Apr 17, 2023
1 parent b71578f commit a5f4306
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
20 changes: 19 additions & 1 deletion core/docker_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package core

import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -395,7 +396,24 @@ func (ds *dockerService) Status(
networkReady.Message = fmt.Sprintf("docker: network plugin is not ready: %v", err)
}
status := &runtimeapi.RuntimeStatus{Conditions: conditions}
return &runtimeapi.StatusResponse{Status: status}, nil
resp := &runtimeapi.StatusResponse{Status: status}
if r.Verbose {
image := defaultSandboxImage
podSandboxImage := ds.podSandboxImage
if len(podSandboxImage) != 0 {
image = podSandboxImage
}
config := map[string]interface{}{
"sandboxImage": image,
}
configByt, err := json.Marshal(config)
if err != nil {
return nil, err
}
resp.Info = make(map[string]string)
resp.Info["config"] = string(configByt)
}
return resp, nil
}

func (ds *dockerService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Expand Down
5 changes: 5 additions & 0 deletions core/docker_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ func TestStatus(t *testing.T) {
runtimeapi.NetworkReady: true,
}, statusResp.Status)

// Should report info if verbose.
statusResp, err = ds.Status(getTestCTX(), &runtimeapi.StatusRequest{Verbose: true})
require.NoError(t, err)
assert.NotNil(t, statusResp.Info)

// Should not report ready status is network plugin returns error.
mockPlugin := newTestNetworkPlugin(t)
ds.network = network.NewPluginManager(mockPlugin)
Expand Down

0 comments on commit a5f4306

Please sign in to comment.