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

Relax search criteria to find both pod & bound pod events #2588

Merged
merged 1 commit into from
Dec 2, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 14 additions & 7 deletions pkg/client/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,21 @@ func (e *events) Search(objOrRef runtime.Object) (*api.EventList, error) {
if err != nil {
return nil, err
}
// TODO: search by UID if it's set
fields := labels.Set{
"involvedObject.kind": ref.Kind,
"involvedObject.namespace": ref.Namespace,
"involvedObject.name": ref.Name,
}.AsSelector()
if e.namespace != "" && ref.Namespace != e.namespace {
return nil, fmt.Errorf("won't be able to find any events of namespace '%v' in namespace '%v'", ref.Namespace, e.namespace)
}
return e.List(labels.Everything(), fields)
fields := labels.Set{}
if ref.Kind != "" {
fields["involvedObject.kind"] = ref.Kind
}
if ref.Namespace != "" {
fields["involvedObject.namespace"] = ref.Namespace
}
if ref.Name != "" {
fields["involvedObject.name"] = ref.Name
}
if ref.UID != "" {
fields["involvedObject.uid"] = ref.UID
}
return e.List(labels.Everything(), fields.AsSelector())
}
9 changes: 7 additions & 2 deletions pkg/kubectl/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func (d *PodDescriber) Describe(namespace, name string) (string, error) {
labels.Everything(),
labels.Set{
"involvedObject.name": name,
"involvedObject.kind": "Pod",
"involvedObject.namespace": namespace,
}.AsSelector(),
)
Expand All @@ -86,7 +85,13 @@ func (d *PodDescriber) Describe(namespace, name string) (string, error) {
glog.Errorf("Unable to convert pod manifest: %v", err)
}

events, _ := d.Events(namespace).Search(pod)
var events *api.EventList
if ref, err := api.GetReference(pod); err != nil {
glog.Errorf("Unable to construct reference to '%#v': %v", pod, err)
} else {
ref.Kind = "" // Find BoundPod objects, too!
events, _ = d.Events(namespace).Search(ref)
}

return tabbedString(func(out io.Writer) error {
fmt.Fprintf(out, "Name:\t%s\n", pod.Name)
Expand Down