Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
94f0cf9
DEVOPS-3406 - Update hook-delete-policy for migration Job and RBAC to…
raul-gherman-modaoperandi Sep 15, 2026
ca4b3a3
DEVOPS-3406 - Add explicit hook-delete-policy for ExternalSecret and …
raul-gherman-modaoperandi Sep 15, 2026
e5da1a7
DEVOPS-3406 - Update createNamespace default to false and enhance REA…
raul-gherman-modaoperandi Sep 15, 2026
b76f616
DEVOPS-3406 - address Copilot review comments (valid) [2]
raul-gherman-modaoperandi Sep 15, 2026
0bea883
DEVOPS-3406 - address Copilot review comments (valid) [3]
raul-gherman-modaoperandi Sep 15, 2026
1d7fadb
DEVOPS-3406 - Enhance namespace handling in Helm chart
raul-gherman-modaoperandi Sep 15, 2026
543b2c7
DEVOPS-3406 - address Copilot review comments (valid) [4]
raul-gherman-modaoperandi Sep 15, 2026
dfcbc5d
DEVOPS-3406 - address Copilot review comments (valid) [5]
raul-gherman-modaoperandi Sep 15, 2026
ba59a74
DEVOPS-3406 - address Copilot review comments (valid) [6]
raul-gherman-modaoperandi Sep 15, 2026
e92ca46
DEVOPS-3406 - address Copilot review comments (valid) [6]
raul-gherman-modaoperandi Sep 15, 2026
cc94430
Update resource-policy check in namespace.yaml
raul-gherman-modaoperandi Sep 15, 2026
1618e26
DEVOPS-3406 - add AGENTS.md (first take)
raul-gherman-modaoperandi Sep 17, 2026
d18e0eb
DEVOPS-3406 - clarify ArgoCD namespace migration note
Copilot Sep 17, 2026
c219d5b
Add error handling for existing namespace in Helm template
raul-gherman-modaoperandi Sep 17, 2026
d05af08
DEVOPS-3406 guard ambiguous Argo namespace migration path
Copilot Sep 17, 2026
0a23a28
DEVOPS-3406 gate namespace lookup
Copilot Sep 17, 2026
86ecf78
DEVOPS-3406 require explicit ack for no-lookup namespace omission
Copilot Sep 17, 2026
1111962
Add namespace migration regression check
Copilot Sep 17, 2026
eb0c2be
DEVOPS-3406 limit namespace guard to upgrade renders
Copilot Sep 17, 2026
21b963b
DEVOPS-3406 add explicit GitOps namespace migration path
Copilot Sep 17, 2026
76aa14f
DEVOPS-3406 document explicit GitOps namespace migration
Copilot Sep 17, 2026
5915039
DEVOPS-3406 remove unreachable namespace fail branch
Copilot Sep 17, 2026
13928f9
DEVOPS-3406 align namespace migration docs with template
Copilot Sep 17, 2026
65a3e8a
DEVOPS-3406 finalize namespace migration docs
Copilot Sep 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/docs/start-here/self-host.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ For Kubernetes installs, use the published Helm chart:
```bash
helm upgrade --install openwork-ee oci://ghcr.io/different-ai/charts/openwork-ee \
--version <chart-version> \
--namespace openwork \
--create-namespace \
-f values.prod.yaml
```

Expand Down
65 changes: 65 additions & 0 deletions packaging/helm/openwork-ee/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# AGENTS.md

Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.

**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.

## 1. Think Before Coding

**Don't assume. Don't hide confusion. Surface tradeoffs.**

Before implementing:
- State your assumptions explicitly. If uncertain, ask.
- If multiple interpretations exist, present them - don't pick silently.
- If a simpler approach exists, say so. Push back when warranted.
- If something is unclear, stop. Name what's confusing. Ask.

## 2. Simplicity First

**Minimum code that solves the problem. Nothing speculative.**

