Skip to content

Commit edf7339

Browse files
def-SangJunBak
authored andcommitted
bin/orchstratord: Add instructions for usage
1 parent 0481273 commit edf7339

File tree

3 files changed

+77
-11
lines changed

3 files changed

+77
-11
lines changed

misc/kind/cluster.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,21 @@ nodes:
157157
image: kindest/node:v1.31.6
158158
labels:
159159
materialize.cloud/disk: true
160+
materialize.cloud/swap: true
160161
materialize.cloud/availability-zone: "1"
161162
topology.kubernetes.io/zone: "1"
162163
- role: worker
163164
image: kindest/node:v1.31.6
164165
labels:
165166
materialize.cloud/disk: true
167+
materialize.cloud/swap: true
166168
materialize.cloud/availability-zone: "2"
167169
topology.kubernetes.io/zone: "2"
168170
- role: worker
169171
image: kindest/node:v1.31.6
170172
labels:
171173
materialize.cloud/disk: true
174+
materialize.cloud/swap: true
172175
materialize.cloud/availability-zone: "3"
173176
topology.kubernetes.io/zone: "3"
174177

@@ -177,6 +180,7 @@ nodes:
177180
image: kindest/node:v1.31.6
178181
labels:
179182
materialize.cloud/disk: false
183+
materialize.cloud/swap: false
180184
materialize.cloud/availability-zone: "1"
181185
topology.kubernetes.io/zone: "1"
182186

@@ -185,11 +189,13 @@ nodes:
185189
image: kindest/node:v1.31.6
186190
labels:
187191
materialize.cloud/disk: true
192+
materialize.cloud/swap: true
188193
materialize.cloud/availability-zone: "3"
189194
topology.kubernetes.io/zone: "3"
190195
- role: worker
191196
image: kindest/node:v1.31.6
192197
labels:
193198
materialize.cloud/disk: true
199+
materialize.cloud/swap: true
194200
materialize.cloud/availability-zone: "3"
195201
topology.kubernetes.io/zone: "3"

misc/python/materialize/cli/orchestratord.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,27 @@
2727
from materialize.docker import image_registry
2828

2929
DEV_IMAGE_TAG = "local-dev"
30-
DEFAULT_POSTGRES = (
31-
"postgres://[email protected]:5432/materialize"
32-
)
33-
DEFAULT_MINIO = "s3://minio:minio123@persist/persist?endpoint=http%3A%2F%2Fminio.materialize.svc.cluster.local%3A9000&region=minio"
30+
DEFAULT_POSTGRES = "postgres://materialize_user:[email protected]:5432/materialize_db?sslmode=disable"
31+
DEFAULT_MINIO = "s3://minio:minio123@bucket/12345678-1234-1234-1234-123456789012?endpoint=http%3A%2F%2Fminio.materialize.svc.cluster.local%3A9000&region=minio"
3432

3533

3634
def main():
3735
os.chdir(MZ_ROOT)
36+
# Console is not on GHCR yet
37+
os.environ["MZ_GHCR"] = "0"
3838

