MCPcopy
hub / github.com/cortexlabs/cortex / DeleteEvictedPods

Function DeleteEvictedPods

pkg/operator/operator/cron.go:42–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40var previousListOfEvictedPods = strset.New()
41
42func DeleteEvictedPods() error {
43 failedPods, err := config.K8s.ListPods(&kmeta.ListOptions{
44 FieldSelector: "status.phase=Failed",
45 })
46 if err != nil {
47 return err
48 }
49
50 var errs []error
51 currentEvictedPods := strset.New()
52 for _, pod := range failedPods {
53 if pod.Status.Reason != k8s.ReasonEvicted {
54 continue
55 }
56 if previousListOfEvictedPods.Has(pod.Name) {
57 _, err := config.K8s.DeletePod(pod.Name)
58 if err != nil {
59 errs = append(errs, err)
60 }
61 continue
62 }
63 currentEvictedPods.Add(pod.Name)
64 }
65 previousListOfEvictedPods = currentEvictedPods
66
67 if errors.HasError(errs) {
68 return errors.FirstError(errs...)
69 }
70 return nil
71}
72
73type instanceInfo struct {
74 InstanceType string `json:"instance_type" yaml:"instance_type"`

Callers

nothing calls this directly

Calls 7

NewFunction · 0.92
HasErrorFunction · 0.92
FirstErrorFunction · 0.92
ListPodsMethod · 0.80
DeletePodMethod · 0.80
HasMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected