Skip to content

Commit d9687a8

Browse files
committed
feat(apiserver): set stream param in LogLocation
Signed-off-by: Jian Zeng <[email protected]>
1 parent b922883 commit d9687a8

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

pkg/registry/core/pod/rest/log.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121
"fmt"
2222

2323
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
24+
utilfeature "k8s.io/apiserver/pkg/util/feature"
25+
"k8s.io/kubernetes/pkg/features"
2426

2527
"k8s.io/apimachinery/pkg/api/errors"
2628
"k8s.io/apimachinery/pkg/runtime"
@@ -86,7 +88,10 @@ func (r *LogREST) Get(ctx context.Context, name string, opts runtime.Object) (ru
8688

8789
countSkipTLSMetric(logOpts.InsecureSkipTLSVerifyBackend)
8890

89-
if errs := validation.ValidatePodLogOptions(logOpts); len(errs) > 0 {
91+
if !utilfeature.DefaultFeatureGate.Enabled(features.PodLogsQuerySplitStreams) {
92+
logOpts.Stream = nil
93+
}
94+
if errs := validation.ValidatePodLogOptions(logOpts, utilfeature.DefaultFeatureGate.Enabled(features.PodLogsQuerySplitStreams)); len(errs) > 0 {
9095
return nil, errors.NewInvalid(api.Kind("PodLogOptions"), name, errs)
9196
}
9297
location, transport, err := pod.LogLocation(ctx, r.Store, r.KubeletConn, name, logOpts)

pkg/registry/core/pod/strategy.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ import (
2626
"strings"
2727
"time"
2828

29+
netutils "k8s.io/utils/net"
30+
"sigs.k8s.io/structured-merge-diff/v4/fieldpath"
31+
2932
apiv1 "k8s.io/api/core/v1"
3033
apiequality "k8s.io/apimachinery/pkg/api/equality"
3134
"k8s.io/apimachinery/pkg/api/errors"
@@ -50,8 +53,6 @@ import (
5053
corevalidation "k8s.io/kubernetes/pkg/apis/core/validation"
5154
"k8s.io/kubernetes/pkg/features"
5255
"k8s.io/kubernetes/pkg/kubelet/client"
53-
netutils "k8s.io/utils/net"
54-
"sigs.k8s.io/structured-merge-diff/v4/fieldpath"
5556
)
5657

5758
// podStrategy implements behavior for Pods
@@ -563,6 +564,10 @@ func LogLocation(
563564
if opts.LimitBytes != nil {
564565
params.Add("limitBytes", strconv.FormatInt(*opts.LimitBytes, 10))
565566
}
567+
if utilfeature.DefaultFeatureGate.Enabled(features.PodLogsQuerySplitStreams) {
568+
// With defaulters, We can be confident that opts.Stream is not nil here.
569+
params.Add("stream", string(*opts.Stream))
570+
}
566571
loc := &url.URL{
567572
Scheme: nodeInfo.Scheme,
568573
Host: net.JoinHostPort(nodeInfo.Hostname, nodeInfo.Port),

staging/src/k8s.io/apiserver/pkg/endpoints/installer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,8 @@ func typeToJSON(typeName string) string {
12161216
return "string"
12171217
case "v1.IncludeObjectPolicy", "*v1.IncludeObjectPolicy":
12181218
return "string"
1219+
case "*string":
1220+
return "string"
12191221

12201222
// TODO: Fix these when go-restful supports a way to specify an array query param:
12211223
// https://github.com/emicklei/go-restful/issues/225

0 commit comments

Comments
 (0)