···
1
-
import ./make-test-python.nix (
6
-
clusterId = "066ae264-2a5d-4729-8001-6ad265f50b03";
5
+
clusterId = "066ae264-2a5d-4729-8001-6ad265f50b03";
12
+
key = "AQBCEJNa3s8nHRAANvdsr93KqzBznuIWm2gOGg==";
13
+
uuid = "55ba2294-3e24-478f-bee0-9dca4c231dd9";
17
+
key = "AQBEEJNac00kExAAXEgy943BGyOpVH1LLlHafQ==";
18
+
uuid = "5e97a838-85b6-43b0-8950-cb56d554d1e5";
22
+
key = "AQAdyhZeIaUlARAAGRoidDAmS6Vkp546UFEf5w==";
23
+
uuid = "ea999274-13d0-4dd5-9af9-ad25a324f72f";
26
+
generateCephConfig =
31
+
fsid = cfg.clusterId;
32
+
monHost = cfg.monA.ip;
33
+
monInitialMembers = cfg.monA.name;
13
-
key = "AQBCEJNa3s8nHRAANvdsr93KqzBznuIWm2gOGg==";
14
-
uuid = "55ba2294-3e24-478f-bee0-9dca4c231dd9";
18
-
key = "AQBEEJNac00kExAAXEgy943BGyOpVH1LLlHafQ==";
19
-
uuid = "5e97a838-85b6-43b0-8950-cb56d554d1e5";
23
-
key = "AQAdyhZeIaUlARAAGRoidDAmS6Vkp546UFEf5w==";
24
-
uuid = "ea999274-13d0-4dd5-9af9-ad25a324f72f";
27
-
generateCephConfig =
32
-
fsid = cfg.clusterId;
33
-
monHost = cfg.monA.ip;
34
-
monInitialMembers = cfg.monA.name;
54
+
networking = networkConfig;
56
-
networking = networkConfig;
56
+
environment.systemPackages = with pkgs; [
58
-
environment.systemPackages = with pkgs; [
63
+
boot.kernelModules = [ "xfs" ];
65
-
boot.kernelModules = [ "xfs" ];
65
+
services.ceph = cephConfig;
67
-
services.ceph = cephConfig;
69
+
dhcpcd.enable = false;
70
+
interfaces.eth1.ipv4.addresses = lib.mkOverride 0 [
72
+
address = cfg.monA.ip;
77
+
cephConfigMonA = generateCephConfig {
81
+
daemons = [ cfg.monA.name ];
71
-
dhcpcd.enable = false;
72
-
interfaces.eth1.ipv4.addresses = pkgs.lib.mkOverride 0 [
74
-
address = cfg.monA.ip;
79
-
cephConfigMonA = generateCephConfig {
83
-
daemons = [ cfg.monA.name ];
87
-
daemons = [ cfg.monA.name ];
85
+
daemons = [ cfg.monA.name ];
100
-
# Following deployment is based on the manual deployment described here:
101
-
# https://docs.ceph.com/docs/master/install/manual-deployment/
102
-
# For other ways to deploy a ceph cluster, look at the documentation at
103
-
# https://docs.ceph.com/docs/master/
98
+
# Following deployment is based on the manual deployment described here:
99
+
# https://docs.ceph.com/docs/master/install/manual-deployment/
100
+
# For other ways to deploy a ceph cluster, look at the documentation at
101
+
# https://docs.ceph.com/docs/master/
109
-
monA.wait_for_unit("network.target")
105
+
monA.wait_for_unit("network.target")
111
-
# Bootstrap ceph-mon daemon
113
-
"sudo -u ceph ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'",
114
-
"sudo -u ceph ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow *' --cap mgr 'allow *'",
115
-
"sudo -u ceph ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring",
116
-
"monmaptool --create --add ${cfg.monA.name} ${cfg.monA.ip} --fsid ${cfg.clusterId} /tmp/monmap",
117
-
"sudo -u ceph ceph-mon --mkfs -i ${cfg.monA.name} --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring",
118
-
"sudo -u ceph touch /var/lib/ceph/mon/ceph-${cfg.monA.name}/done",
119
-
"systemctl start ceph-mon-${cfg.monA.name}",
121
-
monA.wait_for_unit("ceph-mon-${cfg.monA.name}")
122
-
monA.succeed("ceph mon enable-msgr2")
123
-
monA.succeed("ceph config set mon auth_allow_insecure_global_id_reclaim false")
107
+
# Bootstrap ceph-mon daemon
109
+
"sudo -u ceph ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'",
110
+
"sudo -u ceph ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow *' --cap mgr 'allow *'",
111
+
"sudo -u ceph ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring",
112
+
"monmaptool --create --add ${cfg.monA.name} ${cfg.monA.ip} --fsid ${cfg.clusterId} /tmp/monmap",
113
+
"sudo -u ceph ceph-mon --mkfs -i ${cfg.monA.name} --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring",
114
+
"sudo -u ceph touch /var/lib/ceph/mon/ceph-${cfg.monA.name}/done",
115
+
"systemctl start ceph-mon-${cfg.monA.name}",
117
+
monA.wait_for_unit("ceph-mon-${cfg.monA.name}")
118
+
monA.succeed("ceph mon enable-msgr2")
119
+
monA.succeed("ceph config set mon auth_allow_insecure_global_id_reclaim false")
125
-
# Can't check ceph status until a mon is up
126
-
monA.succeed("ceph -s | grep 'mon: 1 daemons'")
121
+
# Can't check ceph status until a mon is up
122
+
monA.succeed("ceph -s | grep 'mon: 1 daemons'")
128
-
# Start the ceph-mgr daemon, after copying in the keyring
130
-
"sudo -u ceph mkdir -p /var/lib/ceph/mgr/ceph-${cfg.monA.name}/",
131
-
"ceph auth get-or-create mgr.${cfg.monA.name} mon 'allow profile mgr' osd 'allow *' mds 'allow *' > /var/lib/ceph/mgr/ceph-${cfg.monA.name}/keyring",
132
-
"systemctl start ceph-mgr-${cfg.monA.name}",
134
-
monA.wait_for_unit("ceph-mgr-a")
135
-
monA.wait_until_succeeds("ceph -s | grep 'quorum ${cfg.monA.name}'")
136
-
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
124
+
# Start the ceph-mgr daemon, after copying in the keyring
126
+
"sudo -u ceph mkdir -p /var/lib/ceph/mgr/ceph-${cfg.monA.name}/",
127
+
"ceph auth get-or-create mgr.${cfg.monA.name} mon 'allow profile mgr' osd 'allow *' mds 'allow *' > /var/lib/ceph/mgr/ceph-${cfg.monA.name}/keyring",
128
+
"systemctl start ceph-mgr-${cfg.monA.name}",
130
+
monA.wait_for_unit("ceph-mgr-a")
131
+
monA.wait_until_succeeds("ceph -s | grep 'quorum ${cfg.monA.name}'")
132
+
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
140
-
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd0.name}",
141
-
"echo bluestore > /var/lib/ceph/osd/ceph-${cfg.osd0.name}/type",
142
-
"ln -sf /dev/vdb /var/lib/ceph/osd/ceph-${cfg.osd0.name}/block",
143
-
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd1.name}",
144
-
"echo bluestore > /var/lib/ceph/osd/ceph-${cfg.osd1.name}/type",
145
-
"ln -sf /dev/vdc /var/lib/ceph/osd/ceph-${cfg.osd1.name}/block",
146
-
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd2.name}",
147
-
"echo bluestore > /var/lib/ceph/osd/ceph-${cfg.osd2.name}/type",
148
-
"ln -sf /dev/vdd /var/lib/ceph/osd/ceph-${cfg.osd2.name}/block",
149
-
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd0.name}/keyring --name osd.${cfg.osd0.name} --add-key ${cfg.osd0.key}",
150
-
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd1.name}/keyring --name osd.${cfg.osd1.name} --add-key ${cfg.osd1.key}",
151
-
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd2.name}/keyring --name osd.${cfg.osd2.name} --add-key ${cfg.osd2.key}",
152
-
'echo \'{"cephx_secret": "${cfg.osd0.key}"}\' | ceph osd new ${cfg.osd0.uuid} -i -',
153
-
'echo \'{"cephx_secret": "${cfg.osd1.key}"}\' | ceph osd new ${cfg.osd1.uuid} -i -',
154
-
'echo \'{"cephx_secret": "${cfg.osd2.key}"}\' | ceph osd new ${cfg.osd2.uuid} -i -',
136
+
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd0.name}",
137
+
"echo bluestore > /var/lib/ceph/osd/ceph-${cfg.osd0.name}/type",
138
+
"ln -sf /dev/vdb /var/lib/ceph/osd/ceph-${cfg.osd0.name}/block",
139
+
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd1.name}",
140
+
"echo bluestore > /var/lib/ceph/osd/ceph-${cfg.osd1.name}/type",
141
+
"ln -sf /dev/vdc /var/lib/ceph/osd/ceph-${cfg.osd1.name}/block",
142
+
"mkdir -p /var/lib/ceph/osd/ceph-${cfg.osd2.name}",
143
+
"echo bluestore > /var/lib/ceph/osd/ceph-${cfg.osd2.name}/type",
144
+
"ln -sf /dev/vdd /var/lib/ceph/osd/ceph-${cfg.osd2.name}/block",
145
+
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd0.name}/keyring --name osd.${cfg.osd0.name} --add-key ${cfg.osd0.key}",
146
+
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd1.name}/keyring --name osd.${cfg.osd1.name} --add-key ${cfg.osd1.key}",
147
+
"ceph-authtool --create-keyring /var/lib/ceph/osd/ceph-${cfg.osd2.name}/keyring --name osd.${cfg.osd2.name} --add-key ${cfg.osd2.key}",
148
+
'echo \'{"cephx_secret": "${cfg.osd0.key}"}\' | ceph osd new ${cfg.osd0.uuid} -i -',
149
+
'echo \'{"cephx_secret": "${cfg.osd1.key}"}\' | ceph osd new ${cfg.osd1.uuid} -i -',
150
+
'echo \'{"cephx_secret": "${cfg.osd2.key}"}\' | ceph osd new ${cfg.osd2.uuid} -i -',
157
-
# Initialize the OSDs with regular filestore
159
-
"ceph-osd -i ${cfg.osd0.name} --mkfs --osd-uuid ${cfg.osd0.uuid}",
160
-
"ceph-osd -i ${cfg.osd1.name} --mkfs --osd-uuid ${cfg.osd1.uuid}",
161
-
"ceph-osd -i ${cfg.osd2.name} --mkfs --osd-uuid ${cfg.osd2.uuid}",
162
-
"chown -R ceph:ceph /var/lib/ceph/osd",
163
-
"systemctl start ceph-osd-${cfg.osd0.name}",
164
-
"systemctl start ceph-osd-${cfg.osd1.name}",
165
-
"systemctl start ceph-osd-${cfg.osd2.name}",
167
-
monA.wait_until_succeeds("ceph osd stat | grep -e '3 osds: 3 up[^,]*, 3 in'")
168
-
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
169
-
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
153
+
# Initialize the OSDs with regular filestore
155
+
"ceph-osd -i ${cfg.osd0.name} --mkfs --osd-uuid ${cfg.osd0.uuid}",
156
+
"ceph-osd -i ${cfg.osd1.name} --mkfs --osd-uuid ${cfg.osd1.uuid}",
157
+
"ceph-osd -i ${cfg.osd2.name} --mkfs --osd-uuid ${cfg.osd2.uuid}",
158
+
"chown -R ceph:ceph /var/lib/ceph/osd",
159
+
"systemctl start ceph-osd-${cfg.osd0.name}",
160
+
"systemctl start ceph-osd-${cfg.osd1.name}",
161
+
"systemctl start ceph-osd-${cfg.osd2.name}",
163
+
monA.wait_until_succeeds("ceph osd stat | grep -e '3 osds: 3 up[^,]*, 3 in'")
164
+
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
165
+
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
172
-
"ceph osd pool create single-node-test 32 32",
173
-
"ceph osd pool ls | grep 'single-node-test'",
168
+
"ceph osd pool create single-node-test 32 32",
169
+
"ceph osd pool ls | grep 'single-node-test'",
175
-
# We need to enable an application on the pool, otherwise it will
176
-
# stay unhealthy in state POOL_APP_NOT_ENABLED.
177
-
# Creating a CephFS would do this automatically, but we haven't done that here.
178
-
# See: https://docs.ceph.com/en/reef/rados/operations/pools/#associating-a-pool-with-an-application
179
-
# We use the custom application name "nixos-test" for this.
180
-
"ceph osd pool application enable single-node-test nixos-test",
171
+
# We need to enable an application on the pool, otherwise it will
172
+
# stay unhealthy in state POOL_APP_NOT_ENABLED.
173
+
# Creating a CephFS would do this automatically, but we haven't done that here.
174
+
# See: https://docs.ceph.com/en/reef/rados/operations/pools/#associating-a-pool-with-an-application
175
+
# We use the custom application name "nixos-test" for this.
176
+
"ceph osd pool application enable single-node-test nixos-test",
182
-
"ceph osd pool rename single-node-test single-node-other-test",
183
-
"ceph osd pool ls | grep 'single-node-other-test'",
185
-
monA.wait_until_succeeds("ceph -s | grep '2 pools, 33 pgs'")
187
-
"ceph osd getcrushmap -o crush",
188
-
"crushtool -d crush -o decrushed",
189
-
"sed 's/step chooseleaf firstn 0 type host/step chooseleaf firstn 0 type osd/' decrushed > modcrush",
190
-
"crushtool -c modcrush -o recrushed",
191
-
"ceph osd setcrushmap -i recrushed",
192
-
"ceph osd pool set single-node-other-test size 2",
194
-
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
195
-
monA.wait_until_succeeds("ceph -s | grep '33 active+clean'")
197
-
"ceph osd pool ls | grep 'multi-node-test'",
198
-
"ceph osd pool delete single-node-other-test single-node-other-test --yes-i-really-really-mean-it",
178
+
"ceph osd pool rename single-node-test single-node-other-test",
179
+
"ceph osd pool ls | grep 'single-node-other-test'",
181
+
monA.wait_until_succeeds("ceph -s | grep '2 pools, 33 pgs'")
183
+
"ceph osd getcrushmap -o crush",
184
+
"crushtool -d crush -o decrushed",
185
+
"sed 's/step chooseleaf firstn 0 type host/step chooseleaf firstn 0 type osd/' decrushed > modcrush",
186
+
"crushtool -c modcrush -o recrushed",
187
+
"ceph osd setcrushmap -i recrushed",
188
+
"ceph osd pool set single-node-other-test size 2",
190
+
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
191
+
monA.wait_until_succeeds("ceph -s | grep '33 active+clean'")
193
+
"ceph osd pool ls | grep 'multi-node-test'",
194
+
"ceph osd pool delete single-node-other-test single-node-other-test --yes-i-really-really-mean-it",
201
-
# Shut down ceph by stopping ceph.target.
202
-
monA.succeed("systemctl stop ceph.target")
197
+
# Shut down ceph by stopping ceph.target.
198
+
monA.succeed("systemctl stop ceph.target")
205
-
monA.succeed("systemctl start ceph.target")
206
-
monA.wait_for_unit("ceph-mon-${cfg.monA.name}")
207
-
monA.wait_for_unit("ceph-mgr-${cfg.monA.name}")
208
-
monA.wait_for_unit("ceph-osd-${cfg.osd0.name}")
209
-
monA.wait_for_unit("ceph-osd-${cfg.osd1.name}")
210
-
monA.wait_for_unit("ceph-osd-${cfg.osd2.name}")
201
+
monA.succeed("systemctl start ceph.target")
202
+
monA.wait_for_unit("ceph-mon-${cfg.monA.name}")
203
+
monA.wait_for_unit("ceph-mgr-${cfg.monA.name}")
204
+
monA.wait_for_unit("ceph-osd-${cfg.osd0.name}")
205
+
monA.wait_for_unit("ceph-osd-${cfg.osd1.name}")
206
+
monA.wait_for_unit("ceph-osd-${cfg.osd2.name}")
212
-
# Ensure the cluster comes back up again
213
-
monA.succeed("ceph -s | grep 'mon: 1 daemons'")
214
-
monA.wait_until_succeeds("ceph -s | grep 'quorum ${cfg.monA.name}'")
215
-
monA.wait_until_succeeds("ceph osd stat | grep -e '3 osds: 3 up[^,]*, 3 in'")
216
-
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
217
-
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
221
-
name = "basic-single-node-ceph-cluster-bluestore";
222
-
meta = with pkgs.lib.maintainers; {
223
-
maintainers = [ lukegb ];
208
+
# Ensure the cluster comes back up again
209
+
monA.succeed("ceph -s | grep 'mon: 1 daemons'")
210
+
monA.wait_until_succeeds("ceph -s | grep 'quorum ${cfg.monA.name}'")
211
+
monA.wait_until_succeeds("ceph osd stat | grep -e '3 osds: 3 up[^,]*, 3 in'")
212
+
monA.wait_until_succeeds("ceph -s | grep 'mgr: ${cfg.monA.name}(active,'")
213
+
monA.wait_until_succeeds("ceph -s | grep 'HEALTH_OK'")
217
+
name = "basic-single-node-ceph-cluster-bluestore";
218
+
meta = with lib.maintainers; {
219
+
maintainers = [ lukegb ];
227
-
monA = generateHost {
229
-
cephConfig = cephConfigMonA;
230
-
networkConfig = networkMonA;
223
+
monA = generateHost {
224
+
cephConfig = cephConfigMonA;
225
+
networkConfig = networkMonA;
234
-
testScript = testscript;
229
+
inherit testScript;