Skip to content

Commit 8ec3a45

Browse files
change to v1 instead of v1alpha2 for new version of CRD
1 parent b1b669a commit 8ec3a45

8 files changed

Lines changed: 115 additions & 115 deletions

File tree

ci/nightly/pipeline.template.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,15 +2439,15 @@ steps:
24392439
agents:
24402440
queue: hetzner-aarch64-16cpu-32gb
24412441

2442-
- id: orchestratord-v1alpha2-opt-in
2443-
label: "Orchestratord v1alpha2 opt-in tests"
2442+
- id: orchestratord-v1-opt-in
2443+
label: "Orchestratord v1 opt-in tests"
24442444
artifact_paths: ["mz_debug_*.zip"]
24452445
depends_on: devel-docker-tags
24462446
timeout_in_minutes: 120
24472447
plugins:
24482448
- ./ci/plugins/mzcompose:
24492449
composition: orchestratord
2450-
run: v1alpha2-opt-in
2450+
run: v1-opt-in
24512451
ci-builder: stable
24522452
agents:
24532453
queue: hetzner-aarch64-16cpu-32gb

doc/developer/design/20260209_simplified_rollout_triggers_and_crd.md

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Additionally, the current system is difficult to automate when faced with evicti
1919

2020
1. **Automatic rollout detection**: The system should automatically detect when a rollout is needed based on spec changes, without requiring users to manually set a UUID.
2121

22-
2. **Seamless version migration**: Existing v1alpha1 resources should continue to work, with automatic conversion to v1alpha2 as needed.
22+
2. **Seamless version migration**: Existing v1alpha1 resources should continue to work, with automatic conversion to v1 as needed.
2323

2424
3. **Terraform compatibility**: Configuration must not fight with infrastructure as code tools such as Terraform.
2525

@@ -34,9 +34,9 @@ Additionally, the current system is difficult to automate when faced with evicti
3434

3535
## Solution Proposal
3636

37-
### 1. New CRD Version: v1alpha2
37+
### 1. New CRD Version: v1
3838

39-
Introduce a new `v1alpha2` version of the Materialize CRD with the following changes:
39+
Introduce a new `v1` version of the Materialize CRD with the following changes:
4040

4141
**Spec changes:**
4242
- Remove `requestRollout` (`Uuid`) - Rollouts are now triggered automatically when the spec hash changes.
@@ -122,14 +122,14 @@ A new HTTPS webhook server handles CRD version conversion:
122122
**Endpoint:** `POST /convert`
123123

124124
**Supported conversions:**
125-
- v1alpha1 -> v1alpha2
126-
- v1alpha2 -> v1alpha1\*
125+
- v1alpha1 -> v1
126+
- v1 -> v1alpha1\*
127127

128128
\*The API server seemed to want this, I don't know why. We can't reconcile these, so going back never makes sense.
129129

130130
**Key conversion logic:**
131131

132-
###### v1alpha1 to v1alpha2:
132+
###### v1alpha1 to v1:
133133
- Spec fields:
134134
- `forcePromote: Uuid` becomes `forcePromote: Option<String>` (nil UUID becomes None)
135135
- `requestRollout` is removed.
@@ -144,52 +144,52 @@ A new HTTPS webhook server handles CRD version conversion:
144144
- If we are already in "promoting" status, we should unconditionally complete the promotion for the current rollout rather than destroying and replacing it.
145145
This may trigger an additional rollout this one time, but I don't know any way around that. I think this is acceptable given the user is doing something very weird by updating orchestratord mid-rollout.
146146

147-
###### v1alpha2 to v1alpha1:
147+
###### v1 to v1alpha1:
148148

149-
We need to include the `lastCompletedRolloutHash` from v1alpha2 in v1alpha1 as well. This is required for round tripping from v1alpha2 -> v1alpha1 -> v1alpha2,
150-
which may happen if a user applies a v1alpha1 change over a v1alpha2 object.
149+
We need to include the `lastCompletedRolloutHash` from v1 in v1alpha1 as well. This is required for round tripping from v1 -> v1alpha1 -> v1,
150+
which may happen if a user applies a v1alpha1 change over a v1 object.
151151

152-
In the case there is an existing `lastCompletedRolloutHash`, it should be kept as-is through the round trip. As we never reconcile with v1alpha1, it should only change at v1alpha2, so this should be safe.
152+
In the case there is an existing `lastCompletedRolloutHash`, it should be kept as-is through the round trip. As we never reconcile with v1alpha1, it should only change at v1, so this should be safe.
153153

154-
No attempt is made to support v1alpha1 beyond giving a valid v1alpha1 structure and supporting round tripping to v1alpha2. Fields that do not exist in v1alpha2 may have their nil value.
154+
No attempt is made to support v1alpha1 beyond giving a valid v1alpha1 structure and supporting round tripping to v1. Fields that do not exist in v1 may have their nil value.
155155

156156
##### Example round trips
157157

158-
In these examples, we assume that orchestratord's attempt to update the stored version succeeds and that reconciliation is triggered after this update. This is only to simplify this document, and is not necessary for correctness. If orchestratord's attempt to update the stored version fails, or the reconciliation is triggered first, the conversion webhook is simply called at that time and we will reconcile the same v1alpha2 object.
158+
In these examples, we assume that orchestratord's attempt to update the stored version succeeds and that reconciliation is triggered after this update. This is only to simplify this document, and is not necessary for correctness. If orchestratord's attempt to update the stored version fails, or the reconciliation is triggered first, the conversion webhook is simply called at that time and we will reconcile the same v1 object.
159159

160160
###### Simplest case
161161
1. There is a stored v1alpha1 Materialize resource, not actively rolling out, with both `status.lastCompletedRolloutRequest` and `spec.requestRollout` matching.
162-
1. Orchestratord gets updated to a version with v1alpha2 support.
163-
1. Orchestratord lists existing v1alpha1 resources on startup, in order to upgrade them to v1alpha2.
164-
1. The API server calls the conversion webhook, which returns a v1alpha2 resource. In this case, it would have `status.lastCompletedRolloutHash` and `status.requestedRolloutHash` set to the same calculated hash after conversion.
165-
1. Orchestratord calls `replace` to store the resource as v1alpha2.
166-
1. Orchestratord gets notified of the new v1alpha2 resource, but determines there is nothing to do.
162+
1. Orchestratord gets updated to a version with v1 support.
163+
1. Orchestratord lists existing v1alpha1 resources on startup, in order to upgrade them to v1.
164+
1. The API server calls the conversion webhook, which returns a v1 resource. In this case, it would have `status.lastCompletedRolloutHash` and `status.requestedRolloutHash` set to the same calculated hash after conversion.
165+
1. Orchestratord calls `replace` to store the resource as v1.
166+
1. Orchestratord gets notified of the new v1 resource, but determines there is nothing to do.
167167

168-
At this point, the stored version is v1alpha2, and no rollout is triggered.
168+
At this point, the stored version is v1, and no rollout is triggered.
169169

170170
1. The user then applies a v1alpha1 resource. It contains some change that affects the hash (ie: `spec.environmentd_image_ref`). It may or may not include `spec.requestRollout`, that doesn't matter.
171-
1. Before storing this change, the API server calls the conversion webhook, which returns a v1alpha2 resource. In this case, it should not contain a status, as the user applied v1alpha1 resource did not contain a status (TODO verify this).
172-
1. Orchestratord gets notified of the new v1alpha2 resource, which contains the old status not yet updated after the applied v1alpha1 resource. This means the `status.lastCompletedRolloutHash` and `status.requestedRolloutHash` still match each other, but do not match the calculated hash.
171+
1. Before storing this change, the API server calls the conversion webhook, which returns a v1 resource. In this case, it should not contain a status, as the user applied v1alpha1 resource did not contain a status (TODO verify this).
172+
1. Orchestratord gets notified of the new v1 resource, which contains the old status not yet updated after the applied v1alpha1 resource. This means the `status.lastCompletedRolloutHash` and `status.requestedRolloutHash` still match each other, but do not match the calculated hash.
173173
1. Orchestratord reconciles like normal, calculating a new `status.requestedRolloutHash` and triggering a rollout since it is different.
174174

175-
If the user had instead applied a v1alpha2 resource instead, no conversion would be needed and orchestratord would reconcile it directly.
175+
If the user had instead applied a v1 resource instead, no conversion would be needed and orchestratord would reconcile it directly.
176176

177177
###### Existing v1alpha1 resource is mid-upgrade, but not promoting
178178
1. There is a stored v1alpha1 Materialize resource, actively rolling out, with `status.lastCompletedRolloutRequest` and `spec.requestRollout` not matching. It is not in "promoting" status.
179-
1. Orchestratord gets updated to a version with v1alpha2 support.
180-
1. Orchestratord lists existing v1alpha1 resources on startup, in order to upgrade them to v1alpha2.
181-
1. The API server calls the conversion webhook, which returns a v1alpha2 resource. In this case, it would have `status.lastCompletedRolloutHash` set to `None` and `status.requestedRolloutHash` set to the calculated hash after conversion.
182-
1. Orchestratord calls `replace` to store the resource as v1alpha2.
183-
1. Orchestratord gets notified of the new v1alpha2 resource.
179+
1. Orchestratord gets updated to a version with v1 support.
180+
1. Orchestratord lists existing v1alpha1 resources on startup, in order to upgrade them to v1.
181+
1. The API server calls the conversion webhook, which returns a v1 resource. In this case, it would have `status.lastCompletedRolloutHash` set to `None` and `status.requestedRolloutHash` set to the calculated hash after conversion.
182+
1. Orchestratord calls `replace` to store the resource as v1.
183+
1. Orchestratord gets notified of the new v1 resource.
184184
1. Orchestratord reconciles like normal, continuing the existing rollout and overwriting any objects that are different. This is the same behavior it would have with current orchestratord and v1alpha1.
185185

