diff --git a/cmd/crio/main.go b/cmd/crio/main.go index 24569cef..959d756f 100644 --- a/cmd/crio/main.go +++ b/cmd/crio/main.go @@ -413,7 +413,7 @@ func main() { }() go func() { - err := service.StartInspectEndpoint() + err := service.StartInfoEndpoints() if err != nil { logrus.Fatalf("Failed to start container inspect endpoint: %v", err) } diff --git a/server/inspect.go b/server/inspect.go index 18537848..377d821c 100644 --- a/server/inspect.go +++ b/server/inspect.go @@ -17,11 +17,31 @@ type ContainerInfo struct { Annotations map[string]string `json:"annotations"` } -// StartInspectEndpoint starts a http server that -// serves container information requests -func (s *Server) StartInspectEndpoint() error { +// CrioInfo stores information about the crio daemon +type CrioInfo struct { + StorageDriver string `json:"storage_driver"` + StorageRoot string `json:"storage_root"` +} + +// StartInfoEndpoints starts a http server that +// serves container information requests and crio daemon information +func (s *Server) StartInfoEndpoints() error { mux := bone.New() + mux.Get("/info", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + ci := CrioInfo{ + StorageDriver: s.config.Config.Storage, + StorageRoot: s.config.Config.Root, + } + js, err := json.Marshal(ci) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + w.Header().Set("Content-Type", "application/json") + w.Write(js) + })) + mux.Get("/containers/:id", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { containerID := bone.GetValue(req, "id") ctr := s.GetContainer(containerID)