@@ -42,6 +42,12 @@ import (
4242 "sigs.k8s.io/descheduler/pkg/tracing"
4343)
4444
45+ const (
46+ deschedulerGlobalName = "sigs.k8s.io/descheduler"
47+ reasonAnnotationKey = "reason"
48+ requestedByAnnotationKey = "requested-by"
49+ )
50+
4551var (
4652 assumedEvictionRequestTimeoutSeconds uint = 10 * 60 // 10 minutes
4753 evictionRequestsCacheResyncPeriod time.Duration = 10 * time .Minute
@@ -522,7 +528,7 @@ func (pe *PodEvictor) EvictPod(ctx context.Context, pod *v1.Pod, opts EvictOptio
522528 return err
523529 }
524530
525- ignore , err := pe .evictPod (ctx , pod )
531+ ignore , err := pe .evictPod (ctx , pod , opts )
526532 if err != nil {
527533 // err is used only for logging purposes
528534 span .AddEvent ("Eviction Failed" , trace .WithAttributes (attribute .String ("node" , pod .Spec .NodeName ), attribute .String ("err" , err .Error ())))
@@ -569,7 +575,7 @@ func (pe *PodEvictor) EvictPod(ctx context.Context, pod *v1.Pod, opts EvictOptio
569575}
570576
571577// return (ignore, err)
572- func (pe * PodEvictor ) evictPod (ctx context.Context , pod * v1.Pod ) (bool , error ) {
578+ func (pe * PodEvictor ) evictPod (ctx context.Context , pod * v1.Pod , opts EvictOptions ) (bool , error ) {
573579 deleteOptions := & metav1.DeleteOptions {
574580 GracePeriodSeconds : pe .gracePeriodSeconds ,
575581 }
@@ -582,6 +588,10 @@ func (pe *PodEvictor) evictPod(ctx context.Context, pod *v1.Pod) (bool, error) {
582588 ObjectMeta : metav1.ObjectMeta {
583589 Name : pod .Name ,
584590 Namespace : pod .Namespace ,
591+ Annotations : map [string ]string {
592+ "reason" : fmt .Sprintf ("triggered by %v/%v: %v" , opts .ProfileName , opts .StrategyName , opts .Reason ),
593+ "requested-by" : deschedulerGlobalName ,
594+ },
585595 },
586596 DeleteOptions : deleteOptions ,
587597 }
0 commit comments