186186
###### Existing v1alpha1 resource is mid-upgrade and already promoting
187187
1. There is a stored v1alpha1 Materialize resource, actively rolling out, with `status.lastCompletedRolloutRequest` and `spec.requestRollout` not matching. It is in "promoting" status.
188-
1. Orchestratord gets updated to a version with v1alpha2 support.
189-
1. Orchestratord lists existing v1alpha1 resources on startup, in order to upgrade them to v1alpha2.
190-
1. The API server calls the conversion webhook, which returns a v1alpha2 resource. In this case, it would have `status.lastCompletedRolloutHash` set to `None` and `status.requestedRolloutHash` set to the calculated hash after conversion.
191-
1. Orchestratord calls `replace` to store the resource as v1alpha2.
192-
1. Orchestratord gets notified of the new v1alpha2 resource.
188+
1. Orchestratord gets updated to a version with v1 support.
189+
1. Orchestratord lists existing v1alpha1 resources on startup, in order to upgrade them to v1.
190+
1. The API server calls the conversion webhook, which returns a v1 resource. In this case, it would have `status.lastCompletedRolloutHash` set to `None` and `status.requestedRolloutHash` set to the calculated hash after conversion.
191+
1. Orchestratord calls `replace` to store the resource as v1.
192+
1. Orchestratord gets notified of the new v1 resource.
193193
1. Orchestratord reconciles like normal. Critically, it unconditionally continues with promotion rather than overwriting any objects.
194194
1. After promotion is successful, the updated status triggers a new rollout. (TODO verify that this works if we have a `status.requestedRolloutHash` set in the initial conversion)
195195

@@ -216,8 +216,8 @@ Orchestratord will also get readiness probes so nothing tries to call this webho
216216
### 5. CRD Registration
217217

218218
The CRD is registered with:
219-
- Both v1alpha1 and v1alpha2 versions
220-
- v1alpha2 as the stored version
219+
- Both v1alpha1 and v1 versions
220+
- v1 as the stored version
221221
- Webhook conversion configuration pointing to the operator service
222222

