mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
feat(apiserver): set stream param in LogLocation
Signed-off-by: Jian Zeng <anonymousknight96@gmail.com>
This commit is contained in:
parent
b9228836e1
commit
d9687a8c3a
@ -21,6 +21,8 @@ import (
|
||||
"fmt"
|
||||
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
@ -86,7 +88,10 @@ func (r *LogREST) Get(ctx context.Context, name string, opts runtime.Object) (ru
|
||||
|
||||
countSkipTLSMetric(logOpts.InsecureSkipTLSVerifyBackend)
|
||||
|
||||
if errs := validation.ValidatePodLogOptions(logOpts); len(errs) > 0 {
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.PodLogsQuerySplitStreams) {
|
||||
logOpts.Stream = nil
|
||||
}
|
||||
if errs := validation.ValidatePodLogOptions(logOpts, utilfeature.DefaultFeatureGate.Enabled(features.PodLogsQuerySplitStreams)); len(errs) > 0 {
|
||||
return nil, errors.NewInvalid(api.Kind("PodLogOptions"), name, errs)
|
||||
}
|
||||
location, transport, err := pod.LogLocation(ctx, r.Store, r.KubeletConn, name, logOpts)
|
||||
|
@ -26,6 +26,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
netutils "k8s.io/utils/net"
|
||||
"sigs.k8s.io/structured-merge-diff/v4/fieldpath"
|
||||
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
@ -50,8 +53,6 @@ import (
|
||||
corevalidation "k8s.io/kubernetes/pkg/apis/core/validation"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/pkg/kubelet/client"
|
||||
netutils "k8s.io/utils/net"
|
||||
"sigs.k8s.io/structured-merge-diff/v4/fieldpath"
|
||||
)
|
||||
|
||||
// podStrategy implements behavior for Pods
|
||||
@ -563,6 +564,10 @@ func LogLocation(
|
||||
if opts.LimitBytes != nil {
|
||||
params.Add("limitBytes", strconv.FormatInt(*opts.LimitBytes, 10))
|
||||
}
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.PodLogsQuerySplitStreams) {
|
||||
// With defaulters, We can be confident that opts.Stream is not nil here.
|
||||
params.Add("stream", string(*opts.Stream))
|
||||
}
|
||||
loc := &url.URL{
|
||||
Scheme: nodeInfo.Scheme,
|
||||
Host: net.JoinHostPort(nodeInfo.Hostname, nodeInfo.Port),
|
||||
|
@ -1216,6 +1216,8 @@ func typeToJSON(typeName string) string {
|
||||
return "string"
|
||||
case "v1.IncludeObjectPolicy", "*v1.IncludeObjectPolicy":
|
||||
return "string"
|
||||
case "*string":
|
||||
return "string"
|
||||
|
||||
// TODO: Fix these when go-restful supports a way to specify an array query param:
|
||||
// https://github.com/emicklei/go-restful/issues/225
|
||||
|
Loading…
Reference in New Issue
Block a user