- No features beyond what was asked.
- No abstractions for single-use code.
- No "flexibility" or "configurability" that wasn't requested.
- No error handling for impossible scenarios.
- If you write 200 lines and it could be 50, rewrite it.

Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.

## 3. Surgical Changes

**Touch only what you must. Clean up only your own mess.**

When editing existing code:
- Don't "improve" adjacent code, comments, or formatting.
- Don't refactor things that aren't broken.
- Match existing style, even if you'd do it differently.
- If you notice unrelated dead code, mention it - don't delete it.

When your changes create orphans:
- Remove imports/variables/functions that YOUR changes made unused.
- Don't remove pre-existing dead code unless asked.

The test: Every changed line should trace directly to the user's request.

## 4. Goal-Driven Execution

**Define success criteria. Loop until verified.**

Transform tasks into verifiable goals:
- "Add validation" → "Write tests for invalid inputs, then make them pass"
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
- "Refactor X" → "Ensure tests pass before and after"

For multi-step tasks, state a brief plan:
```
1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]
```

Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.

---

**These guidelines are working if:** fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.
167 changes: 165 additions & 2 deletions packaging/helm/openwork-ee/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Published releases are available as an OCI Helm chart:
```bash
helm upgrade --install openwork-ee oci://ghcr.io/different-ai/charts/openwork-ee \
--version REPLACE_OPENWORK_VERSION \
--namespace openwork \
--create-namespace \
-f values.prod.yaml
```

Expand Down Expand Up @@ -112,6 +114,138 @@ When applying rendered manifests directly, create the namespace first
(`kubectl create namespace openwork`) since Helm does not create it for you in
that flow.

### Namespace creation under ArgoCD

`createNamespace` (default `false`) controls whether the chart renders its own
`Namespace` object, as the earliest `pre-install,pre-upgrade` hook. It
defaults to `false` because it is unnecessary for the recommended `helm
install`/`helm upgrade --create-namespace` workflow (the CLI flag creates the
namespace itself, before this chart or any of its hooks ever render) and
actively dangerous under ArgoCD (below).

**This hook cannot help a first install into a not-yet-existing *release*
namespace** (the one passed via `helm install --namespace`): Helm creates its
own release-tracking record in that namespace before running any hook, so if
it does not already exist and `--create-namespace` was not passed, the
install fails immediately (`failed to create: namespaces "x" not found`)
before this or any pre-install hook ever runs — pre-provision that namespace
or pass `--create-namespace` regardless of this setting. Enable
`createNamespace` only when the Helm release namespace already exists (or is
a separate namespace altogether, e.g. a shared ops namespace) but this
chart's own `namespace` value points at a *different*, not-yet-existing
target namespace that this hook creates.

When enabled for that scenario as a genuine `helm install`/`helm upgrade` CLI
run, it is safe: the chart uses Helm's `lookup` function to detect an
already-existing namespace and skips rendering the hook entirely on every
upgrade after the first install.

**This safety check does not work under ArgoCD**, which is why the default is
`false` rather than relying on every consumer to override it. ArgoCD renders
charts with `helm template` in its repo-server, which has no live cluster
connection, so `lookup` always returns empty there — if `createNamespace` were
enabled, the Namespace hook would render on every single sync,
unconditionally. Helm and ArgoCD both document that a hook without an explicit
`hook-delete-policy` defaults to `before-hook-creation` (delete the previous
resource, then create a new one), and deleting a Namespace cascades to delete
everything inside it. Enabling `createNamespace` under ArgoCD would mean the
**entire release** — Deployments, Secrets, everything — gets torn down and
rebuilt on every sync.

Leave `createNamespace` at its default (`false`) for any ArgoCD `Application`
and instead let ArgoCD create the namespace itself:

```yaml
# Application values
createNamespace: false # the default — shown for clarity, not required
```

```yaml
# Application spec
syncPolicy:
syncOptions:
- CreateNamespace=true
```

