prow/plank/controller.go
func (c *Controller) terminateDupes(pjs []prowapi.ProwJob, pm map[string]coreapi.Pod) error {
	log := c.log.WithField("aborter", "pod")
	return pjutil.TerminateOlderPresubmitJobs(c.kc, log, pjs, func(toCancel prowapi.ProwJob) error {
		// Allow aborting presubmit jobs for commits that have been superseded by
		// newer commits in GitHub pull requests.
		if c.config().Plank.AllowCancellations {
			if pod, exists := pm[toCancel.ObjectMeta.Name]; exists {
				if client, ok := c.pkcs[toCancel.ClusterAlias()]; !ok {
					return fmt.Errorf("unknown cluster alias %q", toCancel.ClusterAlias())
				} else if err := client.DeletePod(pod.ObjectMeta.Name); err != nil {
					return fmt.Errorf("deleting pod: %v", err)
				}
			}
		}
		return nil
	})
}
func (c *Controller) terminateDupes(pjs []prowapi.ProwJob, pm map[string]coreapi.Pod) error {
	log := c.log.WithField("aborter", "pod")
	return pjutil.TerminateOlderPresubmitJobs(c.kc, log, pjs, func(toCancel prowapi.ProwJob) error {
		// Allow aborting presubmit jobs for commits that have been superseded by
		// newer commits in GitHub pull requests.
		if c.config().Plank.AllowCancellations {
			if pod, exists := pm[toCancel.ObjectMeta.Name]; exists {
				if client, ok := c.pkcs[toCancel.ClusterAlias()]; !ok {
					return fmt.Errorf("unknown cluster alias %q", toCancel.ClusterAlias())
				} else if err := client.DeletePod(pod.ObjectMeta.Name); err != nil {
					return fmt.Errorf("deleting pod: %v", err)
				}
			}
		}
		return nil
	})
}
// terminateDupes aborts presubmits that have a newer version. It modifies pjs
// in-place when it aborts.
// TODO: Dry this out - need to ensure we can abstract children cancellation first.