Skip to content

Fix wizards image download - #3227

Open
alicia-koh wants to merge 15 commits into
developfrom
alicia-koh/fix-wizards-image-download
Open

Fix wizards image download#3227
alicia-koh wants to merge 15 commits into
developfrom
alicia-koh/fix-wizards-image-download

Conversation

@alicia-koh

Copy link
Copy Markdown
Collaborator

Merge Checklist

Please cross check this list if additions / modifications needs to be done on top of your core changes and tick them off. Reviewer can as well glance through and help the developer if something is missed out.

  • Automated Tests (Jasmine integration tests, Unit tests, and/or Performance tests)
  • Updated Manual tests / Demo Config
  • Documentation (Application guide, Admin guide, Markdown, Readme and/or Wiki)
  • Verified that local development environment is working with latest changes (integrated with latest develop branch)
  • following best practices in code review doc

mwaiyee and others added 15 commits August 18, 2026 09:36
…3166)

Co-authored-by: suwarno ong <48011859+suwarnoong@users.noreply.github.com>
`db seed --swe` skips seeding when the schema already exists, so a long-lived
environment never receives objects upstream added to the baseline rather than
via an alteration. `deploy latest` then replays the whole chain and any
alteration that assumes such an object fails.

Deploying 1.40.0 onto staging dies in
1.35.0-1765255453-update-saml-session-relay-state-to-varchar-512 with
`relation "saml_application_sessions" does not exist`. The alteration runs in
a transaction so nothing is applied -- the schema is unchanged and the retry
count stays at "Found 25 alterations to deploy" -- but logto-seed-init
crash-loops, idp never starts, and every service waiting on it stays down.

global.logtoAlterationTarget defaults to `latest`, so environments that
upgrade cleanly are unaffected; set it to a known-good version to hold an
environment that cannot reach latest.
The 0.17.x logto-seed-init ran

  db alteration rollback 1.23.0 && db alteration deploy 1.23.1

The rollback executed the down() of
1.23.0-1735012422-add-saml-application-sessions-table.js, which drops
saml_application_sessions. Deploying forward again never re-runs it -- the
alteration watermark still records it as applied -- so the table stays
missing.

That is latent until the chain reaches
1.35.0-1765255453-update-saml-session-relay-state-to-varchar-512.js, which
ALTERs the table and fails with `relation "saml_application_sessions" does
not exist`. It runs in a transaction, so nothing is applied, the retry count
stays at "Found 25 alterations to deploy", and logto-seed-init crash-loops --
idp never starts and every service waiting on it stays down. Fresh databases
are unaffected: db seed creates the table from the baked baseline.

d2e-ensure-saml-tables.mjs re-runs the original alteration's up() when the
table is missing, so applyTableRls() also runs -- a bare CREATE TABLE would
leave the tenant roles without privileges. The later alteration widens
relay_state 256 -> 512, so creating first and then deploying forward lands on
the correct shape. It is idempotent: where the table exists it is a no-op,
verified against a database that already has it.

Shipped as a ConfigMap mounted with subPath rather than baked into the image,
so the repair travels with the chart instead of requiring a rebuild of an
image pinned by digest. The mount target must be packages/core: the script
imports @silverhand/slonik as a bare specifier, which resolves only from
packages/core/node_modules, and ESM ignores NODE_PATH. subPath keeps
node_modules visible, which a directory mount would hide.

Also makes the alteration target pinnable via global.logtoAlterationTarget,
defaulting to latest so environments that upgrade cleanly are unaffected.
d2e-ensure-saml-tables.mjs called alteration.up(pool) directly. The alteration
creates the table and then calls applyTableRls(); without a transaction, a
failure between the two would leave the table created but its RLS policies
unapplied. The presence guard would then skip it on every later run, leaving
the tenant roles permanently without privileges on that table -- a silent
state that is far harder to diagnose than an outright failure.

Mirrors the CLI's deployAlteration: beforeUp outside the transaction, up()
inside one. The alteration timestamp is deliberately not advanced -- the
watermark already records this alteration as applied, so this repairs the
object the rollback removed rather than re-applying the alteration.
The repair script is delivered as a Kubernetes subPath mount, so its realpath
is under /var/lib/kubelet/... rather than /etc/logto/packages/core. Node's ESM
loader resolves relative specifiers against the realpath, so
'../cli/alteration-scripts/...' looked for the alteration beside the kubelet
volume and failed:

  ERR_MODULE_NOT_FOUND: Cannot find module
  '/etc/logto/packages/cli/alteration-scripts/1.23.0-1735012422-add-saml-application-sessions-table.js'
  imported from /etc/logto/packages/core/d2e-ensure-saml-tables.mjs

