-
Notifications
You must be signed in to change notification settings - Fork 1
fix: Add v2 migration and release safeguards #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
casey-coreweave
wants to merge
1
commit into
main
Choose a base branch
from
cabernathy/add-v2-migration-release-safeguards
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| # Migrating from Operator v1 to v2 | ||
|
|
||
| Use this runbook for an existing W&B deployment managed by Operator v1. Treat | ||
| the migration as a controlled cutover: preserve stateful dependencies, run one | ||
| operator controller at a time, and keep a tested rollback path until v2 is | ||
| healthy. | ||
|
|
||
| Operator v2 does not uninstall the v1 Helm releases or modify migration | ||
| metadata inside MySQL or ClickHouse. Those actions can destroy data or make | ||
| rollback impossible and must remain explicit operator decisions. | ||
|
|
||
| ## Before the change window | ||
|
|
||
| 1. Record the v1 operator and W&B Helm release names, namespaces, chart | ||
| versions, values, and current replica counts. | ||
| 2. Back up MySQL, object storage, ClickHouse, and Redis according to the | ||
| provider's restore procedure, and verify that the backups can be read. | ||
| 3. Use `spec.retentionPolicy.onDelete: detach` in the v2 resource while | ||
| validating the migration. Do not delete the v1 resource or uninstall a | ||
| state-owning Helm release as a migration step. | ||
| 4. Inspect the converted `apps.wandb.com/v2` `WeightsAndBiases` resource before | ||
| applying it: | ||
|
|
||
| - Preserve the public `spec.wandb.hostname`. | ||
| - Verify every external infrastructure selector names an existing Secret | ||
| and key. | ||
| - Verify Redis has a non-empty host and port (or a complete URL), not only a | ||
| password. | ||
| - Verify object-store endpoint, bucket, region, TLS, and path-style settings. | ||
| - Remove `status` and other server-populated metadata from a live-resource | ||
| export before applying it as desired state. | ||
|
|
||
| 5. Determine whether the v1 W&B Helm release owns Redis or another dependency | ||
| that v2 will continue using: | ||
|
|
||
| ```bash | ||
| helm get manifest <v1-wandb-release> -n <wandb-namespace> | ||
| kubectl get statefulset,service,pvc -n <wandb-namespace> | ||
| ``` | ||
|
|
||
| If the release owns Redis, keep that release installed until Redis has been | ||
| migrated to an external service or rehomed outside the release's ownership. | ||
| Pointing v2 at the v1 Redis Service does not make it safe to uninstall the | ||
| v1 release. | ||
|
|
||
| ## Enter single-controller mode | ||
|
|
||
| Do not let Operator v1 and v2 reconcile the same W&B deployment concurrently. | ||
| The v1 controller can restore legacy values or Secrets while v2 is trying to | ||
| apply the converted configuration. | ||
|
|
||
| 1. Identify the v1 controller Deployment from its Helm release and save its | ||
| replica count. | ||
| 2. Scale that Deployment to zero. | ||
| 3. Confirm no v1 controller pods remain before applying the v2 resource. | ||
|
|
||
| For example: | ||
|
|
||
| ```bash | ||
| kubectl -n <v1-operator-namespace> scale \ | ||
| deployment/<v1-controller-deployment> --replicas=0 | ||
| kubectl -n <v1-operator-namespace> get pods | ||
| ``` | ||
|
|
||
| Do not uninstall the v1 operator yet. Leaving the release installed makes the | ||
| controller rollback reversible. | ||
|
|
||
| ## Install Operator v2 and apply the resource | ||
|
|
||
| Pin a reviewed version from the Operator v2 OCI repository: | ||
|
|
||
| ```bash | ||
| helm upgrade --install wandb-operator \ | ||
| oci://us-docker.pkg.dev/wandb-production/public/wandb/charts/operator \ | ||
| --version <operator-version> \ | ||
| --namespace <v2-operator-namespace> \ | ||
| --create-namespace | ||
|
|
||
| kubectl apply -f <weightsandbiases-v2.yaml> | ||
| ``` | ||
|
|
||
| The `wandb/operator` chart in `charts.wandb.ai` is Operator v1 and is not an | ||
| Operator v2 upgrade source. | ||
|
|
||
| The v2 chart installs and upgrades its CRDs with server-side apply. If the CRD | ||
| installer Job fails, inspect that Job and resolve the ownership or RBAC error; | ||
| do not delete existing CRDs as a recovery shortcut. | ||
|
|
||
| ## Wait for the cutover gates | ||
|
|
||
| Applications are gated on infrastructure readiness, MySQL initialization, and | ||
| the W&B migration Jobs. Do not switch traffic or remove v1 workloads until all | ||
| of these checks pass: | ||
|
|
||
| ```bash | ||
| kubectl -n <wandb-namespace> get wandb <wandb-name> -o yaml | ||
| kubectl -n <wandb-namespace> get jobs \ | ||
| -l app.kubernetes.io/instance=<wandb-name>,app.kubernetes.io/component=migration | ||
| kubectl -n <wandb-namespace> get applications | ||
| kubectl -n <wandb-namespace> get deployments | ||
| ``` | ||
|
|
||
| Confirm: | ||
|
|
||
| - Every configured infrastructure status is ready. | ||
| - `status.wandb.migration.ready` is `true`, its version matches | ||
| `spec.wandb.version`, and every migration Job succeeded. | ||
| - Every v2 application Deployment is fully rolled out with available replicas. | ||
| - The public route targets the intended v2 Services and no longer returns | ||
| transient 5xx responses. | ||
|
|
||
| If a migration Job fails, collect its status and logs: | ||
|
|
||
| ```bash | ||
| kubectl -n <wandb-namespace> describe job/<migration-job> | ||
| kubectl -n <wandb-namespace> logs job/<migration-job> -c migrate | ||
| ``` | ||
|
|
||
| Do not infer migration success from a similarly named Deployment. Do not | ||
| automatically clear `partially_applied_version` or edit migration tables: that | ||
| requires a migration-specific recovery decision and a verified backup. | ||
|
|
||
| ## Smoke test before cleanup | ||
|
|
||
| Run the tests through the customer-facing hostname: | ||
|
|
||
| 1. Sign in and load the main UI. | ||
| 2. Create an SDK run using an existing, valid entity. | ||
| 3. Upload and download an artifact through the SDK. | ||
| 4. Download the artifact in a browser using the presigned URL. | ||
| 5. Check the browser request for the expected external object-store endpoint, | ||
| trusted TLS, and successful CORS headers. | ||
| 6. Exercise Runs and Weave views used by the deployment. | ||
|
|
||
| An SDK upload alone is not sufficient for S3-compatible storage. Browser | ||
| downloads can still fail when the external endpoint or CORS policy is wrong. | ||
|
|
||
| ## Retire v1 in the safe order | ||
|
|
||
| 1. Keep the v1 controller at zero replicas. | ||
| 2. Verify the v2 route and workloads remain healthy for the agreed observation | ||
| period. | ||
| 3. Inventory remaining v1 Deployments and scale any that are still serving | ||
| traffic to zero. Operator v2 removes the known legacy `*-bc` Deployments | ||
| only after all desired v2 Deployments are ready; verify rather than assume | ||
| that all v1 workloads are covered. | ||
| 4. Uninstall the v1 operator release only after the rollback window no longer | ||
| requires it. | ||
| 5. Uninstall the v1 W&B release only after confirming it owns no Redis, | ||
| database, object-store, ClickHouse, PVC, Secret, or other resource still | ||
| used by v2. | ||
|
|
||
| Never uninstall the v1 W&B release while v2 still references its Helm-owned | ||
| Redis. The uninstall deletes the Redis workload even if the v2 resource calls | ||
| it "external." | ||
|
|
||
| ## Rollback | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if we want to have a rollback path we may need to disable some features on v2, or data created after the upgrade may not be complete. |
||
|
|
||
| Rollback must also use one controller at a time: | ||
|
|
||
| 1. Stop traffic to the v2 workloads or restore the previous route. | ||
| 2. Scale the v2 operator controller to zero. | ||
| 3. Restore the saved v1 configuration and workload replica counts. | ||
| 4. Scale the v1 operator controller back to its saved replica count. | ||
| 5. Verify database compatibility before rolling the W&B application version | ||
| back; a completed forward migration may not be reversible by changing only | ||
| the image tag. | ||
| 6. Re-run the UI, SDK, artifact, and browser-download smoke tests. | ||
|
|
||
| Do not delete the v2 resource or its dependencies during rollback. Keep them | ||
| detached until the incident is understood and the retained data is no longer | ||
| needed. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that we want to advise even deploying them side by side, in my testing I applied the operator v2 helm chart as an upgrade over the v1 helm release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might requires some pre-upgrade steps to make sure that all the resources are annotated correctly for the transition, but it might be cleaner