Skip to content

Commit 9ec36e9

Browse files
committed
enforce minimum interval for release-blocking jobs
1 parent 2f5ae7b commit 9ec36e9

File tree

1 file changed

+63
-4
lines changed

1 file changed

+63
-4
lines changed

config/tests/jobs/jobs_test.go

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,12 +1170,14 @@ func TestClusterName(t *testing.T) {
11701170
}
11711171
t.Logf("summary: %4d/%4d jobs fail to meet sig-k8s-infra cluster name policy", jobsToFix, len(jobs))
11721172
}
1173+
11731174
func TestKubernetesReleaseBlockingJobsCIPolicy(t *testing.T) {
11741175
jobsToFix := 0
1175-
jobs := allStaticJobs()
1176-
for _, job := range jobs {
1176+
numJobs := len(allStaticJobs())
1177+
1178+
for _, job := range c.AllPeriodics() {
11771179
// Only consider Pods that are release-blocking
1178-
if job.Spec == nil || !isKubernetesReleaseBlocking(job) {
1180+
if job.Spec == nil || !isKubernetesReleaseBlocking(job.JobBase) {
11791181
continue
11801182
}
11811183
// job Pod must qualify for Guaranteed QoS
@@ -1190,14 +1192,71 @@ func TestKubernetesReleaseBlockingJobsCIPolicy(t *testing.T) {
11901192
if job.DecorationConfig.Timeout.Duration > (time.Hour*2 + time.Minute*30) {
11911193
errs = append(errs, fmt.Errorf("release-blocking job must have timeout <= 2h30m and nominally run in <=2h, yet timeout is: %v", job.DecorationConfig.Timeout))
11921194
}
1195+
// periodics must run with minimum frequency, but this is reduced on older release branches
1196+
branch := kubernetesBranch(job.ExtraRefs)
1197+
if branch == "master" || branch == "main" {
1198+
// TODO: cron ...
1199+
if job.Interval != "" {
1200+
interval := job.GetInterval()
1201+
if interval > (time.Hour * 3) {
1202+
errs = append(errs, fmt.Errorf("release-blocking job must have interval <= 3h, yet interval is: %v", interval))
1203+
}
1204+
}
1205+
}
11931206
if len(errs) > 0 {
11941207
jobsToFix++
11951208
}
11961209
for _, err := range errs {
11971210
t.Errorf("%v: %v", job.Name, err)
11981211
}
11991212
}
1200-
t.Logf("summary: %4d/%4d jobs fail to meet kubernetes/kubernetes release-blocking CI policy", jobsToFix, len(jobs))
1213+
1214+
for repo, postsubmits := range c.PostsubmitsStatic {
1215+
for _, job := range postsubmits {
1216+
// postsubmits triggering against repos other than kubernetes/kubernetes
1217+
// should not be release-blocking
1218+
if repo != "kubernetes/kubernetes" {
1219+
if job.Spec != nil && isKubernetesReleaseBlocking(job.JobBase) {
1220+
t.Errorf("%v: postsubmit should not be release-blocking when it does not trigger against kubernetes/kubernetes", job)
1221+
}
1222+
continue
1223+
}
1224+
// only consider release-blocking jobs
1225+
if job.Spec == nil || !isKubernetesReleaseBlocking(job.JobBase) {
1226+
continue
1227+
}
1228+
// release blocking jobs must follow policy
1229+
// job Pod must qualify for Guaranteed QoS
1230+
errs := verifyPodQOSGuaranteed(job.Spec, true)
1231+
if !isCritical(job.Cluster) {
1232+
errs = append(errs, fmt.Errorf("must run in cluster: k8s-infra-prow-build or eks-prow-build-cluster, found: %v", job.Cluster))
1233+
}
1234+
// Allow some buffer over the 120m target in the release blocking job policy:
1235+
// "Have the average of 75% percentile duration of all runs for a week finishing in 120 minutes or less"
1236+
// "Run at least every 3 hours"
1237+
// https://github.com/kubernetes/sig-release/blob/master/release-blocking-jobs.md
1238+
if job.DecorationConfig.Timeout.Duration > (time.Hour*2 + time.Minute*30) {
1239+
errs = append(errs, fmt.Errorf("release-blocking job must have timeout <= 2h30m and nominally run in <=2h, yet timeout is: %v", job.DecorationConfig.Timeout))
1240+
}
1241+
if len(errs) > 0 {
1242+
jobsToFix++
1243+
}
1244+
for _, err := range errs {
1245+
t.Errorf("%v: %v", job.Name, err)
1246+
}
1247+
}
1248+
}
1249+
1250+
t.Logf("summary: %4d/%4d jobs fail to meet kubernetes/kubernetes release-blocking CI policy", jobsToFix, numJobs)
1251+
}
1252+
1253+
func kubernetesBranch(refs []prowapi.Refs) string {
1254+
for _, ref := range refs {
1255+
if ref.Org == "kubernetes" && ref.Repo == "kubernetes" {
1256+
return ref.BaseRef
1257+
}
1258+
}
1259+
return ""
12011260
}
12021261

12031262
func TestK8sInfraProwBuildJobsCIPolicy(t *testing.T) {

0 commit comments

Comments
 (0)