New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AWS EBS volume support #5138
Merged
Merged
AWS EBS volume support #5138
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
edf0292
Add initial support for Volumes to AWS
justinsb 8fde691
Fix tests
justinsb ffadd55
Fix AWS region vs zone
justinsb 6a4153f
Always create volumes in the active k8s zone
justinsb 2812936
Simplify logic of pd.go
justinsb 8908990
Fix merge problems
justinsb 743f2ed
Fix tests
justinsb e56e2ee
Strip leading slash from url path when parsing aws volume
justinsb 49543ac
Update IAM permissions for minion, to allow EBS
justinsb 86ddc0f
Fix mountpoint values
justinsb ee72fa4
Tolerate volume being already-attached
justinsb f2184e0
Fix comment
justinsb 6c823db
Small clean-ups
justinsb b9fd560
Add safe_format_and_mount script to aws
justinsb 3549b30
Add missing import
justinsb a366f9e
Create the /usr/share/google dir in salt
justinsb f0cedd7
More logging around error causes
justinsb cdc569a
Parse the pdName from the volume mount
justinsb 21beabd
Default attachment status to detached
justinsb 3689bf0
Fix pd name parse
justinsb 0101bf2
Fix detached-check logic, warn on multiple attachments
justinsb aa60510
Add comment about EBS status being a bit slow through API
justinsb 95b68ae
Rename pdName -> volumeId for AWS persistent volumes
justinsb 2e91fdd
Fixup merge mistakes
justinsb b3666ed
Add AWSPersistentDisk to fuzzer
justinsb 9711e77
Rename AWSPersistentDisk -> AWSElasticBlockStore, aws-pd -> aws-ebs
justinsb a20484b
Apply latest changes from copy-and-pasted gce_pd
justinsb c7c9695
Add missing conversion for v1beta2
justinsb 4e17677
Make fetching the aws instance id optional, so we can use it on e2e
justinsb 5a887e8
Remove now-unused instanceId parameter from newAwsCloud
justinsb 034412a
Support multiple k8s clusters
justinsb 9561366
Provide more output during a disk delete
justinsb 7e758fe
Grammar fix: s/a AWS/an AWS/g
justinsb 46f9c2c
Style: Ebs -> EBS
justinsb 2afc184
Style: awsId -> awsID
justinsb 98c9ebb
Style: Aws -> AWS
justinsb 933cf60
Style: volumeId -> volumeID
justinsb 503e19e
Rename aws_pd -> aws_ebs
justinsb 9462471
Fix some mistaken volumeId -> volumeID changes
justinsb 7626914
Rename aws_pd.go -> aws_ebs.go, aws_pd_test.go -> aws_ebs_test.go
justinsb File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% if grains['cloud'] is defined and grains['cloud'] == 'aws' %} | ||
/usr/share/google: | ||
file.directory: | ||
- user: root | ||
- group: root | ||
- dir_mode: 755 | ||
|
||
/usr/share/google/safe_format_and_mount: | ||
file.managed: | ||
- source: salt://helpers/safe_format_and_mount | ||
- user: root | ||
- group: root | ||
- mode: 755 | ||
{% endif %} |
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 |
---|---|---|
@@ -0,0 +1,145 @@ | ||
#! /bin/bash | ||
# Copyright 2013 Google Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Mount a disk, formatting it if necessary. If the disk looks like it may | ||
# have been formatted before, we will not format it. | ||
# | ||
# This script uses blkid and file to search for magic "formatted" bytes | ||
# at the beginning of the disk. Furthermore, it attempts to use fsck to | ||
# repair the filesystem before formatting it. | ||
|
||
FSCK=fsck.ext4 | ||
MOUNT_OPTIONS="discard,defaults" | ||
MKFS="mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 -F" | ||
if grep -q '6\..' /etc/redhat-release; then | ||
# lazy_journal_init is not recognized in redhat 6 | ||
MKFS="mkfs.ext4 -E lazy_itable_init=0 -F" | ||
elif grep -q '7\..' /etc/redhat-release; then | ||
FSCK=fsck.xfs | ||
MKFS=mkfs.xfs | ||
fi | ||
|
||
LOGTAG=safe_format_and_mount | ||
LOGFACILITY=user | ||
|
||
function log() { | ||
local readonly severity=$1; shift; | ||
logger -t ${LOGTAG} -p ${LOGFACILITY}.${severity} -s "$@" | ||
} | ||
|
||
function log_command() { | ||
local readonly log_file=$(mktemp) | ||
local readonly retcode | ||
log info "Running: $*" | ||
$* > ${log_file} 2>&1 | ||
retcode=$? | ||
# only return the last 1000 lines of the logfile, just in case it's HUGE. | ||
tail -1000 ${log_file} | logger -t ${LOGTAG} -p ${LOGFACILITY}.info -s | ||
rm -f ${log_file} | ||
return ${retcode} | ||
} | ||
|
||
function help() { | ||
cat >&2 <<EOF | ||
$0 [-f fsck_cmd] [-m mkfs_cmd] [-o mount_opts] <device> <mountpoint> | ||
EOF | ||
exit 0 | ||
} | ||
|
||
while getopts ":hf:o:m:" opt; do | ||
case $opt in | ||
h) help;; | ||
f) FSCK=$OPTARG;; | ||
o) MOUNT_OPTIONS=$OPTARG;; | ||
m) MKFS=$OPTARG;; | ||
-) break;; | ||
\?) log error "Invalid option: -${OPTARG}"; exit 1;; | ||
:) log "Option -${OPTARG} requires an argument."; exit 1;; | ||
esac | ||
done | ||
|
||
shift $(($OPTIND - 1)) | ||
readonly DISK=$1 | ||
readonly MOUNTPOINT=$2 | ||
|
||
[[ -z ${DISK} ]] && help | ||
[[ -z ${MOUNTPOINT} ]] && help | ||
|
||
function disk_looks_unformatted() { | ||
blkid ${DISK} | ||
if [[ $? == 0 ]]; then | ||
return 0 | ||
fi | ||
|
||
local readonly file_type=$(file --special-files ${DISK}) | ||
case ${file_type} in | ||
*filesystem*) | ||
return 0;; | ||
esac | ||
|
||
return 1 | ||
} | ||
|
||
function format_disk() { | ||
log_command ${MKFS} ${DISK} | ||
} | ||
|
||
function try_repair_disk() { | ||
log_command ${FSCK} -a ${DISK} | ||
local readonly fsck_return=$? | ||
if [[ ${fsck_return} -ge 8 ]]; then | ||
log error "Fsck could not correct errors on ${DISK}" | ||
return 1 | ||
fi | ||
if [[ ${fsck_return} -gt 0 ]]; then | ||
log warning "Fsck corrected errors on ${DISK}" | ||
fi | ||
return 0 | ||
} | ||
|
||
function try_mount() { | ||
local mount_retcode | ||
try_repair_disk | ||
|
||
log_command mount -o ${MOUNT_OPTIONS} ${DISK} ${MOUNTPOINT} | ||
mount_retcode=$? | ||
if [[ ${mount_retcode} == 0 ]]; then | ||
return 0 | ||
fi | ||
|
||
# Check to see if it looks like a filesystem before formatting it. | ||
disk_looks_unformatted ${DISK} | ||
if [[ $? == 0 ]]; then | ||
log error "Disk ${DISK} looks formatted but won't mount. Giving up." | ||
return ${mount_retcode} | ||
fi | ||
|
||
# The disk looks like it's not been formatted before. | ||
format_disk | ||
if [[ $? != 0 ]]; then | ||
log error "Format of ${DISK} failed." | ||
fi | ||
|
||
log_command mount -o ${MOUNT_OPTIONS} ${DISK} ${MOUNTPOINT} | ||
mount_retcode=$? | ||
if [[ ${mount_retcode} == 0 ]]; then | ||
return 0 | ||
fi | ||
log error "Tried everything we could, but could not mount ${DISK}." | ||
return ${mount_retcode} | ||
} | ||
|
||
try_mount | ||
exit $? |
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ base: | |
{% else %} | ||
- sdn | ||
{% endif %} | ||
- helpers | ||
- cadvisor | ||
- kubelet | ||
- kube-proxy | ||
|
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is "gce_zone" correct here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is tricky. I'm not sure whether we want flags for each provider (i.e. potentially duplicate kube_master, gce_project, gce_zone -> aws_kube_master, aws_gce_project, aws_gce_zone) or whether we should treat these as "cloud_project" & "cloud_zone". If the latter, a secondary question is whether we should rename the flags.
Edit: I don't much care either way. I'm guessing we'll end up with duplicating (i.e. aws_zone)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can only have one cloud provider at a time, right? Perhaps this is a good place for generic cloud patterns, so long as it's not planned to allow a cluster span infrastructure providers... If that's the case, that's probably an easy small PR instead of adding more to this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the concepts fundamentally match up, I'm in favor of generification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with not renaming in this PR, but please file a bug on this. We just need to figure out the ripple of renaming them.