Skip to content

Commit

Permalink
Merge pull request #1641 from saschagrunert/panic-nil
Browse files Browse the repository at this point in the history
Fix panic if container metadata is `nil`
  • Loading branch information
k8s-ci-robot authored Oct 16, 2024
2 parents 8b53f41 + 34d1b37 commit 325fc84
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/crictl/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,8 @@ func getContainersList(containersList []*pb.Container, opts *listOptions) []*pb.
for _, c := range containersList {
podNamespace := getPodNamespaceFromLabels(c.Labels)
// Filter by pod name/namespace regular expressions.
if matchesRegex(opts.nameRegexp, c.Metadata.Name) &&
if c.Metadata != nil &&
matchesRegex(opts.nameRegexp, c.Metadata.Name) &&
matchesRegex(opts.podNamespaceRegexp, podNamespace) {
filtered = append(filtered, c)
}
Expand Down

0 comments on commit 325fc84

Please sign in to comment.