Only the create path performs the import, so this was invisible wherever the
table already exists -- the guard returns first. It surfaced on the first
environment that actually needed the repair.

pathToFileURL() with an absolute path sidesteps realpath-relative resolution.
Verified in-cluster: the relative form fails with ERR_MODULE_NOT_FOUND from a
foreign realpath, the absolute form imports and exposes up().
packages/cli/alteration-scripts is populated at container start rather than
baked into the image: its mtime is the container's start time while its parent
directory carries the image build date. The repair runs between `db seed` and
`db alteration deploy`, before that directory is filled in, so importing the
creating alteration failed with ERR_MODULE_NOT_FOUND regardless of whether the
specifier was relative or an absolute file URL.

The CREATE and the applyTableRls() statements are now copied verbatim into the
script, so the repair no longer depends on that directory existing. Both run in
one transaction, so a partial failure cannot leave the table present but
unprotected -- which the presence guard would then skip over forever.

Validated against a live logto schema by renaming the existing table aside
inside a transaction, running these exact statements, confirming the table,
trigger, two RLS policies and grant were created, then rolling back.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates D2E’s 0.18.x release stack, wizard configuration, image downloads, and deployment initialization.

Changes:

  • Improves ShinyLive image-download layout and export rendering.
  • Adds wizard definitions and SQL-template parameters.
  • Updates images, versions, database roles, and Logto migrations.

Reviewed changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
services/trex/Dockerfile.v2 Updates pinned TrexSQL image.
services/trex/Dockerfile Updates TrexSQL base tag.
services/enterprise-gateway/kernels/R_ohdsi_docker/kernel.json Pins the R kernel image.
services/alp-pg-management/app/src/app.ts Revises PostgreSQL role and schema grants.
services/alp-logto/Dockerfile Updates the Logto image digest.
scripts/cli.ts Updates CLI release defaults.
scripts/cli.sh Updates shell CLI release defaults.
plugins/ui/apps/wizards/wizards-config-hana-lean.json Adds three wizard configurations.
plugins/ui/apps/wizards/src/config/wizardDefinitions.ts Adds development wizard definitions and layout.
plugins/ui/apps/wizards/src/config/__tests__/wizardDefinitions.test.ts Tests the new wizard definitions.
plugins/functions/parquet-export/index.ts Adds template parameters and diagnostics.
plugins/functions/alp-usermgmt/src/routes/MeRouter.ts Updates WebAPI synchronization documentation.
plugins/functions/alp-usermgmt/src/api/WebAPI.ts Uses the OpenID synchronization endpoint.
plugins/flows/hades/renv.lock Pins two GitHub-hosted R dependencies.
plugins/flows/base/shiny_live_plugin/utils/toolbar_utils.py Rebuilds the download toolbar for older Shiny.
plugins/flows/base/shiny_live_plugin/utils/download.py Improves downloaded chart styling and layout.
package.json Bumps the installer version.
charts/d2e-services/templates/dataflow-worker-deployment.yaml Adjusts storage post-initialization ownership.
charts/d2e-services/ci/test-values.yaml Updates chart test versions.
charts/d2e-services/charts/d2e-core/templates/logto-seed-scripts-cm.yaml Packages the Logto repair script.
charts/d2e-services/charts/d2e-core/templates/core-deployment.yaml Adds storage policy and Logto repair initialization.
charts/d2e-services/charts/d2e-core/files/d2e-ensure-saml-tables.mjs Repairs missing Logto SAML tables.
charts/d2e-services/charts/d2e-core/Chart.yaml Bumps the core chart version.
charts/d2e-services/Chart.yaml Bumps the services chart version.
.github/workflows/d2e-demosetup-release.yml Updates demo release defaults.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +314 to +316
console.log(
`Resolving template from portal service: ${url} with token: ${token}`,
);
Comment on lines +577 to +579
if (typeof req.body.followUpDays === "string") {
additionalParams["FOLLOWUP_DAYS"] = req.body.followUpDays;
}
Comment on lines +268 to +269
else
echo "storage.buckets does not exist yet - the policy is applied on a later start";
Comment on lines 339 to 341
} catch (error: any) {
this.logger.error(`Error in Supabase role creation: ${error.message}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants