Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPBUGS-48552: Update to Kubernetes 1.31.5 #2176

Merged
merged 23 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
04f5b20
kubelet: Fix the volume manager did't check the device mount state in…
carlory Oct 21, 2024
fd78b52
Update CHANGELOG/CHANGELOG-1.31.md for v1.31.4
k8s-release-robot Dec 10, 2024
b8265e7
prevent unnecessary resolving of iscsi/fc devices to dm
RomanBednar Oct 15, 2024
b555e6b
Fix volume expansion offline
gnufied Dec 4, 2024
1f83017
fetch cni plugins from GitHub releases
upodroid Dec 5, 2024
b82572f
Do not attempt to truncate revision history if revisionHistoryLimit i…
ardaguclu Dec 19, 2024
dad2757
Merge pull request #129235 from gnufied/automated-cherry-pick-of-#129…
k8s-ci-robot Dec 20, 2024
eb8c239
Bump images, dependencies and versions to go 1.22.10 and distroless i…
cpanato Dec 30, 2024
ec0d04b
Merge pull request #129424 from cpanato/update-go1234-rel131
k8s-ci-robot Dec 30, 2024
ec1a397
kubeadm: fix a bug where the node.skipPhases in UpgradeNodeConfigurat…
SataQiu Jan 2, 2025
5ac4d36
Merge pull request #129285 from ameukam/automated-cherry-pick-of-#129…
k8s-ci-robot Jan 6, 2025
774adff
webhook: alter regex to account for x509sha1 GODEBUG removal
MadhavJivrajani Dec 30, 2024
7164c72
Merge pull request #129062 from carlory/automated-cherry-pick-of-#128…
k8s-ci-robot Jan 7, 2025
c831762
Merge pull request #129181 from RomanBednar/automated-cherry-pick-of-…
k8s-ci-robot Jan 8, 2025
b26ab8b
Merge pull request #129454 from neolit123/automated-cherry-pick-of-#1…
k8s-ci-robot Jan 8, 2025
6f456a1
Merge pull request #129323 from ardaguclu/automated-cherry-pick-of-#1…
k8s-ci-robot Jan 9, 2025
1043bf3
Merge pull request #129494 from MadhavJivrajani/131-go124-webhook-reg…
k8s-ci-robot Jan 9, 2025
c94919d
kubelet: use env vars in node log query PS command
aravindhp Aug 6, 2024
75c83a6
Merge pull request #129599 from aravindhp/automated-cherry-pick-of-#1…
k8s-ci-robot Jan 14, 2025
af64d83
Release commit for Kubernetes v1.31.5
k8s-release-robot Jan 15, 2025
6b42606
Merge tag 'v1.31.5' into bump-1.31.5
atiratree Jan 17, 2025
79b096c
UPSTREAM: <drop>: manually resolve conflicts
atiratree Jan 20, 2025
d2d1c41
UPSTREAM: <drop>: hack/update-vendor.sh, make update and update image
atiratree Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.22.9
1.22.10
232 changes: 168 additions & 64 deletions CHANGELOG/CHANGELOG-1.31.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/build-image/cross/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.31.0-go1.22.9-bullseye.0
v1.31.0-go1.22.10-bullseye.0
4 changes: 2 additions & 2 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ readonly KUBE_RSYNC_PORT="${KUBE_RSYNC_PORT:-}"
readonly KUBE_CONTAINER_RSYNC_PORT=8730

# These are the default versions (image tags) for their respective base images.
readonly __default_distroless_iptables_version=v0.5.10
readonly __default_go_runner_version=v2.4.0-go1.22.9-bookworm.0
readonly __default_distroless_iptables_version=v0.5.11
readonly __default_go_runner_version=v2.4.0-go1.22.10-bookworm.0
readonly __default_setcap_version=bookworm-v1.0.3

# These are the base images for the Docker-wrapped binaries.
Expand Down
8 changes: 4 additions & 4 deletions build/dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ dependencies:

