mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-02 03:37:46 +08:00
add option 'follow'
This commit is contained in:
parent
91328771d6
commit
0a529f8d06
@ -23,6 +23,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-chi/chi"
|
||||
"github.com/goodrain/rainbond/api/handler"
|
||||
@ -778,8 +779,9 @@ func (t *TenantStruct) Log(w http.ResponseWriter, r *http.Request) {
|
||||
component := r.Context().Value(ctxutil.ContextKey("service")).(*dbmodel.TenantServices)
|
||||
podName := r.URL.Query().Get("podName")
|
||||
containerName := r.URL.Query().Get("containerName")
|
||||
follow, _ := strconv.ParseBool(r.URL.Query().Get("follow"))
|
||||
|
||||
err := handler.GetServiceManager().Log(w, r, component, podName, containerName)
|
||||
err := handler.GetServiceManager().Log(w, r, component, podName, containerName, follow)
|
||||
if err != nil {
|
||||
httputil.ReturnBcodeError(r, w, err)
|
||||
return
|
||||
|
@ -2910,7 +2910,7 @@ func (s *ServiceAction) SyncComponentEndpoints(tx *gorm.DB, components []*api_mo
|
||||
}
|
||||
|
||||
// Log returns the logs reader for a container in a pod, a pod or a component.
|
||||
func (s *ServiceAction) Log(w http.ResponseWriter, r *http.Request, component *dbmodel.TenantServices, podName, containerName string) error {
|
||||
func (s *ServiceAction) Log(w http.ResponseWriter, r *http.Request, component *dbmodel.TenantServices, podName, containerName string, follow bool) error {
|
||||
// If podName and containerName is missing, return the logs reader for the component
|
||||
// If containerName is missing, return the logs reader for the pod.
|
||||
if podName == "" || containerName == "" {
|
||||
@ -2920,7 +2920,7 @@ func (s *ServiceAction) Log(w http.ResponseWriter, r *http.Request, component *d
|
||||
|
||||
request := s.kubeClient.CoreV1().Pods(component.TenantID).GetLogs(podName, &corev1.PodLogOptions{
|
||||
Container: containerName,
|
||||
Follow: true,
|
||||
Follow: follow,
|
||||
})
|
||||
|
||||
out, err := request.Stream(context.TODO())
|
||||
|
@ -104,5 +104,5 @@ type ServiceHandler interface {
|
||||
SyncComponentScaleRules(tx *gorm.DB, components []*api_model.Component) error
|
||||
SyncComponentEndpoints(tx *gorm.DB, components []*api_model.Component) error
|
||||
|
||||
Log(w http.ResponseWriter, r *http.Request, component *dbmodel.TenantServices, podName, containerName string) error
|
||||
Log(w http.ResponseWriter, r *http.Request, component *dbmodel.TenantServices, podName, containerName string, follow bool) error
|
||||
}
|
||||
|
@ -12,7 +12,5 @@ var (
|
||||
ErrSyncOperation = newByMessage(409, 10103, "The asynchronous operation is executing")
|
||||
// ErrHorizontalDueToNoChange
|
||||
ErrHorizontalDueToNoChange = newByMessage(400, 10104, "The number of components has not changed, no need to scale")
|
||||
ErrReadComponentLogs = newByMessage(400, 10105, "Failed to read the component log from reader")
|
||||
ErrWriteComponentLogs = newByMessage(400, 10106, "Failed to write the component log to the streaming response")
|
||||
ErrPodNotFound = newByMessage(404, 10107, "pod not found")
|
||||
ErrPodNotFound = newByMessage(404, 10105, "pod not found")
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user