Browse the docs

Env doctor checks

putnami cloud env doctor checks 10 prerequisites of an environment. putnami cloud env enable applies the ones your workspace owns. This page lists every check, every step, the output and the exit codes. To use them, read Add an environment.

Commands

Command Does Flags
putnami cloud env doctor [<env>] Prints one check per prerequisite, and the fix of each check that is not ok. It changes nothing. It reads files in your checkout and makes one read request to the platform. --env, --strict, --workspace, --output=json
putnami cloud env enable [<env>] Runs the doctor checks, applies every fix your workspace owns, then reads the checks again. --env, --source-revision <commit>, --workspace, --output=json

Without an environment name, both commands use the environment that your workspace link names, then prod. A name has 1 to 64 letters, digits, ., _ or -.

Check states

State Meaning
ok The prerequisite is met.
failing The prerequisite is missing. The check prints the exact fix. env enable prints this state as missing.
degraded The prerequisite exists but is out of date. The check prints the exact fix.
unknown The check could not run. The detail says why. The check still prints the fix.

The header and the counts include every state that is not ok.

Exit codes

Command Exit 1 when
env doctor A check reads failing. With --strict, also a check that reads degraded or unknown.
env enable A step failed, or a check still reads missing.

Both commands exit 0 otherwise. Exit 0 does not mean the command checked every prerequisite. Read the header, or the metric prerequisites_unchecked in structured output. In CI, use --strict to fail on every check that is not ok.

The checks

The checks run in this order.

Check It needs
put-binding The workspace has an active put namespace binding.
oci-registry putnami.workspace.json sets registries.oci.publish to a host and a namespace, such as oci.putnami.dev/acme.
oci-binding The workspace has an active oci namespace binding, or holds at least one active OCI publisher package share from the workspace that owns the namespace its images publish into.
environment-definition The platform accepted an environment definition that declares this environment. Its workloads and channel match putnami.ci.json at the head of your default branch.
ci-envs putnami.ci.json declares the environment with exact workload paths, each with a putnami.json, and sets distribution.memberAttribution to true.
publish-namespaces Each selected workload with a config schema declares a @putnami/cloud:publish-config namespace. Each one whose build produced a migration bundle declares a @putnami/cloud:publish-migration namespace.
runtime-operation-grants The platform lets its own callers run operations in this workspace.
runtime-binding-grant-config The platform lets its config service use its binding in this workspace.
database-ownership In each database that a selected workload migrates, the role <database>_owner owns every object that the first deploy re-owns. See Database ownership on the first deploy.
project-identity No deployment or database binding is still keyed by the manifest name of a workload instead of its workspace path.

A migration bundle exists only after a build. Run putnami build first when a workload owns migrations.

environment-definition reads degraded

The platform accepted an older revision of putnami.ci.json than the head of your default branch. It deploys the environment from the older revision. The detail names each difference and what it does until you accept the head. For a changed channel, the environment keeps following the old channel, and a move of the new channel deploys nothing. The fix is putnami cloud env enable <env>.

When the platform cannot read the head of your default branch, the check stays ok and the detail says that it did not compare.

When a check reads unknown

Check It reads unknown when
runtime-operation-grants, runtime-binding-grant-config The platform cannot read the grants. It answers only for a signed-in user. A run with a machine token, such as in CI, reads both as unknown. Run the command after putnami cloud login.
runtime-binding-grant-config The platform is not set up with the identity of its config service. You cannot fix this from your workspace.
database-ownership The database does not exist yet, because the first deploy creates it. You do not hold platform.workspace.manage in the workspace, and the fix says to run the command as a manager. The platform cannot read the database. The detail names the reason, and the fix prints a query for each database.
publish-namespaces putnami.ci.json selects no workload for the environment.
project-identity The platform does not know the manifest names of the workloads. The command sends them from your checkout, and it cannot when putnami.ci.json selects no workload.
Every check that asks the platform The command cannot reach the platform or resolve your session. The detail names the failure.

Before the first deploy, the role <database>_owner does not exist yet. database-ownership then reads failing, and the fix says that the first deploy creates the role and re-owns the objects.

Output

The first line gives the state and the counts, then one row per check:

env doctor prod  failing  7 of 10 prerequisites ok, 1 missing, 2 could not be checked

  STATE    CHECK                         DETAIL
  ok       put-binding                   active put namespace acme
  failing  oci-registry                  putnami.workspace.json names no registries.oci.publish with a host and a namespace
                                         fix: set in putnami.workspace.json: "registries": {"oci": {"publish": "oci.putnami.dev/acme"}}
  …

