mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +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"
|
"fmt"
|
||||||
|
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
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/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"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)
|
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)
|
return nil, errors.NewInvalid(api.Kind("PodLogOptions"), name, errs)
|
||||||
}
|
}
|
||||||
location, transport, err := pod.LogLocation(ctx, r.Store, r.KubeletConn, name, logOpts)
|
location, transport, err := pod.LogLocation(ctx, r.Store, r.KubeletConn, name, logOpts)
|
||||||
|
@ -26,6 +26,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
netutils "k8s.io/utils/net"
|
||||||
|
"sigs.k8s.io/structured-merge-diff/v4/fieldpath"
|
||||||
|
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
@ -50,8 +53,6 @@ import (
|
|||||||
corevalidation "k8s.io/kubernetes/pkg/apis/core/validation"
|
corevalidation "k8s.io/kubernetes/pkg/apis/core/validation"
|
||||||
"k8s.io/kubernetes/pkg/features"
|
"k8s.io/kubernetes/pkg/features"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/client"
|
"k8s.io/kubernetes/pkg/kubelet/client"
|
||||||
netutils "k8s.io/utils/net"
|
|
||||||
"sigs.k8s.io/structured-merge-diff/v4/fieldpath"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// podStrategy implements behavior for Pods
|
// podStrategy implements behavior for Pods
|
||||||
@ -563,6 +564,10 @@ func LogLocation(
|
|||||||
if opts.LimitBytes != nil {
|
if opts.LimitBytes != nil {
|
||||||
params.Add("limitBytes", strconv.FormatInt(*opts.LimitBytes, 10))
|
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{
|
loc := &url.URL{
|
||||||
Scheme: nodeInfo.Scheme,
|
Scheme: nodeInfo.Scheme,
|
||||||
Host: net.JoinHostPort(nodeInfo.Hostname, nodeInfo.Port),
|
Host: net.JoinHostPort(nodeInfo.Hostname, nodeInfo.Port),
|
||||||
|
@ -1216,6 +1216,8 @@ func typeToJSON(typeName string) string {
|
|||||||
return "string"
|
return "string"
|
||||||
case "v1.IncludeObjectPolicy", "*v1.IncludeObjectPolicy":
|
case "v1.IncludeObjectPolicy", "*v1.IncludeObjectPolicy":
|
||||||
return "string"
|
return "string"
|
||||||
|
case "*string":
|
||||||
|
return "string"
|
||||||
|
|
||||||
// TODO: Fix these when go-restful supports a way to specify an array query param:
|
// TODO: Fix these when go-restful supports a way to specify an array query param:
|
||||||
// https://github.com/emicklei/go-restful/issues/225
|
// https://github.com/emicklei/go-restful/issues/225
|
||||||
|
Loading…
Reference in New Issue
Block a user