-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript
executable file
·1252 lines (1135 loc) · 38.4 KB
/
script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# TODO:
# delete all instances at cleanup and depend upon the results bucket?
# function to call on normal exit and on any failure
ob_cleanup()
{
echo "remember to clean up test instances and resource policies"
exit
}
OB_PROJECT="orangefsdev"
OB_REGION="us-east1"
# Must use us-central1-a zone for any vCPU count over 24
OB_ZONE="us-east1-b"
gcloud config set project "$OB_PROJECT"
gcloud config set compute/region "$OB_REGION"
gcloud config set compute/zone "$OB_ZONE"
#OB_MPI_TYPE="intel"
#OB_MPI_TYPE="openmpi"
OB_MPI_TYPE="vanilla"
# "slots=N" affects the number of processors to use per client
OB_SLOTS=0
#OB_SLOTS=1
# affects memory usage on the ofs servers... default is 512MB
OB_DBMAXSIZE=536870912
# There's an IO buffer shared between the kernel module and the client core.
# There's the concept of a stripe-type and stripe-size that determines
# how, and how much, data is placed in the buffer and also how the
# data is distributed across the various disks in the backing store.
#
OB_DIST_NAME=simple_stripe
#OB_DIST_NAME=basic_dist
#OB_DIST_NAME=varstrip_dist
#OB_DIST_NAME=twod_stripe
#OB_DIST_PARAMS=strip_size:65536
#OB_DIST_PARAMS=strip_size:131072
OB_DIST_PARAMS=strip_size:1048576
# If set, we'll run io500 after everything is set up, else just exit.
OB_RUN_IO500=0
# destination location for io500 config files
OB_IO500_CONFIG="/var/tmp"
#OB_IMAGE=" --image hubcap-fc34-guestenv-gvnic-io500"
#OB_IMAGE=" --image hubcap-fc34-guestenv-gvnic-io500-2"
#OB_IMAGE=" --image hubcap-fc34-guestenv-gvnic-io500-3"
OB_IMAGE="orangefs-io500-sc22-ns"
OB_IMAGE_ARG=" --image=${OB_IMAGE}"
OB_SCOPE="cloud-platform"
OB_SCOPE_ARG=" --scopes=${OB_SCOPE}"
# persistent place for results and configs and whatever.
OB_BUCKET="gs://hubcap_bucket"
OB_OFS_NAME="pattern1-ofs-"
OB_IO500_NAME="pattern1-io500-"
# 0 = use basic gcloud create, 1 = use python bulk api
OB_USE_BULK_CREATE=1
# total number of servers and clients to create
OB_OFS_SERVERS=2
OB_OFS_PORT=3334
OB_OFS_PER_INSTANCE=1
OB_SEPARATE_DATA_META=0
OB_OFS_MACHINE="n2-standard-4"
OB_OFS_MACHINE_ARG=" --machine-type=${OB_OFS_MACHINE}"
OB_IO500_CLIENTS=1
OB_IO500_MACHINE="n2-standard-4"
OB_IO500_MACHINE_ARG=" --machine-type=${OB_IO500_MACHINE}"
# MAX per instance: 24 local SSD partitions - 9 TB - 2.4 million read IOPS
# My observation is that nvme device names will be /dev/nvme0n1 - /dev/nvme0n24
# valid number of ssd drives per instance: [0, 1, 2, 3, 4, 5, 6, 7, 8, 16, 24]
OB_SSD_NUM=1
OB_SSD_ARG=" --local-ssd interface=nvme"
OB_SSD_DEV="/dev/nvme0n"
OB_MDADM="mdadm --create /dev/md0 --level=0 --raid-devices="
OB_MOUNT_POINT="/var/lib/orangefs"
# Number of hardware threads (vCPUs) per physical core on each instance.
# By default, GCP uses Simultaneous Multithreading (2 vCPUs per core), but
# disabling it (by setting this to "1") can improve performance for some
# HPC applications.
# Accepted values are "1" or "2"
OB_THREADS_PER_CORE=1
if [ "$OB_THREADS_PER_CORE" -ne "1" ] && [ "$OB_THREADS_PER_CORE" -ne "2" ]
then
echo "invalid number of threads per core; must be 1 or 2"
exit
fi
OB_THREADS_ARG=" --threads-per-core=${OB_THREADS_PER_CORE}"
# If OB_PLACEMENT_POLICY is set, it will attempt to create the specified
# instances with a compact placement policy. It must be set to one of the
# following strings:
#
# "NONE" (or empty string) - do not create a placement policy
# "CLIENTS" - create a single policy for clients only
# "SERVERS" - create a single policy for servers only
# "SEPARATE" - two policies, one for servers and one for clients
# "SHARED" - single shared policy for both clients and servers (future update)
OB_PLACEMENT_POLICY="NONE"
OB_POLICY_PREFIX="pattern1-io500-pg"
# setup network options
OB_SUBNET=""
OB_NIC_TYPE="" # empty string or "GVNIC" for now
OB_USE_TIER1_NET=0 # if 1, must specify "GVNIC" for OB_NIC_TYPE
OB_NET_INT_ARGS=""
if [ -n "${OB_SUBNET}" ]
then
OB_NET_INT_ARGS="subnet=${OB_SUBNET}"
fi
if [ -n "${OB_NIC_TYPE}" ]
then
# add comma if subnet was specified
if [ -n "${OB_SUBNET}" ]
then
OB_NET_INT_ARGS+=","
fi
OB_NET_INT_ARGS+="nic-type=${OB_NIC_TYPE}"
fi
if [ -n "${OB_NET_INT_ARGS}" ]
then
OB_NET_INT=" --network-interface=${OB_NET_INT_ARGS}"
else
OB_NET_INT=""
fi
if [ "${OB_USE_TIER1_NET}" -gt "0" ]
then
OB_NET_PERF=" --network-performance-configs=total-egress-bandwidth-tier=TIER_1"
else
OB_NET_PERF=""
fi
# Metadata key/value pairs to assign to each instance
# Expects a comma-separated list of key=value pairs (e.g., "key1=val1,key2=val2")
OB_SERVER_METADATA="type=server"
OB_CLIENT_METADATA="type=client"
if [ -n "$OB_SERVER_METADATA" ]
then
OB_SERVER_METADATA_ARG=" --metadata=${OB_SERVER_METADATA}"
else
OB_SERVER_METADATA_ARG=""
fi
if [ -n "$OB_CLIENT_METADATA" ]
then
OB_CLIENT_METADATA_ARG=" --metadata=${OB_CLIENT_METADATA}"
else
OB_CLIENT_METADATA_ARG=""
fi
# Path to a local script to be used as a startup script on created instances
OB_STARTUP_SCRIPT=""
if [ -n "$OB_STARTUP_SCRIPT" ]
then
if [ -e "$OB_STARTUP_SCRIPT" ]
then
OB_STARTUP_SCRIPT_ARG=" --metadata-from-file="
OB_STARTUP_SCRIPT_ARG+="startup-script=${OB_STARTUP_SCRIPT}"
else
echo "Error: Startup script does not exist: '${OB_STARTUP_SCRIPT}'"
exit
fi
else
OB_STARTUP_SCRIPT_ARG=""
fi
# Here we can configure some servers to be data only, some to be meta only,
# and the rest will be both. These are used only when generating
# a balanced layout and overridden when the script runner supplies a
# layout.
OB_OFS_DATA=0 # number of ofs data-only servers
OB_OFS_META=0 # number of ofs meta-only servers
# layout data structure. The first example is "unset" since the first element
# is zero. In the second example, the first row represents
# instance_a and the second row represents instance_b. There are four
# pvfs2-server processes on each instance. a:3334 is both data and meta,
# a:3335 is both, a:3336 is data only and a:3337 is both. b:3334-3336
# is both and b:3337 is meta only. When the layout data structure is
# "unset" the script generates a "balanced" one.
OB_LAYOUT=( 0 )
#OB_LAYOUT=( 1 \
#b b d b \
#b b b m \
#)
# Generate a balanced layout if the script runner doesn't supply a layout.
if [ "${OB_LAYOUT[0]}" -eq "0" ]
then
# figure out the maximum number of data and/or meta only servers
# that can be deployed per instance in a balanced layout.
#
# On the Internet it says:
# To do rounding up ... simply add (denom-1) to the numerator.
#
data_max=$((( OB_OFS_DATA + ( OB_OFS_SERVERS - 1 )) / OB_OFS_SERVERS ))
meta_max=$((( OB_OFS_META + ( OB_OFS_SERVERS - 1 )) / OB_OFS_SERVERS ))
data=$OB_OFS_DATA
meta=$OB_OFS_META
unset OB_LAYOUT
OB_LAYOUT[0]="1"
row=1
for i in `seq 1 $OB_OFS_SERVERS`
do
data_this_server=0
meta_this_server=0
for j in `seq 1 $OB_OFS_PER_INSTANCE`
do
if [ "$data" -gt "0" -a \
"$data_this_server" -lt "$data_max" ]
then
OB_LAYOUT[$(( row + j - 1 ))]=d
data_this_server=$(( data_this_server + 1 ))
data=$(( data - 1 ))
elif [ "$meta" -gt "0" -a \
"$meta_this_server" -lt "$meta_max" ]
then
OB_LAYOUT[$(( row + j - 1 ))]=m
meta_this_server=$(( meta_this_server + 1 ))
meta=$(( meta - 1 ))
else
OB_LAYOUT[$(( row + j - 1 ))]=b
fi
done
row=$((( row * j ) + 1 ))
done
fi
echo "layout:""${OB_LAYOUT[@]}"":"
# sanity check: we should now have a layout data structure populated
# with the same number of elements as we have pvfs2-server processes,
# plus one for the set/unset cookie.
if [ "${#OB_LAYOUT[@]}" -ne \
"$((( OB_OFS_SERVERS * OB_OFS_PER_INSTANCE ) + 1 ))" ]
then
echo "layout:""${OB_LAYOUT[@]}"":"
echo "OB_OFS_SERVERS:""$OB_OFS_SERVERS"":"
echo "OB_OFS_PER_INSTANCE:""$OB_OFS_PER_INSTANCE"":"
exit
fi
OB_OFS_CONFIG="pvfs2-genconfig --iospec "
OB_OFS_CONFIG_FILE_NAME="orangefs.conf"
# clean up any leftover old config files or hostfiles from previous runs.
rm -f "$OB_OFS_CONFIG_FILE_NAME"
rm -f hostfile
rm -f pub.keys
# After starting the instances we'll test their ssh ports this
# many times before we give up and exit.
OB_ATTEMPTS=5
# seconds to sleep between attempts
OB_SLEEP=5
OB_CREATE="gcloud compute instances create "
if [ $(( OB_OFS_DATA + OB_OFS_META )) -gt \
$(( OB_OFS_SERVERS * OB_OFS_PER_INSTANCE )) ]
then
echo "sum of pure data + pure meta must not exceed pvfs2-server number."
ob_cleanup
fi
# create array of port numbers, one for each server.
current_port="$OB_OFS_PORT"
for i in `seq $OB_OFS_PER_INSTANCE`
do
port[i]="$current_port"
current_port=$(( current_port + 1 ))
done
if [ "$OB_SSD_NUM" -lt "1" ]
then
echo "must have at least one SSD."
ob_cleanup
fi
if [ "$OB_SSD_NUM" -lt "$OB_OFS_PER_INSTANCE" ]
then
echo "need at least one SSD for each pvfs2-server process."
echo "OB_SSD_NUM:""$OB_SSD_NUM"":"
echo "OB_OFS_PER_INSTANCE:""$OB_OFS_PER_INSTANCE"":"
ob_cleanup
fi
if [ "$OB_SSD_NUM" -lt $(( OB_OFS_PER_INSTANCE * 2 )) -a \
"$OB_SEPARATE_DATA_META" -eq "1" ]
then
echo "need at least two SSDs per pvfs2-server process to"
echo "keep IO and metadata separate."
ob_cleanup
fi
# indexed arrays of alphabet letters or numerical digits to append to host
# names for differentiation
OB_ALPHA=( {0,{a..z},{A..Z}} )
OB_DIGIT=( $(seq -w 0 99) ) # -w for equal width, so all two digits
if [ "$OB_USE_BULK_CREATE" -gt "0" ]
then
# bulk api automatically appends numbers to instance names
OB_SUFFIX=( ${OB_DIGIT[@]} )
OB_MAX=99
else
# for basic creation, we create the names ourselves
OB_SUFFIX=( ${OB_ALPHA[@]} )
OB_MAX=52
fi
# create compact placement policies
OB_POLICY_CREATE="gcloud compute resource-policies create"
OB_POLICY_TYPE="group-placement"
OB_COLLOCATION="collocated"
# function to create a compact placement policy
# usage: create_policy <policy_name> <vm_count>
create_policy() {
policy_name=$1
vm_count=$2
# create the policy
OB_CMD="$OB_POLICY_CREATE $OB_POLICY_TYPE $policy_name"
OB_CMD+=" --collocation=$OB_COLLOCATION"
OB_CMD+=" --vm-count=$vm_count"
#echo $OB_CMD
eval $OB_CMD
if [ "$?" -gt "0" ]
then
echo "creation of "$policy_name" failed."
ob_cleanup
fi
}
if [ -n "$OB_PLACEMENT_POLICY" ] && [ "$OB_PLACEMENT_POLICY" != "NONE" ]
then
ts=$(date "+%Y%m%d-%H%M%S")
OB_POLICY_NAME="${OB_POLICY_PREFIX}-${ts}"
if [ "$OB_PLACEMENT_POLICY" == "CLIENTS" ]
then
create_policy $OB_POLICY_NAME $OB_IO500_CLIENTS
OB_CLIENT_POLICY_OPTS=" --resource-policies=$OB_POLICY_NAME"
OB_SERVER_POLICY_OPTS=""
elif [ "$OB_PLACEMENT_POLICY" == "SERVERS" ]
then
create_policy $OB_POLICY_NAME $OB_OFS_SERVERS
OB_SERVER_POLICY_OPTS=" --resource-policies=$OB_POLICY_NAME"
OB_CLIENT_POLICY_OPTS=""
elif [ "$OB_PLACEMENT_POLICY" == "SEPARATE" ]
then
OB_SERVER_POLICY_NAME="${OB_POLICY_NAME}-servers"
OB_CLIENT_POLICY_NAME="${OB_POLICY_NAME}-clients"
create_policy $OB_SERVER_POLICY_NAME $OB_OFS_SERVERS
create_policy $OB_CLIENT_POLICY_NAME $OB_IO500_CLIENTS
OB_SERVER_POLICY_OPTS=" --resource-policies=$OB_SERVER_POLICY_NAME"
OB_CLIENT_POLICY_OPTS=" --resource-policies=$OB_CLIENT_POLICY_NAME"
elif [ "$OB_PLACEMENT_POLICY" == "SHARED" ]
then
# TODO: implement shared policies
echo "Support for a shared placement policy will be added in a future update."
echo "For now, please choose NONE, CLIENTS, or SERVERS."
ob_cleanup
fi
# set generic policy options for instance creation
OB_POLICY_OPTS=" --maintenance-policy=TERMINATE"
OB_POLICY_OPTS+=" --no-restart-on-failure"
# TODO: add cleanup message/instructions for policy to ob_cleanup
else
OB_POLICY_NAME=""
OB_POLICY_OPTS=""
fi
echo ""
OB_INSTANCE_FILE="instances.txt"
# clean up leftover output file from previous runs
rm -f "$OB_INSTANCE_FILE"
# define an "enum" for instance types
TYPE_OFS_SERVER=0
TYPE_IO500_CLIENT=1
# function to create instances manually, using gcloud commands
# usage: basic_create <num_instances> <ob_instance_type>
#
# upon completion, instances may not be in the RUNNING state yet
basic_create() {
num_instances=$1
instance_type=$2
if [ $instance_type == $TYPE_OFS_SERVER ]
then
instance_name="$OB_OFS_NAME"
machine_type_arg="$OB_OFS_MACHINE_ARG"
metadata_arg="$OB_SERVER_METADATA_ARG"
elif [ $instance_type == $TYPE_IO500_CLIENT ]
then
instance_name="$OB_IO500_NAME"
machine_type_arg="$OB_IO500_MACHINE_ARG"
metadata_arg="$OB_CLIENT_METADATA_ARG"
else
echo "invalid instance type: ${instance_type}"
ob_cleanup
fi
for i in `seq 1 $num_instances`
do
OB_CMD="$OB_CREATE""$instance_name""${OB_SUFFIX[i]}"
OB_CMD="$OB_CMD""$OB_IMAGE_ARG""$machine_type_arg""$OB_SCOPE_ARG"
OB_CMD="$OB_CMD""$OB_NET_INT""$OB_NET_PERF"
OB_CMD="$OB_CMD""$OB_THREADS_ARG"
OB_CMD="$OB_CMD""$OB_STARTUP_SCRIPT_ARG"
OB_CMD="$OB_CMD""$metadata_arg"
OB_CMD="$OB_CMD"" --no-user-output-enabled"
OB_CMD="$OB_CMD"" --async"
if [ $instance_type == $TYPE_OFS_SERVER ]
then
for j in `seq 1 $OB_SSD_NUM`
do
OB_CMD="$OB_CMD""$OB_SSD_ARG"
done
fi
if [ -n "$OB_POLICY_NAME" ]
then
if [ $instance_type == $TYPE_OFS_SERVER ]
then
if [ -n "$OB_SERVER_POLICY_OPTS" ]
then
OB_CMD="$OB_CMD""$OB_SERVER_POLICY_OPTS""$OB_POLICY_OPTS"
fi
else
if [ -n "$OB_CLIENT_POLICY_OPTS" ]
then
OB_CMD="$OB_CMD""$OB_CLIENT_POLICY_OPTS""$OB_POLICY_OPTS"
fi
fi
fi
# echo $OB_CMD
eval $OB_CMD
if [ "$?" -gt "0" ]
then
echo "creation of ""$instance_name""${OB_SUFFIX[i]}"" failed."
ob_cleanup
fi
# write instance name to file
echo "${instance_name}${OB_SUFFIX[i]}" >> "$OB_INSTANCE_FILE"
done
}
# function to create instances using the python bulk api via external script
#
# if successful, instances will be in RUNNING state upon completion
bulk_create() {
BULK_CREATE_FILENAME="bulk_create.py"
OB_CMD="python $BULK_CREATE_FILENAME"
OB_CMD+=" --project=$OB_PROJECT --region=$OB_REGION --zone=$OB_ZONE"
OB_CMD+=" --image=$OB_IMAGE --scopes=$OB_SCOPE"
OB_CMD+=" --num-servers=$OB_OFS_SERVERS --num-clients=$OB_IO500_CLIENTS"
OB_CMD+=" --server-type=$OB_OFS_MACHINE --client-type=$OB_IO500_MACHINE"
OB_CMD+=" --server-prefix=$OB_OFS_NAME --client-prefix=$OB_IO500_NAME"
OB_CMD+=" --server-metadata=$OB_SERVER_METADATA"
OB_CMD+=" --client-metadata=$OB_CLIENT_METADATA"
OB_CMD+=" --num-ssd-per-server=$OB_SSD_NUM"
OB_CMD+=" --threads-per-core=$OB_THREADS_PER_CORE"
OB_CMD+=" --output-file=$OB_INSTANCE_FILE"
if [ -n "${OB_SUBNET}" ]
then
OB_CMD+=" --subnet=$OB_SUBNET"
fi
if [ -n "${OB_POLICY_NAME}" ]
then
if [ "$OB_PLACEMENT_POLICY" == "SERVERS" ]
then
OB_CMD+=" --server-policy=$OB_POLICY_NAME"
elif [ "$OB_PLACEMENT_POLICY" == "CLIENTS" ]
then
OB_CMD+=" --client-policy=$OB_POLICY_NAME"
elif [ "$OB_PLACEMENT_POLICY" == "SEPARATE" ]
then
OB_CMD+=" --server-policy=$OB_SERVER_POLICY_NAME"
OB_CMD+=" --client-policy=$OB_CLIENT_POLICY_NAME"
fi
fi
if [ -n "${OB_NIC_TYPE}" ]
then
OB_CMD+=" --nic-type=$OB_NIC_TYPE"
fi
if [ "$OB_USE_TIER1_NET" -gt "0" ]
then
OB_CMD+=" --enable-tier1-networking"
fi
if [ -n "${OB_STARTUP_SCRIPT}" ]
then
OB_CMD+=" --startup-script=$OB_STARTUP_SCRIPT"
fi
# echo $OB_CMD
eval $OB_CMD
if [ "$?" -gt "0" ]
then
echo "creation of instances via bulk-create failed."
ob_cleanup
fi
}
# create server and client instances
if [ "$OB_USE_BULK_CREATE" -gt "0" ]
then
bulk_create
else
basic_create $OB_OFS_SERVERS $TYPE_OFS_SERVER
basic_create $OB_IO500_CLIENTS $TYPE_IO500_CLIENT
fi
# get list of created instances' names from file
if [ -e "$OB_INSTANCE_FILE" ]
then
readarray -t INSTANCE_NAMES < "$OB_INSTANCE_FILE"
readarray -t SERVER_NAMES < <(grep "$OB_OFS_NAME" "$OB_INSTANCE_FILE")
readarray -t CLIENT_NAMES < <(grep "$OB_IO500_NAME" "$OB_INSTANCE_FILE")
else
echo "ERROR: ${OB_INSTANCE_FILE} does not exist"
echo "failed to get list of created instances"
ob_cleanup
fi
# function to wait for a launched instance to reach the RUNNING state
wait_for_instance() {
instance_name=$1
instance_status=""
echo -n "Waiting for instance ${instance_name}... "
while [ "$instance_status" != "RUNNING" ]
do
sleep $OB_SLEEP
instance_status=`gcloud compute instances describe $instance_name --format='get(status)'`
done
echo "done."
}
# associative array for host names to ip addrs
declare -A OB_EX_ETC_HOSTS # external addrs
declare -A OB_IN_ETC_HOSTS # internal addrs
# function to collect an instance's external and internal IP addresses
collect_ips() {
instance_name=$1
OB_EX_ETC_HOSTS[$instance_name]=`gcloud compute instances describe $instance_name --format='get(networkInterfaces[0].accessConfigs[0].natIP)'`
if [ "$?" -gt "0" ]
then
echo "no external ip for ${instance_name}."
ob_cleanup
fi
OB_IN_ETC_HOSTS[$instance_name]=`gcloud compute instances describe $instance_name --format='get(networkInterfaces[0].networkIP)'`
if [ "$?" -gt "0" ]
then
echo "no internal ip for ${instance_name}."
ob_cleanup
fi
}
# collect the servers' external and internal IP addrs once they lanuch
for instance_name in "${SERVER_NAMES[@]}"
do
if [ "$OB_USE_BULK_CREATE" -eq "0" ]
then
# if instances were created individually, they may not be RUNNING yet
wait_for_instance $instance_name
fi
collect_ips $instance_name
done
# collect the clients' external and internal IP addrs once they launch
for instance_name in "${CLIENT_NAMES[@]}"
do
if [ "$OB_USE_BULK_CREATE" -eq "0" ]
then
# if instances were created individually, they may not be RUNNING yet
wait_for_instance $instance_name
fi
collect_ips $instance_name
done
echo ""
# Don't continue if unable to connect to ssh port in the allotted time.
echo -n "Testing connectivity to port 22 on orangefs servers. "
for host in "${SERVER_NAMES[@]}"
do
OB_EX_IP="${OB_EX_ETC_HOSTS[$host]}"
OB_TRYS=$OB_ATTEMPTS
while [ "$OB_TRYS" -gt "0" ] && ! nc -z "${OB_EX_IP}" 22
do
sleep $OB_SLEEP
OB_TRYS=$(( OB_TRYS - 1 ))
if [ "$OB_TRYS" -eq "0" ]
then
echo -e "\nno response from ${OB_EX_IP} on port 22."
ob_cleanup
fi
done
echo -n "."
done
echo " done."
echo -n "add ofs server internal IP addrs to each server's host file. "
# make a local file of host lines to add to all the cloud servers.
for host in "${SERVER_NAMES[@]}"
do
OB_IN_IP="${OB_IN_ETC_HOSTS[$host]}"
echo "$OB_IN_IP"" ""$host" >> hostfile
done
# append the local host file onto the end of all the server /etc/host files.
for host in "${SERVER_NAMES[@]}"
do
OB_EX_IP="${OB_EX_ETC_HOSTS[$host]}"
# As we run tests over and over, IP addresses will end up
# getting reused. We want to run tests without having to
# do a bunch of .ssh/known_hosts maintenance, we'll turn
# off host key checking and fling the WARNING message to dev null.
scp -o "StrictHostKeyChecking no" \
hostfile "$OB_EX_IP": > /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo -e "\nscp host file to :"$host": failed."
ob_cleanup
fi
ssh -o "StrictHostKeyChecking no" "$OB_EX_IP" \
sudo sh -c \'cat hostfile \>\> /etc/hosts\' > /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo -e "\nappend hostfile on :"$host": failed."
ob_cleanup
fi
echo -n "."
done
echo " done."
# One SSD per pvfs2-server process or two SSDs per process if separate
# IO and metadata.
if [ $(( OB_SSD_NUM / OB_OFS_PER_INSTANCE )) -eq "1" ] ||
[ $(( OB_SSD_NUM / OB_OFS_PER_INSTANCE )) -eq "2" -a \
"$OB_SEPARATE_DATA_META" -eq "1" ]
then
for host in "${SERVER_NAMES[@]}"
do
OB_EX_IP="${OB_EX_ETC_HOSTS[$host]}"
for j in `seq 1 $OB_SSD_NUM`
do
OB_LABEL="parted /dev/nvme0n"$j" --script mklabel gpt"
ssh -o "StrictHostKeyChecking no" "$OB_EX_IP" \
sudo sh -c \'"$OB_LABEL"\' > /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo "labeling failed "$host" "$j
ob_cleanup
fi
OB_PARTITION="parted -a optimal /dev/nvme0n"$j
OB_PARTITION=$OB_PARTITION" --script mkpart"
OB_PARTITION=$OB_PARTITION" primary ext4 2048 375GB"
ssh -o "StrictHostKeyChecking no" "$OB_EX_IP" \
sudo sh -c \'"$OB_PARTITION"\' > /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo "Partitioning failed "$host" "$j
ob_cleanup
fi
OB_MKFS="mkfs.ext4 -F /dev/nvme0n"$j"p1"
ssh -o "StrictHostKeyChecking no" "$OB_EX_IP" \
sudo sh -c \'"$OB_MKFS"\' > /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo "mkfs failed "$host" "$j
ob_cleanup
fi
if [ "$OB_SEPARATE_DATA_META" -eq "1" ]
then
if [ $(( j % 2 )) -eq 0 ]
then
index=$(( j / 2 ))
mount_point="$OB_MOUNT_POINT""${port[$index]}"
mount_point="$mount_point""/meta"
else
index=$((( j + 1) / 2 ))
mount_point="$OB_MOUNT_POINT""${port[$index]}"
mount_point="$mount_point""/data"
fi
else
mount_point="$OB_MOUNT_POINT""${port[$j]}"
fi
ssh -o "StrictHostKeyChecking no" "$OB_EX_IP" \
sudo sh -c \'mkdir -m 777 -p "$mount_point"\' \
> /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo "mkdir mount point "$host" "$j
ob_cleanup
fi
OB_MOUNT="mount /dev/nvme0n"$j"p1 ""$mount_point"
ssh -o "StrictHostKeyChecking no" "$OB_EX_IP" \
sudo sh -c \'"$OB_MOUNT"\' > /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo "mount failed "$host" "$j
ob_cleanup
fi
echo "SSD #"$j" mounted on "$host
# add to /etc/fstab for automount on reboot
index=$((j-1))
device="/dev/disk/by-id/google-local-nvme-ssd-${index}-part1"
cmd="echo UUID=\$(blkid -s UUID -o value ${device})"
cmd+=" ${mount_point} ext4 discard,defaults,nofail 0 2"
cmd+=" | sudo tee -a /etc/fstab"
ssh -o "StrictHostKeyChecking no" "$OB_EX_IP" \
sudo sh -c \'${cmd}\' > /dev/null 2>&1
echo "SSD #${j} added to /etc/fstab for automount on reboot"
done
done
else
# More than one SSD per orangefs server.
for host in "${SERVER_NAMES[@]}"
do
OB_EX_IP="${OB_EX_ETC_HOSTS[$host]}"
ssd_per_ofs=$(( OB_SSD_NUM / OB_OFS_PER_INSTANCE))
ssd_start=1
ssd_end=$ssd_per_ofs
for j in `seq 1 $OB_OFS_PER_INSTANCE`
do
echo "mount md"$j" on "$host
OB_MDADM="mdadm --create /dev/md"$j
OB_MDADM="$OB_MDADM"" --level=0 --raid-devices="
OB_MDADM="$OB_MDADM""$ssd_per_ofs"
for k in `seq $ssd_start $ssd_end`
do
OB_MDADM="$OB_MDADM"" $OB_SSD_DEV""$k"
done
ssd_start=$(( ssd_start + ssd_per_ofs ))
ssd_end=$(( ssd_end + ssd_per_ofs ))
ssh -o "StrictHostKeyChecking no" "$OB_EX_IP" \
sudo sh -c \'"$OB_MDADM"\' > /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo "mdadm failed for "$host" "$ssd_start
ob_cleanup
fi
ssh -o "StrictHostKeyChecking no" "$OB_EX_IP" sudo \
sh -c \'mkfs.ext4 -F /dev/md"$j"\' \
> /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo "mkfs failed for "$host" "$j
ob_cleanup
fi
mount_point="$OB_MOUNT_POINT""${port[$j]}"
ssh -o "StrictHostKeyChecking no" "$OB_EX_IP" \
sudo sh -c \'mkdir "$mount_point"\' \
> /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo "mkdir mount point "$host" "$j
ob_cleanup
fi
ssh -o "StrictHostKeyChecking no" "$OB_EX_IP" sudo \
sh -c \'mount /dev/md"$j" \
"$mount_point"\' > /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo "mount failed "$host" "$j
ob_cleanup
fi
echo "RAID mounted on "$host" "$j
# add to /etc/fstab for automount on reboot
cmd="echo UUID=\$(blkid -s UUID -o value /dev/md${j})"
cmd+=" ${mount_point} ext4 discard,defaults,nofail 0 2"
cmd+=" | sudo tee -a /etc/fstab"
ssh -o "StrictHostKeyChecking no" "$OB_EX_IP" \
sudo sh -c \'${cmd}\' > /dev/null 2>&1
echo "md${j} array added to /etc/fstab for automount on reboot"
done
done
fi
echo
# create arrays of data and meta servers and use them to build
# a pvfs2-genconfig command, which will end up looking something like this:
# pvfs2-genconfig --iospec one:3334,two:3334,three:3334,four:3334 \
# --metaspec one:3334,two:3334 --quiet pvfs.conf
row=1
for host in "${SERVER_NAMES[@]}"
do
for j in `seq 1 $OB_OFS_PER_INSTANCE`
do
this_pvfs2_server=${host}:${port[$j]}
case ${OB_LAYOUT[$(( row + j - 1 ))]} in
b) OB_DATA_ARRAY+=($this_pvfs2_server)
OB_META_ARRAY+=($this_pvfs2_server);;
m) OB_META_ARRAY+=($this_pvfs2_server);;
d) OB_DATA_ARRAY+=($this_pvfs2_server);;
*) echo "ERROR"
echo "server ${host} instance ${j}"
echo ${OB_LAYOUT[$(( row + j - 1 ))]}
ob_cleanup;;
esac
done
row=$((( row * j ) + 1 ))
done
# add the list of data servers to the pvfs2-genconfig command
for i in "${OB_DATA_ARRAY[@]}"
do
OB_OFS_CONFIG="$OB_OFS_CONFIG"`echo -n $i`","
done
# chop off the trailing comma and get ready for the meta list
OB_OFS_CONFIG=`echo ${OB_OFS_CONFIG%?}`" --metaspec "
for i in "${OB_META_ARRAY[@]}"
do
OB_OFS_CONFIG="$OB_OFS_CONFIG"`echo -n $i`","
done
# chop off the trailing comma and finish building the command
OB_OFS_CONFIG=`echo ${OB_OFS_CONFIG%?}`" --filesystem-dbmaxsize ""$OB_DBMAXSIZE"
OB_OFS_CONFIG="$OB_OFS_CONFIG"" --dist-name ""$OB_DIST_NAME"
OB_OFS_CONFIG="$OB_OFS_CONFIG"" --dist-params=""$OB_DIST_PARAMS"
OB_OFS_CONFIG="$OB_OFS_CONFIG"" --quiet ""$OB_OFS_CONFIG_FILE_NAME"
echo ":""$OB_OFS_CONFIG"":"
eval "$OB_OFS_CONFIG"
# change the DataStorageSpace and MetadataStorageSpace
# designations to coincide with where we mounted the SSD
# drives.
echo -n "edit config file mount points. "
for host in "${SERVER_NAMES[@]}"
do
OB_EX_IP="${OB_EX_ETC_HOSTS[$host]}"
for j in `seq 1 $OB_OFS_PER_INSTANCE`
do
mount_point="$OB_MOUNT_POINT""${port[$j]}"
datastorage=$mount_point/data
metastorage=$mount_point/meta
escape_slashes=$(echo $datastorage | sed 's/\//\\\//g')
sed -i 's/D.*'$host'.*'${port[$j]}'/DataStorageSpace '$escape_slashes'/' orangefs.conf
if [ "$?" -gt "0" ]
then
echo -e "\ncan't edit data storage :"$host":"$j":"
ob_cleanup
fi
escape_slashes=$(echo $metastorage | sed 's/\//\\\//g')
sed -i 's/M.*'$host'.*'${port[$j]}'/MetadataStorageSpace '$escape_slashes'/' orangefs.conf
if [ "$?" -gt "0" ]
then
echo -e "\ncan't edit meta storage :"$host":"$j":"
ob_cleanup
fi
done
done
echo " done."
echo -n "start the servers. "
for host in "${SERVER_NAMES[@]}"
do
OB_EX_IP="${OB_EX_ETC_HOSTS[$host]}"
for j in `seq 1 $OB_OFS_PER_INSTANCE`
do
# deduce my whacky alias from the autogenned conf file.
me=`grep "^ Alias " "$OB_OFS_CONFIG_FILE_NAME" | \
grep $host | \
sed $j'q;d' | \
awk '{ print $2 }'`
# vague sanity check...
if [ `grep Alias "$OB_OFS_CONFIG_FILE_NAME" | \
grep "$me" | \
wc -l` -ne "1" ]
then
echo -e "\nI don't know who I am :"$me":"
ob_cleanup
fi
# copy over the config file.
scp -o "StrictHostKeyChecking no" "$OB_OFS_CONFIG_FILE_NAME" \
"$OB_EX_IP": > /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo -e "\nscp ofs config to :"$host": failed."
ob_cleanup
fi
ssh -o "StrictHostKeyChecking no" "$OB_EX_IP" sudo \
pvfs2-server "$OB_OFS_CONFIG_FILE_NAME" -f \
-a "$me" \
> /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo -e "\nstorage failed on :"$host":"$j":"
ob_cleanup
fi
ssh -o "StrictHostKeyChecking no" "$OB_EX_IP" sudo \
pvfs2-server "$OB_OFS_CONFIG_FILE_NAME" \
-a "$me" \
> /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo -e "\nofs server on :"$host":""$j"" failed."
ob_cleanup
fi
echo -n "."
done
done
echo " done."
echo
# check connectivity on io500 clients.
echo -n "Testing connectivity to port 22 on io500 clients. "
for host in "${CLIENT_NAMES[@]}"
do
OB_EX_IP="${OB_EX_ETC_HOSTS[$host]}"
OB_TRYS=$OB_ATTEMPTS
while [ "$OB_TRYS" -gt "0" ] && ! nc -z ${OB_EX_IP} 22
do
sleep $OB_SLEEP
OB_TRYS=$(( OB_TRYS - 1 ))
if [ "$OB_TRYS" -eq "0" ]
then
echo -e "\nno response from ${OB_EX_IP} on port 22."
ob_cleanup
fi
done
echo -n "."
done
echo " done."
echo -n "add io500 client internal IP addrs to each clients's host file. "
for host in "${CLIENT_NAMES[@]}"
do
OB_IN_IP="${OB_IN_ETC_HOSTS[$host]}"
echo "$OB_IN_IP"" ""$host" >> hostfile
done
# append the local host file onto the end of all the io500 client host files.
for host in "${CLIENT_NAMES[@]}"
do
OB_EX_IP="${OB_EX_ETC_HOSTS[$host]}"
scp -o "StrictHostKeyChecking no" \
hostfile "$OB_EX_IP": > /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo -e "\nscp host file to :"$host": failed."
ob_cleanup
fi
ssh -o "StrictHostKeyChecking no" "$OB_EX_IP" \
sudo sh -c \'cat hostfile \>\> /etc/hosts\' > /dev/null 2>&1
if [ "$?" -gt "0" ]
then
echo -e "\nappend hostfile on :"$host": failed."
ob_cleanup
fi
echo -n "."
done
echo " done."
# "third party" ssh tools such as mpirun need to be usable
# on the clients without interaction from a human... set up
# passwordless ssh access between the client instances:
# + generate a keypair for each client