With --output=json, data is the status node. Each check is a child under data.children, with an id such as env.doctor.oci-registry. The counts are under data.metrics: prerequisites_ok, prerequisites_missing, prerequisites_degraded and prerequisites_unchecked. A failed command still carries them.

env enable steps

env enable runs the doctor checks, converges each check that is not ok in the order of the table above, then reads the checks again.

Check What enable does
put-binding, oci-binding Activates the namespace binding under the distribution.namespace of putnami.ci.json.
environment-definition Accepts putnami.ci.json from the head of your repository's default branch, which the platform resolves. Pass --source-revision <commit> (a full commit id) to accept another commit. It never reads your local checkout. The platform then deploys each workload that the definition newly selects, from the release set that the channel points at now.
runtime-operation-grants Lets each platform caller it names operate your services.
runtime-binding-grant-config Lets the platform resolve the config of your services.
oci-registry, ci-envs, publish-namespaces Reported only. These are edits to files in your checkout. The row prints the fix.
database-ownership, project-identity Reported only. The platform or the first deploy converges them. The row prints the fix.

Each step reads applied, skipped, failed or reported. A failed or reported step prints its fix. A failed step does not stop the others.

Enable prod of workspace 0b8f3c9e-…

applied   put-binding                   activated put namespace acme (idempotency key acme-put)
applied   environment-definition        accepted revision 1 at source revision 4f2e… (default-branch head)
skipped   runtime-operation-grants      <caller>@… already enabled at revision 3
reported  database-ownership            not written by this command: objects in acme_shop are owned outside acme_shop_owner
          fix: BEGIN; ALTER TABLE … OWNER TO acme_shop_owner; COMMIT;

1 applied, 0 failed

Environment prod of workspace 0b8f3c9e-…
…

Every write reads the current revision first and sends it as the expected revision. A concurrent change fails the step with the revision moved and is never overwritten. A second run on the same commit finds nothing to do. env enable checks the environment definition again on every run: it replays the commit of the latest revision, and accepts any other commit, even one with the same putnami.ci.json, as a new revision.

The command needs platform.workspace.manage in the workspace. A session without it is refused in one line before any write. A check that could not run is reported and never written, because a write on a guess could apply the wrong fix.

With --output=json, the steps are under data.steps, the counts under data.applied and data.failed, and the checks under data.readiness.

Database ownership on the first deploy

A workload that served before continuous delivery created its database objects as its own login. Its first continuous-delivery deploy re-owns them to <database>_owner, in the schemas public, migration and the schemas of the workload.

The deploy re-owns:

  • schemas;
  • tables, partitioned tables, foreign tables, views, materialized views and sequences;
  • functions, procedures, aggregates and window functions;
  • enum types, composite types and domains.

The deploy does not re-own:

  • range types and base types;
  • members of an extension;
  • routines internal to a type, such as the constructors of a range type;
  • a sequence owned by a table column: it moves with its table;
  • an object whose owner the platform can neither act as nor borrow, such as an object owned by the built-in postgres user or by a password user. The deploy skips it and continues. The check keeps listing it, and the fix says who can re-own it: a superuser, or the platform's database service once it is a member of that owner. A table among these objects still fails the grants of the deploy;
  • every object in a schema that such an owner owns, whoever owns the object. <database>_owner cannot create in that schema, so the deploy skips those objects too. The check lists them as waiting for their schema. The grants of the deploy on that schema still fail until a superuser re-owns it to <database>_owner. The next deploy then adopts the objects.

The deploy grants <database>_app what the default privileges of the owner give: SELECT, INSERT, UPDATE and DELETE on each re-owned table and view, and USAGE and SELECT on each sequence. The migration schema stays read-only for <database>_app.

The login that served before keeps working. A service-account login (…@….iam) that owned at least one table in those schemas is granted <database>_app. A login that owned only a view, a sequence, a routine or a type is not. The grant stays after the old revision is retired. Once no revision serves as that login, revoke the grant as the platform's database service:

REVOKE "<database>_app" FROM "<login>";

Re-owning a table locks it (ACCESS EXCLUSIVE) until the database setup of the deploy commits. The setup waits at most 5 seconds for each lock. When the old revision holds a table longer, the deploy fails instead of making the queries of the old revision wait. The next deploy retries. A later deploy finds nothing to re-own and locks nothing.

Next