-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support persistence options for zookeeper (#273)
Signed-off-by: Xudong Sun <[email protected]>
- Loading branch information
1 parent
55f9c2f
commit 41508b7
Showing
10 changed files
with
295 additions
and
66 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -113,3 +113,20 @@ jobs: | |
run: ./local-test.sh zookeeper | ||
- name: Run zookeeper e2e tests | ||
run: cd e2e && cargo run -- zookeeper | ||
zookeeper-ephemeral-e2e-test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: "^1.20" | ||
- name: Install kind | ||
run: go install sigs.k8s.io/[email protected] | ||
- name: Install Rust toolchain | ||
run: | | ||
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y | ||
- name: Deploy zookeeper controller | ||
run: ./local-test.sh zookeeper | ||
- name: Run zookeeper e2e tests | ||
run: cd e2e && cargo run -- zookeeper-ephemeral |
This file contains 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 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 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 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 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 |
---|---|---|
|
@@ -1213,55 +1213,63 @@ fn make_stateful_set(zk: &ZookeeperCluster, rv: &String) -> (stateful_set: State | |
}); | ||
// Set the templates used for creating the persistent volume claims attached to each pod | ||
stateful_set_spec.set_volume_claim_templates({ | ||
let mut volume_claim_templates = Vec::new(); | ||
volume_claim_templates.push({ | ||
let mut pvc = PersistentVolumeClaim::default(); | ||
pvc.set_metadata({ | ||
let mut metadata = ObjectMeta::default(); | ||
metadata.set_name(new_strlit("data").to_string()); | ||
metadata.set_labels(make_labels(zk)); | ||
metadata.set_annotations(zk.spec().annotations()); | ||
metadata | ||
}); | ||
pvc.set_spec({ | ||
let mut pvc_spec = PersistentVolumeClaimSpec::default(); | ||
pvc_spec.set_access_modes({ | ||
let mut access_modes = Vec::new(); | ||
access_modes.push(new_strlit("ReadWriteOnce").to_string()); | ||
|
||
proof { | ||
assert_seqs_equal!( | ||
[email protected]_values(|mode: String| mode@), | ||
zk_spec::make_stateful_set(zk@, rv@) | ||
.spec.get_Some_0().volume_claim_templates.get_Some_0()[0] | ||
.spec.get_Some_0().access_modes.get_Some_0() | ||
); | ||
} | ||
|
||
access_modes | ||
if zk.spec().persistence().enabled() { | ||
let mut volume_claim_templates = Vec::new(); | ||
volume_claim_templates.push({ | ||
let mut pvc = PersistentVolumeClaim::default(); | ||
pvc.set_metadata({ | ||
let mut metadata = ObjectMeta::default(); | ||
metadata.set_name(new_strlit("data").to_string()); | ||
metadata.set_labels(make_labels(zk)); | ||
metadata.set_annotations(zk.spec().annotations()); | ||
metadata | ||
}); | ||
pvc_spec.set_resources({ | ||
let mut resources = ResourceRequirements::default(); | ||
resources.set_requests({ | ||
let mut requests = StringMap::empty(); | ||
requests.insert(new_strlit("storage").to_string(), new_strlit("20Gi").to_string()); | ||
requests | ||
pvc.set_spec({ | ||
let mut pvc_spec = PersistentVolumeClaimSpec::default(); | ||
pvc_spec.set_access_modes({ | ||
let mut access_modes = Vec::new(); | ||
access_modes.push(new_strlit("ReadWriteOnce").to_string()); | ||
proof { | ||
assert_seqs_equal!( | ||
[email protected]_values(|mode: String| mode@), | ||
zk_spec::make_stateful_set(zk@, rv@) | ||
.spec.get_Some_0().volume_claim_templates.get_Some_0()[0] | ||
.spec.get_Some_0().access_modes.get_Some_0() | ||
); | ||
} | ||
access_modes | ||
}); | ||
resources | ||
pvc_spec.set_resources({ | ||
let mut resources = ResourceRequirements::default(); | ||
resources.set_requests({ | ||
let mut requests = StringMap::empty(); | ||
requests.insert(new_strlit("storage").to_string(), zk.spec().persistence().storage_size()); | ||
requests | ||
}); | ||
resources | ||
}); | ||
pvc_spec.overwrite_storage_class_name(zk.spec().persistence().storage_class_name()); | ||
pvc_spec | ||
}); | ||
pvc_spec | ||
pvc | ||
}); | ||
pvc | ||
}); | ||
|
||
proof { | ||
assert_seqs_equal!( | ||
[email protected]_values(|pvc: PersistentVolumeClaim| pvc@), | ||
zk_spec::make_stateful_set(zk@, rv@).spec.get_Some_0().volume_claim_templates.get_Some_0() | ||
); | ||
proof { | ||
assert_seqs_equal!( | ||
[email protected]_values(|pvc: PersistentVolumeClaim| pvc@), | ||
zk_spec::make_stateful_set(zk@, rv@).spec.get_Some_0().volume_claim_templates.get_Some_0() | ||
); | ||
} | ||
volume_claim_templates | ||
} else { | ||
let empty_templates = Vec::<PersistentVolumeClaim>::new(); | ||
proof { | ||
assert_seqs_equal!( | ||
[email protected]_values(|pvc: PersistentVolumeClaim| pvc@), | ||
zk_spec::make_stateful_set(zk@, rv@).spec.get_Some_0().volume_claim_templates.get_Some_0() | ||
); | ||
} | ||
empty_templates | ||
} | ||
|
||
volume_claim_templates | ||
}); | ||
stateful_set_spec | ||
}); | ||
|
@@ -1432,6 +1440,14 @@ fn make_zk_pod_spec(zk: &ZookeeperCluster) -> (pod_spec: PodSpec) | |
}); | ||
volume | ||
}); | ||
if !zk.spec().persistence().enabled() { | ||
volumes.push({ | ||
let mut volume = Volume::default(); | ||
volume.set_name(new_strlit("data").to_string()); | ||
volume.set_empty_dir(); | ||
volume | ||
}); | ||
} | ||
|
||
proof { | ||
assert_seqs_equal!( | ||
|
This file contains 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.