Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit 10d58b4

Browse files
committed
Changed the ISCSI detection process to be more sane.
1 parent 90278e0 commit 10d58b4

File tree

2 files changed

+104
-41
lines changed

2 files changed

+104
-41
lines changed

scripts/boot.sh

Lines changed: 70 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,6 @@ mkdir -p /usr/share/java/
124124
cd mysql-connector-java-5.1.46
125125
cp mysql-connector-java-5.1.46-bin.jar /usr/share/java/mysql-connector-java.jar
126126

127-
EXECNAME="SLEEP"
128-
log "->START"
129-
sleep 300
130-
# Sleep for 5 minutes to allow block volume attachments time to finish
131-
log "->DONE"
132-
133127
#
134128
# DISK SETUP
135129
#
@@ -187,30 +181,66 @@ iscsi_target_only(){
187181

188182
## Look for all ISCSI devices in sequence, finish on first failure
189183
EXECNAME="ISCSI"
190-
done="0"
191-
log "-- Detecting Block Volumes --"
192-
for i in `seq 2 33`; do
193-
if [ $done = "0" ]; then
194-
iscsiadm -m discoverydb -D -t sendtargets -p 169.254.2.$i:3260 2>&1 2>/dev/null
195-
iscsi_chk=`echo -e $?`
196-
if [ $iscsi_chk = "0" ]; then
197-
# IQN list is important set up this array with discovered IQNs
198-
iqn[${i}]=`iscsiadm -m discoverydb -D -t sendtargets -p 169.254.2.${i}:3260 | gawk '{print $2}'`
199-
log "-> Discovered volume $((i-1)) - IQN: ${iqn[${i}]}"
200-
continue
201-
else
202-
log "--> Discovery Complete - ${#iqn[@]} volumes found"
203-
done="1"
184+
log "- Begin Block Volume Detection Loop -"
185+
detection_flag="0"
186+
while [ "$detection_flag" = "0" ]; do
187+
detection_done="0"
188+
log "-- Detecting Block Volumes --"
189+
for i in `seq 2 33`; do
190+
if [ $detection_done = "0" ]; then
191+
iscsiadm -m discoverydb -D -t sendtargets -p 169.254.2.$i:3260 2>&1 2>/dev/null
192+
iscsi_chk=`echo -e $?`
193+
if [ $iscsi_chk = "0" ]; then
194+
# IQN list is important set up this array with discovered IQNs
195+
iqn[${i}]=`iscsiadm -m discoverydb -D -t sendtargets -p 169.254.2.${i}:3260 | gawk '{print $2}'`
196+
log "-> Discovered volume $((i-1)) - IQN: ${iqn[${i}]}"
197+
continue
198+
else
199+
volume_count="${#iqn[@]}"
200+
log "--> Discovery Complete - ${#iqn[@]} volumes found"
201+
detection_done="1"
202+
fi
204203
fi
204+
done;
205+
## Now let's do this again after a 30 second sleep to ensure consistency in case this ran in the middle of volume attachments
206+
sleep 30
207+
sanity_detection_done="0"
208+
sanity_volume_count="0"
209+
for i in `seq 2 33`; do
210+
if [ $sanity_detection_done = "0" ]; then
211+
iscsiadm -m discoverydb -D -t sendtargets -p 169.254.2.$i:3260 2>&1 2>/dev/null
212+
iscsi_chk=`echo -e $?`
213+
if [ $iscsi_chk = "0" ]; then
214+
# IQN list is important set up this array with discovered IQNs
215+
siqn[${i}]=`iscsiadm -m discoverydb -D -t sendtargets -p 169.254.2.${i}:3260 | gawk '{print $2}'`
216+
continue
217+
else
218+
sanity_volume_count="${#siqn[@]}"
219+
log "--> Sanity Discovery Complete - ${#siqn[@]} volumes found"
220+
sanity_detection_done="1"
221+
fi
222+
fi
223+
done;
224+
if [ "$volume_count" = "0" ]; then
225+
log "-- $volume_count Block Volumes detected, sleeping 30 then retry --"
226+
sleep 30
227+
continue
228+
elif [ "$volume_count" != "$sanity_volume_count" ]; then
229+
log "-- Sanity Check Failed - $sanity_volume_count Volumes found, $volume_count on first run. Re-running --"
230+
sleep 15
231+
continue
232+
elif [ "$volume_count" = "$sanity_volume_count" ]; then
233+
log "-- Setup for ${#iqn[@]} Block Volumes --"
234+
for i in `seq 1 ${#iqn[@]}`; do
235+
n=$((i+1))
236+
iscsi_setup
237+
done;
238+
detection_flag="1"
239+
else
240+
log "-- Repeating Detection --"
241+
continue
205242
fi
206243
done;
207-
if [ ${#iqn[@]} -gt 0 ]; then
208-
log "-- Setup for ${#iqn[@]} Block Volumes --"
209-
for i in `seq 1 ${#iqn[@]}`; do
210-
n=$((i+1))
211-
iscsi_setup
212-
done;
213-
fi
214244

215245
EXECNAME="boot.sh - DISK PROVISIONING"
216246
#
@@ -256,23 +286,31 @@ for i in `seq 1 ${#iqn[@]}`; do
256286
vol_match
257287
log "-->Checking /dev/oracleoci/$disk"
258288
if [ -h /dev/oracleoci/$disk ]; then
259-
mke2fs -F -t ext4 -b 4096 -E lazy_itable_init=1 -O sparse_super,dir_index,extent,has_journal,uninit_bg -m1 /dev/oracleoci/$disk
260-
if [ $disk = "oraclevdb" ]; then
289+
case $disk in
290+
oraclevdb)
291+
mke2fs -F -t ext4 -b 4096 -E lazy_itable_init=1 -O sparse_super,dir_index,extent,has_journal,uninit_bg -m1 /dev/oracleoci/$disk
261292
log "--->Mounting /dev/oracleoci/$disk to /var/log/cloudera"
262293
mkdir -p /var/log/cloudera
263294
mount -o noatime,barrier=1 -t ext4 /dev/oracleoci/$disk /var/log/cloudera
264295
UUID=`lsblk -no UUID /dev/oracleoci/$disk`
265296
echo "UUID=$UUID /var/log/cloudera ext4 defaults,_netdev,nofail,noatime,discard,barrier=0 0 2" | tee -a /etc/fstab
266-
elif [ $disk = "oraclevdc" ]; then
297+
mkdir -p /var/log/cloudera/cloudera-scm-agent
298+
ln -s /var/log/cloudera/cloudera-scm-agent /var/log/cloudera-scm-agent
299+
;;
300+
oraclevdc)
301+
mke2fs -F -t ext4 -b 4096 -E lazy_itable_init=1 -O sparse_super,dir_index,extent,has_journal,uninit_bg -m1 /dev/oracleoci/$disk
267302
log "--->Mounting /dev/oracleoci/$disk to /opt/cloudera"
268303
mkdir -p /opt/cloudera
269304
mount -o noatime,barrier=1 -t ext4 /dev/oracleoci/$disk /opt/cloudera
270305
UUID=`lsblk -no UUID /dev/oracleoci/$disk`
271306
echo "UUID=$UUID /opt/cloudera ext4 defaults,_netdev,nofail,noatime,discard,barrier=0 0 2" | tee -a /etc/fstab
272-
else
307+
;;
308+
*)
309+
mke2fs -F -t ext4 -b 4096 -E lazy_itable_init=1 -O sparse_super,dir_index,extent,has_journal,uninit_bg -m1 /dev/oracleoci/$disk
273310
block_data_mount
274311
dcount=$((dcount+1))
275-
fi
312+
;;
313+
esac
276314
/sbin/tune2fs -i0 -c0 /dev/oracleoci/$disk
277315
dsetup="1"
278316
else

