Skip to content

Commit

Permalink
WIP: add k8s events support
Browse files Browse the repository at this point in the history
This code does not compile yet. Fixes kubernetes-sigs#166.
  • Loading branch information
seanmalloy committed Sep 20, 2019
1 parent f112754 commit e0ad178
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/descheduler/evictions/evictions.go
Expand Up @@ -18,10 +18,13 @@ package evictions

import (
"fmt"
"time"

"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/api/events/v1beta1"
policy "k8s.io/api/policy/v1beta1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
apimachinery "k8s.io/apimachinery/pkg/apis/meta/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"

Expand All @@ -47,7 +50,10 @@ func EvictPod(client clientset.Interface, pod *v1.Pod, policyGroupVersion string
}
err := client.Policy().Evictions(eviction.Namespace).Evict(eviction)

event := v1beta1.Event{EventTime: apimachinery.NewMicroTime(time.Now()), Reason: "good bye pod"}

if err == nil {
client.Events().Events(pod.Namespace).Create(event)
return true, nil
} else if apierrors.IsTooManyRequests(err) {
return false, fmt.Errorf("error when evicting pod (ignoring) %q: %v", pod.Name, err)
Expand Down

0 comments on commit e0ad178

Please sign in to comment.