Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic crictl info config with sandboxImage #180

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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