scripts/boot_plus_tmp.sh

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ iscsi_target_only(){
182182
## Look for all ISCSI devices in sequence, finish on first failure
183183
EXECNAME="ISCSI"
184184
log "- Begin Block Volume Detection Loop -"
185-
volume_count="0"
186-
while [ "$volume_count" -lt 2 ]; do
185+
detection_flag="0"
186+
while [ "$detection_flag" = "0" ]; do
187187
detection_done="0"
188188
log "-- Detecting Block Volumes --"
189189
for i in `seq 2 33`; do
@@ -202,18 +202,43 @@ while [ "$volume_count" -lt 2 ]; do
202202
fi
203203
fi
204204
done;
205-
if [ "$volume_count" = 0 ]; then
206-
log "-- Sleeping 60 then retry detection --"
207-
sleep 60
208-
elif [ "$volume_count" = 1]; then
209-
log "-- Sleeping 60 then retry detection --"
210-
sleep 60
211-
else
205+
## Now let's do this again after a 30 second sleep to ensure consistency in case this ran in the middle of volume attachments
206+
sleep 30
207+
sanity_detection_done="0"
208+
sanity_volume_count="0"
209+
for i in `seq 2 33`; do
210+
if [ $sanity_detection_done = "0" ]; then
211+
iscsiadm -m discoverydb -D -t sendtargets -p 169.254.2.$i:3260 2>&1 2>/dev/null
212+
iscsi_chk=`echo -e $?`
213+
if [ $iscsi_chk = "0" ]; then
214+
# IQN list is important set up this array with discovered IQNs
215+
siqn[${i}]=`iscsiadm -m discoverydb -D -t sendtargets -p 169.254.2.${i}:3260 | gawk '{print $2}'`
216+
continue
217+
else
218+
sanity_volume_count="${#siqn[@]}"
219+
log "--> Sanity Discovery Complete - ${#siqn[@]} volumes found"
220+
sanity_detection_done="1"
221+
fi
222+
fi
223+
done;
224+
if [ "$volume_count" = "0" ]; then
225+
log "-- $volume_count Block Volumes detected, sleeping 30 then retry --"
226+
sleep 30
227+
continue
228+
elif [ "$volume_count" != "$sanity_volume_count" ]; then
229+
log "-- Sanity Check Failed - $sanity_volume_count Volumes found, $volume_count on first run. Re-running --"
230+
sleep 15
231+
continue
232+
elif [ "$volume_count" = "$sanity_volume_count" ]; then
212233
log "-- Setup for ${#iqn[@]} Block Volumes --"
213234
for i in `seq 1 ${#iqn[@]}`; do
214235
n=$((i+1))
215236
iscsi_setup
216237
done;
238+
detection_flag="1"
239+
else
240+
log "-- Repeating Detection --"
241+
continue
217242
fi
218243
done;
219244

0 commit comments

Comments
 (0)