Fix regression that registration-timeout check was not working for runnerset (#1178)

Follow-up for #1167
This commit is contained in:
Yusuke Kuoka
2022-03-05 19:31:05 +09:00
committed by GitHub
parent 9cc9f8c182
commit 95a5770d55
4 changed files with 62 additions and 222 deletions

View File

@@ -217,6 +217,30 @@ func setAnnotation(meta *metav1.ObjectMeta, key, value string) {
meta.Annotations[key] = value
}
func podConditionTransitionTime(pod *corev1.Pod, tpe corev1.PodConditionType, v corev1.ConditionStatus) *metav1.Time {
for _, c := range pod.Status.Conditions {
if c.Type == tpe && c.Status == v {
return &c.LastTransitionTime
}
}
return nil
}
func podConditionTransitionTimeAfter(pod *corev1.Pod, tpe corev1.PodConditionType, d time.Duration) bool {
c := podConditionTransitionTime(pod, tpe, corev1.ConditionTrue)
if c == nil {
return false
}
return c.Add(d).Before(time.Now())
}
func podRunnerID(pod *corev1.Pod) string {
id, _ := getAnnotation(&pod.ObjectMeta, AnnotationKeyRunnerID)
return id
}
// unregisterRunner unregisters the runner from GitHub Actions by name.
//
// This function returns: