jdecool/scaleway-runtimepublic Fork
⑂ b64f0a3
Commits
⬇ Clone ▾
git clone https://git.rickub.com/jdecool/scaleway-runtime.git
git clone ssh://git@rickub.com/jdecool/scaleway-runtime.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

docs: verify Command Invocations end to end on ScalewayUnverified

The example was deployed with its CRON triggers set to every minute in a
scratch copy of its Terraform, plus a wrong secret and a failing command.
The logs show a plain trigger landing on POST /, app:greet running as a
Command Invocation, a wrong secret and an HTTP call being rejected, and a
failing command being logged and not retried. Stale notes about the
package not being on Packagist and the Terraform never being applied go.
Jérémy DECOOL committed 2026-11-14T14:37:20+01:00 Browse files
b64f0a3 parent: 67c2d80
modified README.md +4 -1
@@ -10,7 +10,7 @@ Vocabulary (Invocation, Event, Warm Process...) is defined in [GLOSSARY.md](GLOS
1010
1111 > [!IMPORTANT]
1212 > The platform facts the runtime relies on were measured on Scaleway with the [probe](probe), see [docs/probe-results.md](docs/probe-results.md).
13-> The runtime itself has only run through the Emulator so far, and the package is not on Packagist yet.
13+> The [example application](example) runs on Scaleway: its scenarios, CRON triggers and Command Invocations were checked on a deployment.
1414
1515 ## Contents
1616
@@ -323,6 +323,8 @@ Services are reset around each command, so it shares no state with the Invocatio
323323 | `args` not a JSON object | 500 |
324324 | The Front Controller returns a Response, a PSR-15 handler or a plain `HttpKernelInterface` | 500, as there is no Console Application to run the command |
325325
326+Nothing shows the Function Response of a CRON Invocation, and a failed one is not retried: the [logs](#logs) are where the outcome of a command shows up, so log what it does ([measured](docs/probe-results.md#cron-invocations)).
327+
326328 ### Security model
327329
328330 A body only becomes a Command Invocation when both hold:
@@ -382,6 +384,7 @@ Replacing a function, for instance to change its `runtime`, deletes its CRON tri
382384
383385 Scaleway sends what the function writes to stdout and stderr to [Cockpit](https://www.scaleway.com/en/docs/cockpit/), in the project's `Scaleway Logs` data source, about 2 seconds after it is written.
384386 The runtime logs its own failures to stderr, as Monolog does with a `php://stderr` handler.
387+Without Monolog, Symfony's fallback logger writes to stderr too, but from the `error` level only: lower it as the [example](example/config/services.yaml) does.
385388 Each line is one log entry: a stack trace spans one entry per line, and a line over 16 KiB is split into 16 KiB entries and cut after 64 KiB.
386389 Every entry has the `debug` level, stderr ones included, except the continuations of a split line, whose level is `unknown`: filter on the `stream` field instead.
387390 An entry looks like this, with the `resource_id` label holding the function's UUID:
@@ -10,7 +10,7 @@ Vocabulary (Invocation, Event, Warm Process...) is defined in [GLOSSARY.md](GLOS
10 10
11 > [!IMPORTANT]11 > [!IMPORTANT]
12 > The platform facts the runtime relies on were measured on Scaleway with the [probe](probe), see [docs/probe-results.md](docs/probe-results.md).12 > The platform facts the runtime relies on were measured on Scaleway with the [probe](probe), see [docs/probe-results.md](docs/probe-results.md).
13-> The runtime itself has only run through the Emulator so far, and the package is not on Packagist yet.13+> The [example application](example) runs on Scaleway: its scenarios, CRON triggers and Command Invocations were checked on a deployment.
14 14
15 ## Contents15 ## Contents
16 16
@@ -323,6 +323,8 @@ Services are reset around each command, so it shares no state with the Invocatio
323 | `args` not a JSON object | 500 |323 | `args` not a JSON object | 500 |
324 | The Front Controller returns a Response, a PSR-15 handler or a plain `HttpKernelInterface` | 500, as there is no Console Application to run the command |324 | The Front Controller returns a Response, a PSR-15 handler or a plain `HttpKernelInterface` | 500, as there is no Console Application to run the command |
325 325
326+Nothing shows the Function Response of a CRON Invocation, and a failed one is not retried: the [logs](#logs) are where the outcome of a command shows up, so log what it does ([measured](docs/probe-results.md#cron-invocations)).
327+
326 ### Security model328 ### Security model
327 329
328 A body only becomes a Command Invocation when both hold:330 A body only becomes a Command Invocation when both hold:
@@ -382,6 +384,7 @@ Replacing a function, for instance to change its `runtime`, deletes its CRON tri
382 384
383 Scaleway sends what the function writes to stdout and stderr to [Cockpit](https://www.scaleway.com/en/docs/cockpit/), in the project's `Scaleway Logs` data source, about 2 seconds after it is written.385 Scaleway sends what the function writes to stdout and stderr to [Cockpit](https://www.scaleway.com/en/docs/cockpit/), in the project's `Scaleway Logs` data source, about 2 seconds after it is written.
384 The runtime logs its own failures to stderr, as Monolog does with a `php://stderr` handler.386 The runtime logs its own failures to stderr, as Monolog does with a `php://stderr` handler.
387+Without Monolog, Symfony's fallback logger writes to stderr too, but from the `error` level only: lower it as the [example](example/config/services.yaml) does.
385 Each line is one log entry: a stack trace spans one entry per line, and a line over 16 KiB is split into 16 KiB entries and cut after 64 KiB.388 Each line is one log entry: a stack trace spans one entry per line, and a line over 16 KiB is split into 16 KiB entries and cut after 64 KiB.
386 Every entry has the `debug` level, stderr ones included, except the continuations of a split line, whose level is `unknown`: filter on the `stream` field instead.389 Every entry has the `debug` level, stderr ones included, except the continuations of a split line, whose level is `unknown`: filter on the `stream` field instead.
387 An entry looks like this, with the `resource_id` label holding the function's UUID:390 An entry looks like this, with the `resource_id` label holding the function's UUID:
modified docs/plan.md +4 -3
@@ -53,8 +53,9 @@ Recorded per phase; the settled design above already reflects them.
5353 ## Remaining work
5454
5555 Done on 2026-11-14: the repository is on GitHub with CI green, the package is on Packagist, `example/composer.lock` is locked from Packagist, and `example/e2e/run.sh` passed against the example deployed on Scaleway (`php85`), before `v0.1.0` was tagged.
56+Command Invocations were then verified on that deployment through its logs ([probe results](probe-results.md#cron-invocations)): a CRON trigger lands on `POST /`, the `app:greet` arguments with the secret run the command, a wrong secret or an HTTP call do not, and a failing command is logged.
57+For that, the example logs from the `info` level to stderr, and no longer logs the body of `POST /`, which may hold the secret; `e2e/run.sh` still skips the CRON scenarios against a deployment, the triggers firing hourly and their outcome being in Cockpit only, so the example README documents the manual check.
5658
57-1. Verify a Command Invocation end to end on Scaleway: the e2e scenarios trigger CRON Invocations only through the Emulator, and the deployed one could only be observed in the logs.
58-2. Run the example deployment with `host` set, to check absolute URLs.
59-3. Measure what the probe left open: what a deployment with a failing Composer script serves.
59+1. Run the example deployment with `host` set, to check absolute URLs.
60+2. Measure what the probe left open: what a deployment with a failing Composer script serves.
6061 Where logs go was measured on 2026-11-14 ([probe results](probe-results.md#logs)): the runtime's stderr lines reach Cockpit one entry per line, with a `DEBUG - ` prefix and a ` source=user stream=stderr` suffix.
@@ -53,8 +53,9 @@ Recorded per phase; the settled design above already reflects them.
53 ## Remaining work53 ## Remaining work
54 54
55 Done on 2026-11-14: the repository is on GitHub with CI green, the package is on Packagist, `example/composer.lock` is locked from Packagist, and `example/e2e/run.sh` passed against the example deployed on Scaleway (`php85`), before `v0.1.0` was tagged.55 Done on 2026-11-14: the repository is on GitHub with CI green, the package is on Packagist, `example/composer.lock` is locked from Packagist, and `example/e2e/run.sh` passed against the example deployed on Scaleway (`php85`), before `v0.1.0` was tagged.
56+Command Invocations were then verified on that deployment through its logs ([probe results](probe-results.md#cron-invocations)): a CRON trigger lands on `POST /`, the `app:greet` arguments with the secret run the command, a wrong secret or an HTTP call do not, and a failing command is logged.
57+For that, the example logs from the `info` level to stderr, and no longer logs the body of `POST /`, which may hold the secret; `e2e/run.sh` still skips the CRON scenarios against a deployment, the triggers firing hourly and their outcome being in Cockpit only, so the example README documents the manual check.
56 58
57-1. Verify a Command Invocation end to end on Scaleway: the e2e scenarios trigger CRON Invocations only through the Emulator, and the deployed one could only be observed in the logs.59+1. Run the example deployment with `host` set, to check absolute URLs.
58-2. Run the example deployment with `host` set, to check absolute URLs.60+2. Measure what the probe left open: what a deployment with a failing Composer script serves.
59-3. Measure what the probe left open: what a deployment with a failing Composer script serves.
60 Where logs go was measured on 2026-11-14 ([probe results](probe-results.md#logs)): the runtime's stderr lines reach Cockpit one entry per line, with a `DEBUG - ` prefix and a ` source=user stream=stderr` suffix.61 Where logs go was measured on 2026-11-14 ([probe results](probe-results.md#logs)): the runtime's stderr lines reach Cockpit one entry per line, with a `DEBUG - ` prefix and a ` source=user stream=stderr` suffix.
modified docs/probe-results.md +19 -0
@@ -81,6 +81,25 @@ Headers sent by the client:
8181 - The trigger `args` arrive as a JSON string in `body`, without `isBase64Encoded`.
8282 - CRON Events carry neither `X-Real-Ip` nor `X-Envoy-External-Address`, which the platform always sets (overwriting client values) on external HTTP calls.
8383
84+## CRON Invocations
85+
86+Measured on 2026-11-14 with the [example](../example) and `jdecool/scaleway-runtime` v0.1.0 (`php85`), its two triggers set to every minute in a copy of its Terraform, with two more: the `app:greet` arguments with a wrong secret, and with `--fail`.
87+For three minutes, each of the four triggers fired once a minute, 1 to 15 seconds past it, each Invocation preceded by `DEBUG - Function Triggered: / source=core`.
88+Their stderr lines, without the `DEBUG - ` prefix and ` source=user stream=stderr` suffix:
89+
90+| Trigger arguments | Logged |
91+| --- | --- |
92+| `{"job": "hourly"}` | `[info] Matched route "app_demo_cron".`, then `[info] CRON Invocation received with the arguments job` |
93+| `app:greet`, `{"name": "CRON"}`, the right secret | `[info] Command app:greet said: Hello CRON!` only: no route matched, no failure |
94+| `app:greet`, a wrong secret | `Command Invocation rejected: the "secret" does not match SCALEWAY_CRON_SECRET, the body goes to the Application as a plain HTTP body.`, then the `POST /` lines |
95+| `app:greet`, `{"--fail": true}`, the right secret | `[info] Command app:greet said: Hello world!`, then `Command "app:greet" failed with exit code 1: Hello world!` and one entry per line of the output, blank ones included |
96+
97+- The wrong secret was rejected for the secret, not for the HTTP-only headers: CRON Events lack them, as the probe found.
98+- The same `app:greet` body with the right secret, sent over HTTP by `example/e2e/run.sh`, logged `Command Invocation rejected: the Event comes from an HTTP call, not a CRON trigger, ...` and landed on `POST /`.
99+- The failing command was not retried: one Invocation a minute, like the others.
100+- The status code of a CRON Invocation's Function Response appears nowhere in the logs.
101+- The CRON secret appeared in none of the 110 entries of the run.
102+
84103 ## Context
85104
86105 An `array`: `{"memoryLimitInMb": 256, "functionName": "probe-php85", "functionVersion": ""}`.
@@ -81,6 +81,25 @@ Headers sent by the client:
81 - The trigger `args` arrive as a JSON string in `body`, without `isBase64Encoded`.81 - The trigger `args` arrive as a JSON string in `body`, without `isBase64Encoded`.
82 - CRON Events carry neither `X-Real-Ip` nor `X-Envoy-External-Address`, which the platform always sets (overwriting client values) on external HTTP calls.82 - CRON Events carry neither `X-Real-Ip` nor `X-Envoy-External-Address`, which the platform always sets (overwriting client values) on external HTTP calls.
83 83
84+## CRON Invocations
85+
86+Measured on 2026-11-14 with the [example](../example) and `jdecool/scaleway-runtime` v0.1.0 (`php85`), its two triggers set to every minute in a copy of its Terraform, with two more: the `app:greet` arguments with a wrong secret, and with `--fail`.
87+For three minutes, each of the four triggers fired once a minute, 1 to 15 seconds past it, each Invocation preceded by `DEBUG - Function Triggered: / source=core`.
88+Their stderr lines, without the `DEBUG - ` prefix and ` source=user stream=stderr` suffix:
89+
90+| Trigger arguments | Logged |
91+| --- | --- |
92+| `{"job": "hourly"}` | `[info] Matched route "app_demo_cron".`, then `[info] CRON Invocation received with the arguments job` |
93+| `app:greet`, `{"name": "CRON"}`, the right secret | `[info] Command app:greet said: Hello CRON!` only: no route matched, no failure |
94+| `app:greet`, a wrong secret | `Command Invocation rejected: the "secret" does not match SCALEWAY_CRON_SECRET, the body goes to the Application as a plain HTTP body.`, then the `POST /` lines |
95+| `app:greet`, `{"--fail": true}`, the right secret | `[info] Command app:greet said: Hello world!`, then `Command "app:greet" failed with exit code 1: Hello world!` and one entry per line of the output, blank ones included |
96+
97+- The wrong secret was rejected for the secret, not for the HTTP-only headers: CRON Events lack them, as the probe found.
98+- The same `app:greet` body with the right secret, sent over HTTP by `example/e2e/run.sh`, logged `Command Invocation rejected: the Event comes from an HTTP call, not a CRON trigger, ...` and landed on `POST /`.
99+- The failing command was not retried: one Invocation a minute, like the others.
100+- The status code of a CRON Invocation's Function Response appears nowhere in the logs.
101+- The CRON secret appeared in none of the 110 entries of the run.
102+
84 ## Context103 ## Context
85 104
86 An `array`: `{"memoryLimitInMb": 256, "functionName": "probe-php85", "functionVersion": ""}`.105 An `array`: `{"memoryLimitInMb": 256, "functionName": "probe-php85", "functionVersion": ""}`.
modified example/README.md +11 -6
@@ -14,6 +14,8 @@ A minimal Symfony application running on Scaleway Serverless Functions through `
1414
1515 Its `post-install-cmd` warms the prod cache when Scaleway installs the dependencies at deploy time, as the warmup needs no secret; without it, the first Invocation of each Warm Process builds the cache.
1616
17+It logs from the `info` level to stderr, which reaches Cockpit, through Symfony's fallback logger lowered in `config/services.yaml`, without Monolog.
18+
1719 The `app:greet` console command (`src/Command/GreetCommand.php`) runs as a Command Invocation: a `POST /` whose JSON body is `{"command": "app:greet", "args": {"name": "...", "--yell": true}, "secret": "..."}`, the secret matching the function's `SCALEWAY_CRON_SECRET`.
1820 Its `--fail` option shows how a failed command answers: a 500 with the command output.
1921 Over HTTP, even with the secret, the same body is a plain HTTP body and lands on `POST /`.
@@ -37,13 +39,12 @@ return static fn (): Closure => static fn (array $event, mixed $context): array
3739
3840 ## Run it locally
3941
40-The package is not on Packagist yet, and the example works on the runtime of this checkout anyway: `composer link-runtime` installs it from the parent directory, through a `path` repository it adds to `composer.json`.
41-Never commit that repository: `scaleway-package` refuses it, as Scaleway cannot resolve it.
42-Until the first publication, the committed `composer.lock` is the one `link-runtime` writes; once the package is on Packagist, it is regenerated without the repository (`composer update jdecool/scaleway-runtime`) and committed, which makes the example deployable as is.
42+The example requires the runtime from Packagist; `composer link-runtime` installs the runtime of this checkout instead, from the parent directory, through a `path` repository it adds to `composer.json`.
43+Never commit that repository nor the lock it writes: `scaleway-package` refuses them, as Scaleway cannot resolve them.
4344
4445 ```sh
4546 cd example
46-composer link-runtime
47+composer install # or composer link-runtime, for the runtime of this checkout
4748 export SCALEWAY_CRON_SECRET=local-secret # lets the Emulator and the scenarios run Command Invocations
4849 vendor/bin/scaleway-serve # the Emulator, on http://127.0.0.1:8000
4950 e2e/run.sh http://127.0.0.1:8000 # in another terminal, with the same SCALEWAY_CRON_SECRET
@@ -66,8 +67,6 @@ It publishes the runtime of this checkout to that install in place of Packagist,
6667
6768 ## Deploy it
6869
69-Deploying needs the package on Packagist and the lock regenerated against it, see above: until then, `scaleway-package` refuses the committed lock.
70-The Terraform code is unvalidated: it was written against the `scaleway/scaleway` provider v2.92 documentation and never applied.
7170 Set `host` to the function's domain (or a custom domain) for absolute URLs to be right; it cannot default to the function's own `domain_name`, so apply once, then again with `-var host=...`.
7271
7372 ```sh
@@ -83,3 +82,9 @@ terraform -chdir=terraform destroy
8382
8483 Rerun `scaleway-package` and `terraform apply` to deploy a new version.
8584 Against a deployment, `e2e/run.sh` skips the CRON scenarios, as only the platform triggers CRON Invocations.
85+Check them in the [logs](../README.md#logs) instead, after the triggers ran (at minutes 0 and 30): each one leaves its line, the second showing that `app:greet` ran as a Command Invocation.
86+
87+```
88+DEBUG - [info] CRON Invocation received with the arguments job source=user stream=stderr
89+DEBUG - [info] Command app:greet said: Hello CRON! source=user stream=stderr
90+```
@@ -14,6 +14,8 @@ A minimal Symfony application running on Scaleway Serverless Functions through `
14 14
15 Its `post-install-cmd` warms the prod cache when Scaleway installs the dependencies at deploy time, as the warmup needs no secret; without it, the first Invocation of each Warm Process builds the cache.15 Its `post-install-cmd` warms the prod cache when Scaleway installs the dependencies at deploy time, as the warmup needs no secret; without it, the first Invocation of each Warm Process builds the cache.
16 16
17+It logs from the `info` level to stderr, which reaches Cockpit, through Symfony's fallback logger lowered in `config/services.yaml`, without Monolog.
18+
17 The `app:greet` console command (`src/Command/GreetCommand.php`) runs as a Command Invocation: a `POST /` whose JSON body is `{"command": "app:greet", "args": {"name": "...", "--yell": true}, "secret": "..."}`, the secret matching the function's `SCALEWAY_CRON_SECRET`.19 The `app:greet` console command (`src/Command/GreetCommand.php`) runs as a Command Invocation: a `POST /` whose JSON body is `{"command": "app:greet", "args": {"name": "...", "--yell": true}, "secret": "..."}`, the secret matching the function's `SCALEWAY_CRON_SECRET`.
18 Its `--fail` option shows how a failed command answers: a 500 with the command output.20 Its `--fail` option shows how a failed command answers: a 500 with the command output.
19 Over HTTP, even with the secret, the same body is a plain HTTP body and lands on `POST /`.21 Over HTTP, even with the secret, the same body is a plain HTTP body and lands on `POST /`.
@@ -37,13 +39,12 @@ return static fn (): Closure => static fn (array $event, mixed $context): array
37 39
38 ## Run it locally40 ## Run it locally
39 41
40-The package is not on Packagist yet, and the example works on the runtime of this checkout anyway: `composer link-runtime` installs it from the parent directory, through a `path` repository it adds to `composer.json`.42+The example requires the runtime from Packagist; `composer link-runtime` installs the runtime of this checkout instead, from the parent directory, through a `path` repository it adds to `composer.json`.
41-Never commit that repository: `scaleway-package` refuses it, as Scaleway cannot resolve it.43+Never commit that repository nor the lock it writes: `scaleway-package` refuses them, as Scaleway cannot resolve them.
42-Until the first publication, the committed `composer.lock` is the one `link-runtime` writes; once the package is on Packagist, it is regenerated without the repository (`composer update jdecool/scaleway-runtime`) and committed, which makes the example deployable as is.
43 44
44 ```sh45 ```sh
45 cd example46 cd example
46-composer link-runtime47+composer install # or composer link-runtime, for the runtime of this checkout
47 export SCALEWAY_CRON_SECRET=local-secret # lets the Emulator and the scenarios run Command Invocations48 export SCALEWAY_CRON_SECRET=local-secret # lets the Emulator and the scenarios run Command Invocations
48 vendor/bin/scaleway-serve # the Emulator, on http://127.0.0.1:800049 vendor/bin/scaleway-serve # the Emulator, on http://127.0.0.1:8000
49 e2e/run.sh http://127.0.0.1:8000 # in another terminal, with the same SCALEWAY_CRON_SECRET50 e2e/run.sh http://127.0.0.1:8000 # in another terminal, with the same SCALEWAY_CRON_SECRET
@@ -66,8 +67,6 @@ It publishes the runtime of this checkout to that install in place of Packagist,
66 67
67 ## Deploy it68 ## Deploy it
68 69
69-Deploying needs the package on Packagist and the lock regenerated against it, see above: until then, `scaleway-package` refuses the committed lock.
70-The Terraform code is unvalidated: it was written against the `scaleway/scaleway` provider v2.92 documentation and never applied.
71 Set `host` to the function's domain (or a custom domain) for absolute URLs to be right; it cannot default to the function's own `domain_name`, so apply once, then again with `-var host=...`.70 Set `host` to the function's domain (or a custom domain) for absolute URLs to be right; it cannot default to the function's own `domain_name`, so apply once, then again with `-var host=...`.
72 71
73 ```sh72 ```sh
@@ -83,3 +82,9 @@ terraform -chdir=terraform destroy
83 82
84 Rerun `scaleway-package` and `terraform apply` to deploy a new version.83 Rerun `scaleway-package` and `terraform apply` to deploy a new version.
85 Against a deployment, `e2e/run.sh` skips the CRON scenarios, as only the platform triggers CRON Invocations.84 Against a deployment, `e2e/run.sh` skips the CRON scenarios, as only the platform triggers CRON Invocations.
85+Check them in the [logs](../README.md#logs) instead, after the triggers ran (at minutes 0 and 30): each one leaves its line, the second showing that `app:greet` ran as a Command Invocation.
86+
87+```
88+DEBUG - [info] CRON Invocation received with the arguments job source=user stream=stderr
89+DEBUG - [info] Command app:greet said: Hello CRON! source=user stream=stderr
90+```
modified example/terraform/main.tf +1 -1
@@ -1,4 +1,4 @@
1-# Deploys the example application. Unvalidated: written against the scaleway provider docs (v2.92), never applied.
1+# Deploys the example application.
22 # Credentials come from the usual SCW_ACCESS_KEY, SCW_SECRET_KEY and SCW_DEFAULT_PROJECT_ID variables.
33 # Build the zip first: (cd example && vendor/bin/scaleway-package).
44
@@ -1,4 +1,4 @@
1-# Deploys the example application. Unvalidated: written against the scaleway provider docs (v2.92), never applied.1+# Deploys the example application.
2 # Credentials come from the usual SCW_ACCESS_KEY, SCW_SECRET_KEY and SCW_DEFAULT_PROJECT_ID variables.2 # Credentials come from the usual SCW_ACCESS_KEY, SCW_SECRET_KEY and SCW_DEFAULT_PROJECT_ID variables.
3 # Build the zip first: (cd example && vendor/bin/scaleway-package).3 # Build the zip first: (cd example && vendor/bin/scaleway-package).
4 4