Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh
66 linesCodeBlameRaw
1-- The standard sandbox is now Cloudflare Containers' standard-3: 2 vCPU,
2-- 8 GiB of memory and 16 GB of disk, where it had half a vCPU, 4 GiB and
3-- 8 GB (standard-1; a custom 1 vCPU, 4 GiB, 20 GB type was never served).
4-- Cloudflare bills memory and disk as provisioned for every second a
5-- container runs, so a sandbox second's base (memory, disk and the Durable
6-- Object behind it) is now, at list prices:
7--
8-- 8 x 2.5 + 16 x 0.07 + 0.125 x 12.5 = 22.6825 millionths of a dollar
9--
10-- against 12.1225 for 4 GiB and 8 GB. g1t-4core (standard-4) is priced
11-- from it by its scale in the contracts. The price book follows it now,
12-- not after the keeper's notice period, so g1t never charges less than a
13-- sandbox costs it:
14--
15-- - sandbox_base_second (runs that report their own CPU): 22.6825.
16-- - sandbox_second and build_second (the average, for runs that do not):
17-- what they were, or a rise still waiting for its date if that is more,
18-- plus 10.56, the base's growth from 12.1225. The CPU in use on top of
19-- the base is unchanged, and counting it from the smallest base the
20-- price book had keeps the result at or above cost.
21--
22-- Rises still waiting for their date on these meters are replaced, as
23-- pricing.rs does when a newer decision replaces a waiting version, so
24-- none can take the price below cost later. The keeper measures again on
25-- its daily run.
26
27-- 1. What changes, and why.
28INSERT OR IGNORE INTO price_changes (id, meter, old_cost_micros, new_cost_micros, markup_percent, reason, created_at)
29SELECT 'prc_standard_3_' || meter, meter, cost_micros,
30 CASE meter
31 WHEN 'sandbox_base_second' THEN MAX(cost_micros, 22.6825,
32 COALESCE((SELECT MAX(v.cost_micros) FROM price_versions v WHERE v.meter = prices.meter AND v.applied_at IS NULL), 0))
33 ELSE MAX(cost_micros,
34 COALESCE((SELECT MAX(v.cost_micros) FROM price_versions v WHERE v.meter = prices.meter AND v.applied_at IS NULL), 0)) + 10.56
35 END,
36 markup_percent,
37 'Higher: the standard sandbox is now 2 vCPU, 8 GiB and 16 GB, and Cloudflare bills its memory and disk for every second it runs',
38 strftime('%Y-%m-%dT%H:%M:%SZ', 'now')
39 FROM prices WHERE meter IN ('sandbox_base_second', 'sandbox_second', 'build_second');
40
41-- 2. The price book, now.
42UPDATE prices
43 SET cost_micros = (SELECT c.new_cost_micros FROM price_changes c WHERE c.id = 'prc_standard_3_' || prices.meter),
44 updated_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now')
45 WHERE meter IN ('sandbox_base_second', 'sandbox_second', 'build_second')
46 AND EXISTS (SELECT 1 FROM price_changes c WHERE c.id = 'prc_standard_3_' || prices.meter);
47
48-- 3. Rises waiting for their date are replaced.
49UPDATE price_proposals SET status = 'superseded'
50 WHERE version_id IN (SELECT id FROM price_versions
51 WHERE meter IN ('sandbox_base_second', 'sandbox_second', 'build_second') AND applied_at IS NULL);
52
53DELETE FROM price_versions
54 WHERE meter IN ('sandbox_base_second', 'sandbox_second', 'build_second') AND applied_at IS NULL;
55
56-- 4. A version in force from now, so the charges after it are explained by
57-- it.
58INSERT OR IGNORE INTO price_versions (id, meter, version, cost_micros, markup_percent, effective_at, reason, created_by, created_at, applied_at)
59SELECT 'pv_' || p.meter || '_' || (COALESCE((SELECT MAX(v.version) FROM price_versions v WHERE v.meter = p.meter), 0) + 1),
60 p.meter,
61 COALESCE((SELECT MAX(v.version) FROM price_versions v WHERE v.meter = p.meter), 0) + 1,
62 p.cost_micros, p.markup_percent,
63 strftime('%Y-%m-%dT%H:%M:%SZ', 'now'),
64 'The standard sandbox is now 2 vCPU, 8 GiB and 16 GB', 'migration',
65 strftime('%Y-%m-%dT%H:%M:%SZ', 'now'), strftime('%Y-%m-%dT%H:%M:%SZ', 'now')
66 FROM prices p WHERE p.meter IN ('sandbox_base_second', 'sandbox_second', 'build_second');