3939
parser = argparse.ArgumentParser(
4040
prog="orchestratord",
41-
description="""Runs orchestratord within a local kind cluster""",
41+
description="Runs orchestratord within a local kind cluster",
42+
usage="""
43+
For a new setup you can run:
44+
kind delete cluster
45+
kind create cluster --config misc/kind/cluster.yaml
46+
kubectl create namespace materialize
47+
kubectl apply -f misc/helm-charts/testing/postgres.yaml
48+
kubectl apply -f misc/helm-charts/testing/minio.yaml
49+
bin/orchestratord run
50+
bin/orchestratord environment --license-key-file ~/license-key""",
4251
)
4352
parser.add_argument(
4453
"--kind-cluster-name",

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

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ use crate::crd::generated::cert_manager::certificates::{
3030
CertificateIssuerRef, CertificateSecretTemplate,
3131
};
3232

33+
const V26_0_0: Version = Version::new(26, 0, 0);
34+
3335
pub const LAST_KNOWN_ACTIVE_GENERATION_ANNOTATION: &str =
3436
"materialize.cloud/last-known-active-generation";
3537

@@ -500,13 +502,15 @@ pub mod v1alpha1 {
500502
parse_image_ref(&self.spec.environmentd_image_ref),
501503
current_environmentd_version,
502504
) {
503-
// We deny upgrades past 1 major version of the last successful rollout.
504-
new_environmentd_version.major <= current_environmentd_version.major + 1
505-
} else {
506-
// If we couldn't parse either versions, we allow the upgrade since environmentd
507-
// will still be able to determine if the upgrade is allowed or not.
508-
true
505+
if current_environmentd_version >= V26_0_0 {
506+
// We deny upgrades past 1 major version of the last successful rollout
507+
return new_environmentd_version.major
508+
<= current_environmentd_version.major + 1;
509+
}
509510
}
511+
// If we fail any of the preconditions for the check (e.g. we couldn't parse either version),
512+
// we still allow the upgrade since environmentd will still error if the upgrade is not allowed.
513+
true
510514
}
511515

512516
pub fn managed_resource_meta(&self, name: String) -> ObjectMeta {
@@ -669,4 +673,51 @@ mod tests {
669673
mz.spec.environmentd_image_ref = "my.private.registry:5000:v0.33.3".to_owned();
670674
assert!(!mz.meets_minimum_version(&Version::parse("0.34.0").unwrap()));
671675
}
676+
677+
#[mz_ore::test]
678+
fn within_upgrade_window() {
679+
use super::v1alpha1::MaterializeStatus;
680+
681+
let mut mz = Materialize {
682+
spec: MaterializeSpec {
683+
environmentd_image_ref: "materialize/environmentd:v26.0.0".to_owned(),
684+
..Default::default()
685+
},
686+
metadata: ObjectMeta {
687+
..Default::default()
688+
},
689+
status: Some(MaterializeStatus {
690+
last_completed_rollout_environmentd_image_ref: Some(
691+
"materialize/environmentd:v26.0.0".to_owned(),
692+
),
693+
..Default::default()
694+
}),
695+
};
696+
697+
// Pass: upgrading from 26.0.0 to 27.7.3 (within 1 major version)
698+
mz.spec.environmentd_image_ref = "materialize/environmentd:v27.7.3".to_owned();
699+
assert!(mz.within_upgrade_window());
700+
701+
// Pass: upgrading from 26.0.0 to 27.7.8-dev.0 (within 1 major version, pre-release)
702+
mz.spec.environmentd_image_ref = "materialize/environmentd:v27.7.8-dev.0".to_owned();
703+
assert!(mz.within_upgrade_window());
704+
705+
// Fail: upgrading from 26.0.0 to 28.0.1 (more than 1 major version)
706+
mz.spec.environmentd_image_ref = "materialize/environmentd:v28.0.1".to_owned();
707+
assert!(!mz.within_upgrade_window());
708+
709+
// Pass: upgrading from 26.0.0 to 28.0.1.not_a_valid_version (invalid version, defaults to true)
710+
mz.spec.environmentd_image_ref =
711+
"materialize/environmentd:v28.0.1.not_a_valid_version".to_owned();
712+
assert!(mz.within_upgrade_window());
713+
714+
// Pass: upgrading from 0.147.5 to 26.1.0 (any version before 26.0.0 passes)
715+
mz.status
716+
.as_mut()
717+
.unwrap()
718+
.last_completed_rollout_environmentd_image_ref =
719+
Some("materialize/environmentd:v0.147.5".to_owned());
720+
mz.spec.environmentd_image_ref = "materialize/environmentd:v26.1.0".to_owned();
721+
assert!(mz.within_upgrade_window());
722+
}
672723
}

0 commit comments

Comments
 (0)