Skip to content

Commit 3068b57

Browse files
committed
fix(sim-setup): keep realtime and migrations on the app's pinned release, and pass image tags as strings
1 parent 6f876ab commit 3068b57

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

‎packages/sim-setup/src/modes/k8s.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,18 @@ describe('k8s image pins', () => {
1818
expect(args).toContain('realtime.image.tag=latest')
1919
expect(args).toContain('realtime.image.pullPolicy=Always')
2020
})
21+
22+
it('keeps unpinned realtime and migrations on the release the app is pinned to', () => {
23+
const args = imageTagArgs({ app: { image: { tag: 'v0.9.74' } } })
24+
25+
expect(args).toContain('realtime.image.tag=v0.9.74')
26+
expect(args).toContain('migrations.image.tag=v0.9.74')
27+
expect(args).not.toContain('realtime.image.pullPolicy=Always')
28+
})
29+
30+
it('passes tags as strings so a numeric-looking tag is not coerced', () => {
31+
const args = imageTagArgs({ app: { image: { tag: '20260101' } } })
32+
33+
expect(args[args.indexOf('app.image.tag=20260101') - 1]).toBe('--set-string')
34+
})
2135
})

‎packages/sim-setup/src/modes/k8s.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,19 +299,22 @@ interface ReleaseValues {
299299
* `--set` flags pinning the app, realtime, and migrations images. A checkout's chart carries a
300300
* deliberately stale appVersion, so without them the release would run old images. A digest or
301301
* tag the existing release already pins is kept (a digest overrides any tag in the chart).
302-
* `latest` is pulled on every start, or nodes would keep the image they cached and never see a
303-
* newer build.
302+
* An unpinned realtime or migrations image follows the app's pinned tag, so the three stay on one
303+
* release. `latest` is pulled on every start, or nodes would keep the image they cached and never
304+
* see a newer build. Tags go through `--set-string` so a numeric-looking tag stays a string.
304305
*/
305306
export function imageTagArgs(values: ReleaseValues | null): string[] {
307+
const appTag = values?.app?.image?.tag
308+
const releaseTag = appTag && appTag !== 'latest' ? appTag : 'latest'
306309
return (['app', 'realtime', 'migrations'] as const).flatMap((component) => {
307310
const image = values?.[component]?.image
308311
if (image?.digest) {
309-
const args = ['--set', `${component}.image.digest=${image.digest}`]
310-
return image.tag ? [...args, '--set', `${component}.image.tag=${image.tag}`] : args
312+
const args = ['--set-string', `${component}.image.digest=${image.digest}`]
313+
return image.tag ? [...args, '--set-string', `${component}.image.tag=${image.tag}`] : args
311314
}
312315
const pinned = image?.tag
313-
const tag = pinned && pinned !== 'latest' ? pinned : 'latest'
314-
const args = ['--set', `${component}.image.tag=${tag}`]
316+
const tag = pinned && pinned !== 'latest' ? pinned : releaseTag
317+
const args = ['--set-string', `${component}.image.tag=${tag}`]
315318
return tag === 'latest' ? [...args, '--set', `${component}.image.pullPolicy=Always`] : args
316319
})
317320
}

0 commit comments

Comments
 (0)