Merge pull request #30038 from adityakali/gci53

Automatic merge from submit-queue

Remove use of /usr/share/google/safe_format_and_mount script from GCI

This script was provided by Google Compute Image Packages
(https://github.com/GoogleCloudPlatform/compute-image-packages) and
has been deprecated since over an year. Newer version of the package
doesn't include it at all. So remove its usage and instead follow
recommended instructions from
https://cloud.google.com/compute/docs/disks/add-persistent-disk#formatting.

cc @kubernetes/goog-image
pull/6/head
Kubernetes Submit Queue 2016-08-05 00:54:20 -07:00 committed by GitHub
commit 6c81ba5b71
1 changed files with 22 additions and 6 deletions

View File

@ -48,16 +48,32 @@ function create-dirs {
fi
}
# Formats the given device ($1) if needed and mounts it at given mount point
# ($2).
function safe-format-and-mount() {
device=$1
mountpoint=$2
# Format only if the disk is not already formatted.
if ! tune2fs -l "${device}" ; then
echo "Formatting '${device}'"
mkfs.ext4 -F -E lazy_itable_init=0,lazy_journal_init=0,discard "${device}"
fi
mkdir -p "${mountpoint}"
echo "Mounting '${device}' at '${mountpoint}'"
mount -o discard,defaults "${device}" "${mountpoint}"
}
# Local ssds, if present, are mounted at /mnt/disks/ssdN.
function ensure-local-ssds() {
for ssd in /dev/disk/by-id/google-local-ssd-*; do
if [ -e "${ssd}" ]; then
ssdnum=`echo ${ssd} | sed -e 's/\/dev\/disk\/by-id\/google-local-ssd-\([0-9]*\)/\1/'`
ssdmount="/mnt/disks/ssd${ssdnum}/"
echo "Formatting and mounting local SSD $ssd to ${ssdmount}"
mkdir -p ${ssdmount}
/usr/share/google/safe_format_and_mount -m "mkfs.ext4 -F" "${ssd}" ${ssdmount} || \
{ echo "Local SSD $ssdnum mount failed"; return 1; }
safe-format-and-mount "${ssd}" ${ssdmount}
echo "Mounted local SSD $ssd at ${ssdmount}"
chmod a+w ${ssdmount}
else
echo "No local SSD disks found."
@ -124,7 +140,7 @@ function find-master-pd {
# Mounts a persistent disk (formatting if needed) to store the persistent data
# on the master -- etcd's data, a few settings, and security certs/keys/tokens.
# safe_format_and_mount only formats an unformatted disk, and mkdir -p will
# safe-format-and-mount only formats an unformatted disk, and mkdir -p will
# leave a directory be if it already exists.
function mount-master-pd {
find-master-pd
@ -138,8 +154,8 @@ function mount-master-pd {
# Format and mount the disk, create directories on it for all of the master's
# persistent data, and link them to where they're used.
mkdir -p "${mount_point}"
/usr/share/google/safe_format_and_mount -m "mkfs.ext4 -F" "${pd_path}" "${mount_point}" &>/var/log/master-pd-mount.log || \
{ echo "!!! master-pd mount failed, review /var/log/master-pd-mount.log !!!"; return 1; }
safe-format-and-mount "${pd_path}" "${mount_point}"
echo "Mounted master-pd '${pd_path}' at '${mount_point}'"
# NOTE: These locations on the PD store persistent data, so to maintain
# upgradeability, these locations should not change. If they do, take care