Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathsplitcrons.sh
More file actions
Latest commit
executable file
·59 lines (59 loc) · 5.27 KB
/
Copy pathsplitcrons.sh
File metadata and controls
executable file
·59 lines (59 loc) · 5.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# value a|b means a in weekly mode, b in monthly mode
# NEW (default) algorithm: probes which project cronjobs actually exist in the cluster (kubectl get cronjob)
# and their DB sizes (kubectl exec devstats-postgres-0 ... pg_database_size), then splits the schedule
# space proportionally to sqrt(DB size) (geometric-mean damping: size ratio R => time ratio sqrt(R)).
# Sync minutes always start at GHA_OFFSET (default HH:04 - GHA archive for hour H is available ~HH:04).
# OLD_ALGORITHM=1 (use the legacy index-based spread algorithm with KUBERNETES_HOURS/ALL_HOURS reservations).
# NO_DB_SIZES=1 (new algorithm: skip DB size probing, use even weights).
# SIZES_POD=devstats-postgres-0 (new algorithm: pod used to probe DB sizes via psql).
# SPLIT_ALGO=geom|prop|invgeom (new algorithm weight = size^0.5 (default), size^1.0, size^1.5).
# WEIGHT_POWER=0.75 (new algorithm: custom weight power [0.0,4.0], overrides SPLIT_ALGO).
# DAILY_PROJECTS='kubernetes,all,jenkins,opentelemetry,allcdf,istio' (default; '-' = none):
# projects too big to sync every SYNC_HOURS - excluded from the sync window split (like non-project DBs),
# scheduled once/day instead, spread (weighted) after the affiliations import cron, with
# GHA2DB_RECENT_RANGE/GHA2DB_ORPHAN_COMMITS_RANGE patched to DAILY_RANGE and GHA2DB_RECENT_REPOS_RANGE to
# DAILY_REPOS_RANGE (also saved as recentRange/orphanCommitsRange/recentReposRange in the output values yaml).
# Affiliations crons of daily projects stay in the regular weighted affs spread (affs space is not saturated).
# DAILY_RANGE='26 hours' (default: 24h daily cadence + 2h overlap; used for daily projects' lookback ranges).
# DAILY_REPOS_RANGE='2 days' (default: ghapi2db recently-modified-repos window for daily projects; the code default '1 day' has no margin at 24h cadence).
# NO_AFFS_ANCHOR=1 (disable the default per-project affs anchoring and return to fully independent affs placement).
# By default each project's affs cron is anchored to its OWN sync cron so they can never start close to each
# other (close pairs caused monthly provision-guard sync skips and affs imports racing a running sync):
# - regular (6-hourly) projects: affs starts exactly mid-gap between two consecutive sync slots (slot +SYNC_HOURS/2,
# so +3h for 6-hourly syncs; the slot is chosen to keep the affs hour closest to the weighted spread target),
# - daily projects: affs starts DAILY_AFFS_OFFSET_HOURS after the daily sync,
# - the affs day of week/month still comes from the weighted spread (even affs load across the period).
# DAILY_AFFS_OFFSET_HOURS=8 (default: daily projects' 24h day splits into max 8h for the daily sync run,
# then the affs run starts, having max 16h before the next daily sync; affs take longer than syncs) [1,23].
# ARCHIVED projects (archived: true in values.yaml) never count: they are excluded from all splits (freeing
# schedule space) and their leftover cronjobs (if any) get suspend=true pushed.
# CTX_TEST=test, CTX_PROD=prod (new algorithm: kubectl contexts for test/prod envs; use '-' for current context;
# defaults 'test'/'prod' match in-cluster kubeconfigs; from outside use e.g. CTX_TEST=linode-test CTX_PROD=prod).
# MONTHLY=1 (use 4-weeks - 28 days schedule instead of weekly one).
# KUBERNETES_HOURS=24|36 (reserve this amount of time for Kubernetes project sync [3,30|48]) (old algorithm only).
# ALL_HOURS=20|36 (reserve this amount of time for All CNCF project sync [3,30|48]) (old algorithm only).
# GHA_OFFSET=4 (start at HH:04, to ensure GHA archives are already saved [2,10]).
# SYNC_HOURS=6 (ensure syncing projects every 6 hours, values 1-6 are supported)
# OFFSET_HOURS=-4 (we assume half of weekend is Sun 3 AM, and assume USA tz -7 (3-7=-4), [-84,84]) (old algorithm only).
# ALWAYS_PATCH=1 (skip checking for difference and always call kubectl patch)
# NEVER_PATCH=1 (do not execute kubectl patch - preview/dry mode)
# ONLY_ENV=1 (only patch CJs env variables)
# SKIP_AFFS_ENV=1 (skip patching env for affiliations cron jobs)
# SKIP_SYNC_ENV=1 (skip patching env for affiliations cron jobs)
# PATCH_ENV='AffSkipTemp,MaxHist,SkipAffsLock,AffsLockDB,NoDurable,DurablePQ,MaxRunDuration,SkipGHAPI,SkipGetRepos,NCPUs,RecentRange,OrphanCommitsRange,RecentReposRange'
# ONLY_SUSPEND=1 (only process suspend data)
# SUSPEND_ALL=1 (suspend all cronjobs)
# NO_SUSPEND_H=1 (do not process (un)suspend for hourly sync crons
# NO_SUSPEND_A=1 (do not process (un)suspend for affiliations crons
# DEBUG=1 - more verbose output
# Examples:
# ./splitcrons ../devstats-helm/devstats-helm/values.yaml new-values.yaml
# MONTHLY=1 DEBUG=1 ./splitcrons devstats-helm/values.yaml new-values.yaml
# ALWAYS_PATCH=1 MONTHLY=1 DEBUG=1 ./splitcronsa devstats-helm/values.yaml new-values.yaml
# PATCH_ENV=NCPUs ALWAYS_PATCH=1 MONTHLY=1 DEBUG=1 ./splitcronsa devstats-helm/values.yaml new-values.yaml
# PATCH_ENV=NCPUs ALWAYS_PATCH=1 MONTHLY=1 DEBUG=1 ./splitcrons devstats-helm/values.yaml new-values.yaml
# MONTHLY=1 ONLY_SUSPEND=1 ./splitcrons devstats-helm/values.yaml new-values.yaml
# MONTHLY=1 ONLY_TEST=1 CTX_TEST=linode-test ./splitcrons devstats-helm/values.yaml new-values.yaml
# NEVER_PATCH=1 MONTHLY=1 OLD_ALGORITHM=1 ./splitcrons devstats-helm/values.yaml new-values.yaml
./splitcrons devstats-helm/values.yaml new-values.yaml &&echo"Now update devstats-helm/values.yaml with new-values.yaml"