kubernetes / kubernetes/kubectl

kubectl events breaks table layout on multi-line event messages

Open
#1,883 5 comments 0 reactions 0 assignees View on GitHub
kind/bug needs-triage sig/cli
Dominant language
Go
Stars
3.3k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

### What happened?

`kubectl events` renders each event as one tab-separated row and passes the
message to the tabwriter unchanged. A tabwriter ends a row at a line break,
so a multi-line message (e.g. from a failing exec probe) is printed as extra
lines that belong to no event and carry no columns — the table is broken.

`kubectl get events` does not have this problem: its table printer truncates
a cell at the first break character and appends "...".

### What did you expect to happen?

The command's own help says:

> Display events. Prints a table of the most important information about events.

Two things follow from that description:
- It promises *a table*. A multi-line message breaks the table, so the
command isn't honoring its own contract.
- It shows the *most important* information, not the full message — so
truncating an over-long / multi-line message and leaving the full text to
`-o yaml` / `kubectl describe` is consistent with its stated purpose, which
is exactly what `kubectl get events` already does.

### How can we reproduce it (as minimally and precisely as possible)?

```yaml
apiVersion: v1
kind: Pod
metadata:
name: mlprobe
namespace: ent-repro
spec:
containers:
- name: c
image: busybox:latest
command: ["sleep", "3600"]
readinessProbe:
exec:
command: ["sh", "-c", "echo line one; echo line two; exit 1"]
periodSeconds: 5
```

```bash
kubectl create ns ent-repro
kubectl apply -f mlprobe.yaml
```

```bash
zshuang@dev:~/workspace/kubernetes$ ~/kubectl get events -n ent-repro -w | grep Unhealthy
1s Warning Unhealthy pod/mlprobe Readiness probe failed: line one...
0s Warning Unhealthy pod/mlprobe Readiness probe failed: line one...
0s Warning Unhealthy pod/mlprobe Readiness probe failed: line one...
0s Warning Unhealthy pod/mlprobe Readiness probe failed: line one...
0s Warning Unhealthy pod/mlprobe Readiness probe failed: line one...

zshuang@dev:~/workspace/kubernetes$ ~/kubectl events -n ent-repro
LAST SEEN TYPE REASON OBJECT MESSAGE
79s Normal Pulled Pod/mlprobe Container image "registry.cn-beijing.aliyuncs.com/botnow/busybox:latest" already present on machine
79s Normal Created Pod/mlprobe Created container: c
79s Normal Started Pod/mlprobe Started container c
79s Normal Scheduled Pod/mlprobe Successfully assigned ent-repro/mlprobe to botnow-control-plane
4s (x17 over 79s) Warning Unhealthy Pod/mlprobe Readiness probe failed: line one
line two

zshuang@dev:~/workspace/kubernetes$ ./_output/bin/kubectl events -n ent-repro
LAST SEEN TYPE REASON OBJECT MESSAGE
2m45s Normal Pulled Pod/mlprobe Container image "registry.cn-beijing.aliyuncs.com/botnow/busybox:latest" already present on machine
2m45s Normal Created Pod/mlprobe Created container: c
2m45s Normal Started Pod/mlprobe Started container c
2m45s Normal Scheduled Pod/mlprobe Successfully assigned ent-repro/mlprobe to botnow-control-plane
50s (x25 over 2m45s) Warning Unhealthy Pod/mlprobe Readiness probe failed: line one...

```

### Anything else we need to know?

I'm happy to work on the fix once the expected behavior is confirmed.

### Kubernetes version

```console
$ kubectl version
# paste output here
Client Version: v1.36.3
Kustomize Version: v5.8.1
Server Version: v1.36.1
```

### Cloud provider

### OS version

```console
# On Linux:
$ cat /etc/os-release
# paste output here
PRETTY_NAME="Ubuntu 24.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.4 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo
$ uname -a
# paste output here
Linux ubuntu 7.0.14-orbstack-00380-ga7e0a2dc9535 kubernetes/kubernetes#1 SMP PREEMPT Fri Aug 7 03:48:40 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
```

### Install tools

### Container runtime (CRI) and version (if applicable)

### Related plugins (CNI, CSI, ...) and versions (if applicable)

Contributor guide

Open the contributing guide

Research direction

Start at the kubectl events command entry point and compare its table rendering with kubectl get events, which already handles multiline messages. Use the supplied readiness-probe reproduction to observe the output. Done means each event remains a single table row while the displayed message is shortened consistently with kubectl get events.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.