This is a native, non-hook, one-time ArgoCD operation with no delete-then-recreate
lifecycle, so the namespace (and everything in it) is created once and then
left alone by subsequent syncs.

The Namespace's hook-ness does not vary with `migrations.hook` (see
"Migrations" below): reclassifying the *same* resource between a hook and a
plain manifest across upgrades is unsafe in both directions, confirmed
against a live cluster — presenting an existing hook-created resource as an
ordinary one hard-fails the upgrade outright (`exists and cannot be imported
into the current release: invalid ownership metadata`, since hook-created
resources never receive Helm's release-ownership labels), and presenting an
existing ordinary resource as a hook for the first time deletes it before the
new hook's own annotations ever apply, cascading to everything inside —
confirmed by watching a canary resource get wiped out even though the new
hook render already carried `resource-policy: keep`.

Given that, this chart automatically detects and never disturbs a Namespace
that is already safe, and on direct Helm runs with live-cluster `lookup`
access safely migrates the one population that is not — without requiring
`createNamespace: true`, which matters because this same chart version also
flips that default from `true` to `false` (see above). For no-lookup renders
such as ArgoCD, that legacy plain-Namespace migration is not automatic: use
the explicit `migrateLegacyPlainNamespace=true` one-release path described
below before letting the chart omit the Namespace.

Using `lookup` to check the *live* object on the explicit
`createNamespace=true` path, this chart:

- Omits rendering entirely if the looked-up Namespace already carries either
`helm.sh/hook` or `helm.sh/resource-policy: keep`. The first covers the
common case of a release that predates this file, where the Namespace was
already a hook under the old default (`migrations.hook: true`) and was never
actually at risk (hook resources are never tracked by a release the way
ordinary ones are, so re-rendering as a hook here would only reintroduce the
very delete-then-create risk this logic exists to avoid — confirmed
empirically, that reclassification is what deletes it); the second covers a
Namespace an earlier release already migrated.
- Otherwise, if `createNamespace=true` and the Namespace exists, carries
neither marker, and is already owned by *this* Helm release (its
`meta.helm.sh/release-name` and `meta.helm.sh/release-namespace`
annotations match this release, and it carries the
`app.kubernetes.io/managed-by: Helm` label — the same ownership stamp Helm
itself checks before agreeing to manage a pre-existing resource, confirmed
empirically to be present on any chart-rendered resource and absent from one
created via `--create-namespace` or plain `kubectl`): renders it as a plain,
non-hook manifest that only adds the missing annotation, never
reclassifying it, which Helm applies as an ordinary same-kind,
already-owned in-place update. This is the legacy-migration case for direct
Helm runs that keep `createNamespace=true`.
- Only creates a brand-new Namespace (as the earliest hook) when
`createNamespace=true` and nothing exists live at all.
- If `createNamespace=false`, the chart skips that live-cluster `lookup` path
entirely and omits the Namespace by default. For the legacy GitOps /
no-lookup migration case, set `migrateLegacyPlainNamespace=true` for one
release so the chart renders a plain Namespace with both
`helm.sh/resource-policy: keep` and ArgoCD `Prune=false` before later
omission.
Comment on lines +221 to +226
- Otherwise, when `createNamespace=true` and the existing Namespace is owned
by neither this release nor either marker (created entirely outside Helm,
e.g. manually, via `--create-namespace`, or by ArgoCD's own
`CreateNamespace=true`), the chart fails rather than silently adopting or
destroying a namespace this release does not own.

`helm.sh/resource-policy: keep` itself states plainly (per Helm's docs) that
it "instructs Helm to skip deleting this resource when a helm operation
(such as `helm uninstall`, `helm upgrade` or `helm rollback`) would result in
its deletion" — checked against the live object's current annotations, not
the newly-rendered manifest. Once stamped, the *next* release finds the
marker already present and skips rendering the Namespace entirely from then
on too, exactly like the lookup-skip this file has always used for fresh
installs. For direct Helm upgrades, that lookup-based migration only runs on
the `createNamespace=true` path. If a legacy release still needs the plain
Namespace migration while `createNamespace=false` (including the new default),
set `migrateLegacyPlainNamespace=true` for one upgrade so the chart renders
the plain Namespace with both `helm.sh/resource-policy: keep` and ArgoCD
`Prune=false`, or add equivalent protection another way, before later omission.
The direct Helm `createNamespace=true` path and the explicit
`migrateLegacyPlainNamespace=true` render were both verified separately.

### Upgrade note: public URL values

Current chart versions make `config.public.webOrigin` the primary public URL.
Expand Down Expand Up @@ -154,7 +288,10 @@ For local development from a repository checkout, render or install directly:

```bash
helm template openwork-ee ./packaging/helm/openwork-ee -f values.prod.yaml
helm upgrade --install openwork-ee ./packaging/helm/openwork-ee -f values.prod.yaml
helm upgrade --install openwork-ee ./packaging/helm/openwork-ee \
--namespace openwork \
--create-namespace \
-f values.prod.yaml
```

### Automations rollout
Expand Down Expand Up @@ -1001,7 +1138,7 @@ The migration Job runs as a Helm `pre-install,pre-upgrade` hook by default:
migrations:
enabled: true
hook: true
hookDeletePolicy: before-hook-creation,hook-succeeded
hookDeletePolicy: before-hook-creation,hook-succeeded,hook-failed
command:
- node
args:
Expand All @@ -1010,6 +1147,32 @@ migrations:

The default hook executes the precompiled Den DB bootstrap runner already built into the Den API image. On a completely empty database it applies the build-time current-schema SQL snapshot, records the committed migrations as the baseline, then runs pending migrations with Drizzle ORM. On an existing schema without a Drizzle ledger, it records the baseline before migrating.

`hookDeletePolicy` keeps `hook-failed` alongside the defaults: a Job's pod
template is immutable, so `before-hook-creation` gives each hook run a clean
slate by deleting the previous instance first, but a **failed** run without
`hook-failed` used to sit around until the *next* sync's `before-hook-creation`
delete tried to clear it — and if that delete raced ArgoCD's own automated-sync
retry timing, the Job (and, via ArgoCD's `hook-finalizer`, the namespace behind
it) could get stuck `Terminating` indefinitely. `hook-failed` deletes it
immediately instead, well clear of the next sync attempt. The migration RBAC
(`ServiceAccount`/`Role`/`RoleBinding`) and the `ExternalSecret` hooks also
carry `before-hook-creation` explicitly — Helm and ArgoCD both document that
this is the default applied to any hook without an explicit
`hook-delete-policy` anyway, so leaving it off would not change behavior, only
leave it undocumented. It is tolerable for these leaf, non-cascading resources
(no finalizers, so the delete completes essentially instantly, and the
ExternalSecret's `target.deletionPolicy: Retain` protects the materialized
Secret regardless). It is *not* tolerable for the Namespace hook, because
deleting a Namespace cascades to everything inside it — see "Namespace
creation under ArgoCD" above for why that one needs a different fix entirely
(`createNamespace: false` plus ArgoCD's own `syncOptions: [CreateNamespace=true]`),
not an annotation choice.

`migrations.hook` only ever affects the ExternalSecret, migration RBAC, and
migration Job above — it never affects the Namespace (see "Namespace creation
under ArgoCD"), which is always a hook whenever `createNamespace` is true,
independent of this value.

For retained-log troubleshooting, temporarily disable hook behavior and reduce
retries:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# hostnames, run helm upgrade again, and then validate browser auth. Prefer the
# HTTPS/ACM example for production.

# Must match the --namespace above: with createNamespace at its chart default
# (false), nothing else creates this namespace, and --create-namespace only
# creates the one the Helm release itself lives in.
namespace: openwork-ee

image:
tag: "REPLACE_OPENWORK_VERSION"
pullPolicy: IfNotPresent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
# Balancers created from Kubernetes Services. Use it for the first AWS smoke
# test and for installs where separate web/API hostnames are acceptable.

# Must match the --namespace above: with createNamespace at its chart default
# (false), nothing else creates this namespace, and --create-namespace only
# creates the one the Helm release itself lives in.
namespace: openwork-ee

image:
tag: "REPLACE_OPENWORK_VERSION"
pullPolicy: IfNotPresent
Expand Down
5 changes: 5 additions & 0 deletions packaging/helm/openwork-ee/examples/values.azure-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# add-on's managed NGINX Ingress controller. Use it for production-like Azure
# tests where browser auth and SSO need stable HTTPS hostnames.

# Must match the --namespace above: with createNamespace at its chart default
# (false), nothing else creates this namespace, and --create-namespace only
# creates the one the Helm release itself lives in.
namespace: openwork-ee

image:
tag: "REPLACE_OPENWORK_VERSION"
pullPolicy: IfNotPresent
Expand Down
5 changes: 5 additions & 0 deletions packaging/helm/openwork-ee/examples/values.gcp-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
# global IP and Google-managed certificate. Apply the ManagedCertificate and
# BackendConfig manifests from docs/gcp-gke-helm.md before installing.

# Must match the --namespace above: with createNamespace at its chart default
# (false), nothing else creates this namespace, and --create-namespace only
# creates the one the Helm release itself lives in.
namespace: openwork-ee

image:
tag: "REPLACE_OPENWORK_VERSION"
pullPolicy: IfNotPresent
Expand Down
13 changes: 13 additions & 0 deletions packaging/helm/openwork-ee/templates/externalsecret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ metadata:
ExternalSecret must apply first so ESO can start materializing the Secret
the Job consumes. Weight -10 precedes the Job's -5. ArgoCD maps these to
PreSync the same way, so GitOps installs get the same ordering.

before-hook-creation is explicit here even though it is also Helm's and
Argo CD's documented default for an unannotated hook (Argo CD: "if no
deletion policy is specified, Argo CD will automatically assume
BeforeHookCreation rules") — omitting the annotation does not disable
delete-then-create, it renders it implicitly. That default is tolerable
here: this is a leaf, non-cascading resource with no finalizer, so the
delete completes near-instantly; and target.deletionPolicy defaults to
Retain, so even a brief gap between the old ExternalSecret's deletion and
the new one's creation never deletes the materialized Secret workloads
read from. Contrast the Namespace hook (templates/namespace.yaml), where
the very same default is dangerous because deleting it cascades to every
resource inside — see that file's comment for the real mitigation.
*/}}
{{- if .Values.migrations.hook }}
annotations:
Expand Down
11 changes: 11 additions & 0 deletions packaging/helm/openwork-ee/templates/migration-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
instead of failing on the env secretKeyRef. Rendered only outside inline
mode. In hook mode these must be hooks with an earlier weight than the Job
(-6 precedes the Job's -5) so they exist before it starts.

before-hook-creation is explicit here even though it is also Helm's and
Argo CD's documented default for an unannotated hook (Argo CD: "if no
deletion policy is specified, Argo CD will automatically assume
BeforeHookCreation rules") — omitting the annotation does not disable
delete-then-create, it renders it implicitly. That default is tolerable for
these three: they are leaf, non-cascading RBAC objects with no finalizers,
so the delete completes near-instantly and the following create rarely (if
ever) collides. Contrast the Namespace hook (templates/namespace.yaml),
where the very same default is dangerous because deleting it cascades to
every resource inside — see that file's comment for the real mitigation.
*/}}
{{- /* Runs the legacy create=false shim before the secretsMode check below. */}}
{{- include "openwork-ee.secretsMode.validate" . }}
Expand Down
Loading