# Golang
- name: "golang: upstream version"
version: 1.22.9
version: 1.22.10
refPaths:
- path: .go-version
- path: build/build-image/cross/VERSION
Expand All @@ -138,7 +138,7 @@ dependencies:
match: minimum_go_version=go([0-9]+\.[0-9]+)

- name: "registry.k8s.io/kube-cross: dependents"
version: v1.31.0-go1.22.9-bullseye.0
version: v1.31.0-go1.22.10-bullseye.0
refPaths:
- path: build/build-image/cross/VERSION

Expand Down Expand Up @@ -176,15 +176,15 @@ dependencies:
match: registry\.k8s\.io\/build-image\/debian-base:[a-zA-Z]+\-v((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)

- name: "registry.k8s.io/distroless-iptables: dependents"
version: v0.5.10
version: v0.5.11
refPaths:
- path: build/common.sh
match: __default_distroless_iptables_version=
- path: test/utils/image/manifest.go
match: configs\[DistrolessIptables\] = Config{list\.BuildImageRegistry, "distroless-iptables", "v([0-9]+)\.([0-9]+)\.([0-9]+)"}

- name: "registry.k8s.io/go-runner: dependents"
version: v2.4.0-go1.22.9-bookworm.0
version: v2.4.0-go1.22.10-bookworm.0
refPaths:
- path: build/common.sh
match: __default_go_runner_version=
Expand Down
18 changes: 17 additions & 1 deletion cmd/kubeadm/app/cmd/upgrade/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package upgrade

import (
"fmt"
"io"
"os"

Expand Down Expand Up @@ -83,7 +84,22 @@ func newCmdNode(out io.Writer) *cobra.Command {
return err
}

return nodeRunner.Run(args)
data, err := nodeRunner.InitData(args)
if err != nil {
return err
}
if _, ok := data.(*nodeData); !ok {
return errors.New("invalid data struct")
}
if err := nodeRunner.Run(args); err != nil {
return err
}
if nodeOptions.dryRun {
fmt.Println("[upgrade/successful] Finished dryrunning successfully!")
return nil
}

return nil
},
Args: cobra.NoArgs,
}
Expand Down
6 changes: 6 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAu
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg=
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df h1:7RFfzj4SSt6nnvCPbCqijJi1nWCd+TqAT3bYCStRC18=
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM=
github.com/apache/arrow/go/v12 v12.0.0/go.mod h1:d+tV/eHZZ7Dz7RPrFKtPK02tpr+c9/PEd/zm8mDS9Vg=
github.com/apache/arrow/go/v14 v14.0.2 h1:N8OkaJEOfI3mEZt07BIkvo4sC6XDbL+48MBPWO5IONw=
github.com/apache/arrow/go/v14 v14.0.2/go.mod h1:u3fgh3EdgN/YQ8cVQRguVW3R+seMybFg8QBQ5LU+eBY=
Expand All @@ -383,6 +384,7 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 h1:G1bPvciwNyF7IU
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 h1:BUAU3CGlLvorLI26FmByPp2eC2qla6E1Tw+scpcg/to=
github.com/aws/aws-sdk-go v1.35.24 h1:U3GNTg8+7xSM6OAJ8zksiSM4bRqxBWmVwwehvOSNG3A=
github.com/aws/aws-sdk-go v1.35.24/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k=
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c h1:+0HFd5KSZ/mm3JmhmrDukiId5iR6w4+BdFtfSy4yWIc=
github.com/census-instrumentation/opencensus-proto v0.4.1 h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g=
Expand Down Expand Up @@ -445,6 +447,7 @@ github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MG
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0=
github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4=
github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68=
github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4=
github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY=
Expand Down Expand Up @@ -513,6 +516,7 @@ github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639 h1:mV02weKRL81bEnm8A0HT1/CAelMQDBuQIfLw8n+d6xI=
github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465 h1:KwWnWVWCNtNq/ewIX7HIKnELmEx2nDP42yskD/pi7QE=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024 h1:rBMNdlhTLzJjJSDIjNEXX1Pz3Hmwmz91v+zycvx9PJc=
github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o=
Expand All @@ -537,6 +541,7 @@ github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzR
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI=
github.com/matttproud/golang_protobuf_extensions v1.0.2 h1:hAHbPm5IJGijwng3PWk09JkG9WeqChjprR5s9bBZ+OM=
github.com/matttproud/golang_protobuf_extensions v1.0.2/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/miekg/dns v1.0.14 h1:9jZdLNd/P4+SfEJ0TNyxYpsK8N4GtfylBLqtbYN1sbA=
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY=
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE=
Expand All @@ -547,6 +552,7 @@ github.com/mitchellh/gox v0.4.0 h1:lfGJxY7ToLJQjHHwi0EX6uYBdK78egf954SQl13PQJc=
github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
github.com/openshift/build-machinery-go v0.0.0-20240613134303-8359781da660 h1:F0zE2bmdVvaEd18VXuGYQdJJ1FYJu4MIDW9PYZWc9No=
Expand Down
2 changes: 1 addition & 1 deletion openshift-hack/images/hyperkube/Dockerfile.rhel
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ COPY --from=builder /tmp/build/* /usr/bin/
LABEL io.k8s.display-name="OpenShift Kubernetes Server Commands" \
io.k8s.description="OpenShift is a platform for developing, building, and deploying containerized applications." \
io.openshift.tags="openshift,hyperkube" \
io.openshift.build.versions="kubernetes=1.31.4"
io.openshift.build.versions="kubernetes=1.31.5"
2 changes: 1 addition & 1 deletion pkg/controller/statefulset/stateful_set_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (ssc *defaultStatefulSetControl) truncateHistory(
}
historyLen := len(history)
historyLimit := int(*set.Spec.RevisionHistoryLimit)
if historyLen <= historyLimit {
if historyLimit < 0 || historyLen <= historyLimit {
return nil
}
// delete any non-live history to maintain the revision limit.
Expand Down
35 changes: 35 additions & 0 deletions pkg/controller/statefulset/stateful_set_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import (
"k8s.io/kubernetes/pkg/controller"
"k8s.io/kubernetes/pkg/controller/history"
"k8s.io/kubernetes/pkg/features"
"k8s.io/utils/ptr"
)

type invariantFunc func(set *apps.StatefulSet, om *fakeObjectManager) error
Expand Down Expand Up @@ -2009,6 +2010,13 @@ func TestStatefulSetControlLimitsHistory(t *testing.T) {
if err != nil {
t.Fatalf("%s: %s", test.name, err)
}

if *set.Spec.RevisionHistoryLimit < 0 {
// If the revisionHistoryLimit is negative value, we don't truncate
// the revision history and it is incremental.
continue
}

if len(revisions) > int(*set.Spec.RevisionHistoryLimit)+2 {
t.Fatalf("%s: %d greater than limit %d", test.name, len(revisions), *set.Spec.RevisionHistoryLimit)
}
Expand All @@ -2030,6 +2038,33 @@ func TestStatefulSetControlLimitsHistory(t *testing.T) {
return burst(newStatefulSet(3))
},
},
{
name: "zero revisionHistoryLimit",
invariants: assertMonotonicInvariants,
initial: func() *apps.StatefulSet {
sts := newStatefulSet(3)
sts.Spec.RevisionHistoryLimit = ptr.To(int32(0))
return sts
},
},
{
name: "negative revisionHistoryLimit",
invariants: assertMonotonicInvariants,
initial: func() *apps.StatefulSet {
sts := newStatefulSet(3)
sts.Spec.RevisionHistoryLimit = ptr.To(int32(-2))
return sts
},
},
{
name: "positive revisionHistoryLimit",
invariants: assertMonotonicInvariants,
initial: func() *apps.StatefulSet {
sts := newStatefulSet(3)
sts.Spec.RevisionHistoryLimit = ptr.To(int32(5))
return sts
},
},
}
for i := range tests {
testFn(t, &tests[i])
Expand Down
3 changes: 2 additions & 1 deletion pkg/features/kube_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,8 @@ const (
// alpha: v1.27
// beta: v1.30
//
// Enables querying logs of node services using the /logs endpoint
// Enables querying logs of node services using the /logs endpoint. Enabling this feature has security implications.
// The recommendation is to enable it on a need basis for debugging purposes and disabling otherwise.
NodeLogQuery featuregate.Feature = "NodeLogQuery"

// owner: @xing-yang @sonasingh46
Expand Down
2 changes: 1 addition & 1 deletion pkg/generated/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/kubelet/apis/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ type KubeletConfiguration struct {
EnableSystemLogHandler bool
// EnableSystemLogQuery enables the node log query feature on the /logs endpoint.
// EnableSystemLogHandler has to be enabled in addition for this feature to work.
// Enabling this feature has security implications. The recommendation is to enable it on a need basis for debugging
// purposes and disabling otherwise.
// +featureGate=NodeLogQuery
// +optional
EnableSystemLogQuery bool
Expand Down
3 changes: 2 additions & 1 deletion pkg/kubelet/kubelet_server_journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,14 +384,15 @@ func (n *nodeLogQuery) splitNativeVsFileLoggers(ctx context.Context) ([]string,
// copyServiceLogs invokes journalctl or Get-WinEvent with the provided args. Note that
// services are explicitly passed here to account for the heuristics.
func (n *nodeLogQuery) copyServiceLogs(ctx context.Context, w io.Writer, services []string, previousBoot int) {
cmdStr, args, err := getLoggingCmd(n, services)
cmdStr, args, cmdEnv, err := getLoggingCmd(n, services)
if err != nil {
fmt.Fprintf(w, "\nfailed to get logging cmd: %v\n", err)
return
}
cmd := exec.CommandContext(ctx, cmdStr, args...)
cmd.Stdout = w
cmd.Stderr = w
cmd.Env = append(os.Environ(), cmdEnv...)

if err := cmd.Run(); err != nil {
if _, ok := err.(*exec.ExitError); ok {
Expand Down
12 changes: 8 additions & 4 deletions pkg/kubelet/kubelet_server_journal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ import (
)

// getLoggingCmd returns the journalctl cmd and arguments for the given nodeLogQuery and boot. Note that
// services are explicitly passed here to account for the heuristics
func getLoggingCmd(n *nodeLogQuery, services []string) (string, []string, error) {
args := []string{
// services are explicitly passed here to account for the heuristics.
// The return values are:
// - cmd: the command to be executed
// - args: arguments to the command
// - cmdEnv: environment variables when the command will be executed
func getLoggingCmd(n *nodeLogQuery, services []string) (cmd string, args []string, cmdEnv []string, err error) {
args = []string{
"--utc",
"--no-pager",
}
Expand Down Expand Up @@ -70,7 +74,7 @@ func getLoggingCmd(n *nodeLogQuery, services []string) (string, []string, error)
}
args = append(args, fmt.Sprintf("--output=%s", output))

return "journalctl", args, nil
return "journalctl", args, nil, nil
}

// checkForNativeLogger checks journalctl output for a service
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubelet/kubelet_server_journal_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
)

// getLoggingCmd on unsupported operating systems returns the echo command and a warning message (as strings)
func getLoggingCmd(n *nodeLogQuery, services []string) (string, []string, error) {
return "", []string{}, errors.New("Operating System Not Supported")
func getLoggingCmd(n *nodeLogQuery, services []string) (cmd string, args []string, cmdEnv []string, err error) {
return "", args, cmdEnv, errors.New("Operating System Not Supported")
}

// checkForNativeLogger on unsupported operating systems returns false
Expand Down
52 changes: 43 additions & 9 deletions pkg/kubelet/kubelet_server_journal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"net/url"
"reflect"
"runtime"
"sort"
"strings"
"testing"
"time"
Expand All @@ -30,31 +31,64 @@ import (
)

func Test_getLoggingCmd(t *testing.T) {
var emptyCmdEnv []string
tests := []struct {
name string
args nodeLogQuery
wantLinux []string
wantWindows []string
wantOtherOS []string
name string
args nodeLogQuery
services []string
wantLinux []string
wantWindows []string
wantLinuxCmdEnv []string
wantWindowsCmdEnv []string
}{
{
args: nodeLogQuery{},
wantLinux: []string{"--utc", "--no-pager", "--output=short-precise"},
wantWindows: []string{"-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", "Get-WinEvent -FilterHashtable @{LogName='Application'} | Sort-Object TimeCreated | Format-Table -AutoSize -Wrap"},
name: "basic",
args: nodeLogQuery{},
services: []string{},
wantLinux: []string{"--utc", "--no-pager", "--output=short-precise"},
wantLinuxCmdEnv: emptyCmdEnv,
wantWindows: []string{"-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", "Get-WinEvent -FilterHashtable @{LogName='Application'} | Sort-Object TimeCreated | Format-Table -AutoSize -Wrap"},
wantWindowsCmdEnv: emptyCmdEnv,
},
{
name: "two providers",
args: nodeLogQuery{},
services: []string{"p1", "p2"},
wantLinux: []string{"--utc", "--no-pager", "--output=short-precise", "--unit=p1", "--unit=p2"},
wantLinuxCmdEnv: emptyCmdEnv,
wantWindows: []string{"-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", "Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName=$Env:kubelet_provider0,$Env:kubelet_provider1} | Sort-Object TimeCreated | Format-Table -AutoSize -Wrap"},
wantWindowsCmdEnv: []string{"kubelet_provider0=p1", "kubelet_provider1=p2"},
},
{
name: "empty provider",
args: nodeLogQuery{},
services: []string{"p1", "", "p2"},
wantLinux: []string{"--utc", "--no-pager", "--output=short-precise", "--unit=p1", "--unit=p2"},
wantLinuxCmdEnv: emptyCmdEnv,
wantWindows: []string{"-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", "Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName=$Env:kubelet_provider0,$Env:kubelet_provider2} | Sort-Object TimeCreated | Format-Table -AutoSize -Wrap"},
wantWindowsCmdEnv: []string{"kubelet_provider0=p1", "kubelet_provider2=p2"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, got, err := getLoggingCmd(&tt.args, []string{})
_, got, gotCmdEnv, err := getLoggingCmd(&tt.args, tt.services)
sort.Strings(got)
sort.Strings(tt.wantLinux)
switch os := runtime.GOOS; os {
case "linux":
if !reflect.DeepEqual(got, tt.wantLinux) {
t.Errorf("getLoggingCmd() = %v, want %v", got, tt.wantLinux)
}
if !reflect.DeepEqual(gotCmdEnv, tt.wantLinuxCmdEnv) {
t.Errorf("gotCmdEnv %v, wantLinuxCmdEnv %v", gotCmdEnv, tt.wantLinuxCmdEnv)
}
case "windows":
if !reflect.DeepEqual(got, tt.wantWindows) {
t.Errorf("getLoggingCmd() = %v, want %v", got, tt.wantWindows)
}
if !reflect.DeepEqual(gotCmdEnv, tt.wantWindowsCmdEnv) {
t.Errorf("gotCmdEnv %v, wantWindowsCmdEnv %v", gotCmdEnv, tt.wantWindowsCmdEnv)
}
default:
if err == nil {
t.Errorf("getLoggingCmd() = %v, want err", got)
Expand Down
Loading