223223
```rust
@@ -241,7 +241,7 @@ mz_crd.spec.conversion = Some(CustomResourceConversion {
241241

242242
### 6. Replace all Materialize resources to update their stored versions
243243

244-
We have set v1alpha2 as the stored version, but that doesn't update existing resources. Those are only updated when they are reapplied.
244+
We have set v1 as the stored version, but that doesn't update existing resources. Those are only updated when they are reapplied.
245245

246246
During orchestratord startup, after waiting for the CRD to be established, we need to loop through all Materialize resources and `replace` them.
247247

@@ -250,22 +250,22 @@ If it is possible to determine the stored version of these resources, we should
250250
I think it is OK for this to be best-effort, and only warn in case of failure.
251251
For backward compatibility reasons, we're going to have to support the old version for some time.
252252
Orchestratord is likely to get restarted/upgraded multiple times in that period, so it can try again.
253-
If the user ever writes an updated CR, it will also be stored in v1alpha2, so it isn't critical that this work immediately.
253+
If the user ever writes an updated CR, it will also be stored in v1, so it isn't critical that this work immediately.
254254

255255
## Known testing required
256256

257257
Our existing nightly orchestratord tests cover a lot, but we'll need to extend them to work with multiple CRD versions.
258258

259-
- Upgrades from existing v1alpha1 environments by applying v1alpha1 CR. (this is basically what we have now, but we need to not break it with the orchestratord changes to reconcile v1alpha2 after conversion)
260-
- Upgrades from existing v1alpha1 environments by applying v1alpha2 CR.
261-
- Upgrades from existing v1alpha2 environments by applying v1alpha1 CR.
262-
- Upgrades from existing v1alpha2 environments by applying v1alpha2 CR.
259+
- Upgrades from existing v1alpha1 environments by applying v1alpha1 CR. (this is basically what we have now, but we need to not break it with the orchestratord changes to reconcile v1 after conversion)
260+
- Upgrades from existing v1alpha1 environments by applying v1 CR.
261+
- Upgrades from existing v1 environments by applying v1alpha1 CR.
262+
- Upgrades from existing v1 environments by applying v1 CR.
263263
- Upgrade from existing v1alpha1 environment that is mid-rollout not in "promoting" status.
264264
- Upgrade from existing v1alpha1 environment that is mid-rollout in "promoting" status.
265265
- Upgrades with a previous rollout already in progress.
266266
- Upgrades triggered by annotation.
267-
- Deploy of latest Materialize image versions using v1alpha2 CR.
268-
- Deploy of older Materialize image versions using v1alpha2 CR.
267+
- Deploy of latest Materialize image versions using v1 CR.
268+
- Deploy of older Materialize image versions using v1 CR.
269269

270270
## Minimal Viable Prototype
271271

src/cloud-resources/src/crd/materialize.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ pub mod v1alpha1 {
564564
pub fn should_force_promote(&self) -> bool {
565565
self.spec.force_promote == self.spec.request_rollout.hyphenated().to_string()
566566
|| self.spec.force_promote
567-
== super::v1alpha2::Materialize::from(self.clone()).generate_rollout_hash()
567+
== super::v1::Materialize::from(self.clone()).generate_rollout_hash()
568568
|| self.spec.rollout_strategy
569569
== MaterializeRolloutStrategy::ImmediatelyPromoteCausingDowntime
570570
}
@@ -761,7 +761,7 @@ pub mod v1alpha1 {
761761
/// If you want to trigger a rollout without making other changes that would cause this
762762
/// hash to change, you must set forceRollout to the same UUID as requestRollout.
763763
pub resources_hash: String,
764-
/// The last completed rollout hash from v1alpha2.
764+
/// The last completed rollout hash from v1.
765765
/// This exists on this older version only for round-trip conversion support.
766766
pub last_completed_rollout_hash: Option<String>,
767767
pub conditions: Vec<Condition>,
@@ -801,11 +801,11 @@ pub mod v1alpha1 {
801801
}
802802
}
803803

804-
impl From<v1alpha2::Materialize> for Materialize {
805-
fn from(value: v1alpha2::Materialize) -> Self {
804+
impl From<v1::Materialize> for Materialize {
805+
fn from(value: v1::Materialize) -> Self {
806806
let rollout_hash = value.generate_rollout_hash();
807807
// Derive a deterministic UUID from the rollout hash so that the
808-
// same v1alpha2 spec always produces the same requestRollout,
808+
// same v1 spec always produces the same requestRollout,
809809
// making re-applies of an unchanged spec idempotent.
810810
let request_rollout = Uuid::new_v5(&Uuid::NAMESPACE_OID, rollout_hash.as_bytes());
811811
Materialize {
@@ -870,7 +870,7 @@ pub mod v1alpha1 {
870870
}
871871
}
872872

873-
pub mod v1alpha2 {
873+
pub mod v1 {
874874
use super::*;
875875

876876
#[derive(
@@ -887,7 +887,7 @@ pub mod v1alpha2 {
887887
#[kube(
888888
namespaced,
889889
group = "materialize.cloud",
890-
version = "v1alpha2",
890+
version = "v1",
891891
kind = "Materialize",
892892
singular = "materialize",
893893
plural = "materializes",

src/mz-debug/src/k8s_dumper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomRe
3838
use kube::api::{ListParams, LogParams};
3939
use kube::{Api, Client};
4040
use mz_cloud_resources::crd::generated::cert_manager::certificates::Certificate;
41-
use mz_cloud_resources::crd::materialize::v1alpha2::Materialize;
41+
use mz_cloud_resources::crd::materialize::v1::Materialize;
4242

4343
use serde::{Serialize, de::DeserializeOwned};
4444
use tracing::{info, warn};

src/mz-debug/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::str::FromStr;
2121

2222
use chrono::{DateTime, Utc};
2323
use kube::{Api, Client};
24-
use mz_cloud_resources::crd::materialize::v1alpha2::Materialize;
24+
use mz_cloud_resources::crd::materialize::v1::Materialize;
2525
use mz_server_core::listeners::AuthenticatorKind;
2626
use zip::ZipWriter;
2727
use zip::write::SimpleFileOptions;

src/orchestratord/src/k8s.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub async fn register_crds(
108108
ca_cert_path: String,
109109
) -> Result<(), anyhow::Error> {
110110
let ca_bytes = tokio::fs::read(ca_cert_path).await?;
111-
let mut mz_crd = crd::materialize::v1alpha2::Materialize::crd();
111+
let mut mz_crd = crd::materialize::v1::Materialize::crd();
112112
let default_columns = mz_crd.spec.versions[0]
113113
.additional_printer_columns
114114
.take()

0 commit comments

Comments
 (0)