Skip to content

Conversation

tksm
Copy link
Contributor

@tksm tksm commented Feb 9, 2023

Fixes #39

This PR is to show initContainers first when --no-follow and --max-log-requests 1 are specified. It makes logs easy to follow because it is the same as the order of execution in Kubernetes.

Example

Here is an example pod with an initContainer.

apiVersion: v1
kind: Pod
metadata:
  name: seq
spec:
  initContainers:
  - name: init1
    command: ["/bin/seq", "5"]
    image: busybox:latest
  containers:
  - name: container1
    command: ["/bin/seq", "5"]
    image: busybox:latest

Currently, stern always shows initContainers last when --no-follow and --max-log-requests 1 are specified.

$ stern --container-state all --no-follow --max-log-requests 1 pod/seq
+ seq › container1
seq container1 1
seq container1 2
seq container1 3
seq container1 4
seq container1 5
- seq › container1
+ seq › init1
seq init1 1
seq init1 2
seq init1 3
seq init1 4
seq init1 5
- seq › init1

By this PR, stern always shows initContainers first.

$ stern --container-state all --no-follow --max-log-requests 1 pod/seq
+ seq › init1
seq init1 1
seq init1 2
seq init1 3
seq init1 4
seq init1 5
- seq › init1
+ seq › container1
seq container1 1
seq container1 2
seq container1 3
seq container1 4
seq container1 5
- seq › container1

Copy link
Member

@rkmathi rkmathi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

@floryut
Copy link
Member

floryut commented Feb 10, 2023

lgtm 👍

@rkmathi rkmathi merged commit ef753f1 into stern:master Feb 12, 2023
@tksm tksm deleted the init-containers-first branch February 13, 2023 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggestion: show sequential init container logs first, then pod logs
3 participants