From ed91c76f9f866bf5d14583f5047aa595994e88e3 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Mon, 5 May 2014 15:09:02 -0700 Subject: [PATCH] maint(coreos-base/oem-ec2-compat): Remove c10n based etcd bootstrapping --- .../oem-ec2-compat/files/cloud-config.yml | 14 --- .../oem-ec2-compat/files/coreos-c10n | 118 ------------------ .../oem-ec2-compat/files/etcd-bootstrap | 34 ----- ...ebuild => oem-ec2-compat-0.0.1-r14.ebuild} | 0 .../oem-ec2-compat-0.0.1.ebuild | 2 - 5 files changed, 168 deletions(-) delete mode 100755 sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/coreos-c10n delete mode 100755 sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/etcd-bootstrap rename sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/{oem-ec2-compat-0.0.1-r13.ebuild => oem-ec2-compat-0.0.1-r14.ebuild} (100%) diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/cloud-config.yml b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/cloud-config.yml index c9b38599a4..0551114a15 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/cloud-config.yml +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/cloud-config.yml @@ -26,20 +26,6 @@ coreos: Type=oneshot EnvironmentFile=/etc/environment ExecStart=/usr/bin/coreos-cloudinit -ignore-failure=true -from-url=http://169.254.169.254/latest/user-data - - name: ec2-c10n.service - command: restart - runtime: yes - content: | - [Unit] - Description=Legacy c10n support from EC2-style metadata - Requires=ec2-cloudinit.service - After=ec2-cloudinit.service - ConditionPathIsMountPoint=!/usr - - [Service] - Type=oneshot - RemainAfterExit=no - ExecStart=/usr/share/oem/bin/coreos-c10n oem: id: @@OEM_ID@@ name: @@OEM_NAME@@ diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/coreos-c10n b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/coreos-c10n deleted file mode 100755 index 613bf4108f..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/coreos-c10n +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash - -depwarn() { - DOCS="https://github.com/coreos/coreos-cloudinit#cloud-config" - echo "DEPRECATION WARNING! $1 See docs for the new cloud-config format here: $DOCS" 1>&2; -} - -# this will only run on generic images - -C10N_ENDPOINT=https://core-api.appspot.com/v1/c10n/group -META_URL="http://169.254.169.254/latest" - -ETCD_SERVICE_D="/run/systemd/system/etcd.service.d" -mkdir -p $ETCD_SERVICE_D - -/usr/bin/block-until-url $META_URL -IP=$(curl -s $META_URL/meta-data/local-ipv4) - -# Attempt to download userdata, exiting on failure or no user-data is found -USER_DATA=$(curl -s --fail $META_URL/user-data) -retcode=$? - -# exit code 22 is http code 404, meaning user-data is blank -if [[ $retcode -ne 0 && $retcode -ne 22 ]]; then - echo "Unable to communicate with EC2 metadata service" - exit 1 -elif [[ $retcode -eq 22 || -z "${USER_DATA}" ]]; then - echo "No user-data provided" - exit 0 -fi - -# Preserve the original user-data contents to use as the c10n token in case -# a discovery URL is not provided. -C10N_TOKEN="${USER_DATA}" - -# If user-data is an HTTPS url, follow it -if echo "${USER_DATA}" | grep -q '^https://'; then - depwarn "Resolving user-data as a URL is deprecated." - - # Backwards compatibility. If we have a GitHub gist that doesn't end in /raw, we'll append it to before grabbing the gist - if echo "${USER_DATA}" | grep -e '^https://gist.github.com' | grep -v -e 'raw$'; then - USER_DATA="${USER_DATA}/raw" - fi - - echo "Downloading contents of URL: ${USER_DATA}" - - USER_DATA="$(curl -s $USER_DATA)" -fi - -# Create temporary file that gets cleaned up on exit -TMP=$(mktemp) -trap "rm -f ${TMP}" EXIT - -# Write user-data to disk for future validation -echo "${USER_DATA}" > $TMP - -# If user-data is a script, execute it -if head -n 1 $TMP | grep -q '^#!'; then - if grep -q '^ETCD_DISCOVERY_URL=' $TMP; then - depwarn "The ETCD_DISCOVERY_URL variable is deprecated." - eval $(grep '^ETCD_DISCOVERY_URL=' $TMP | tail -n1) - fi - - if grep -q '^START_FLEET=1' $TMP; then - depwarn "The START_FLEET variable is deprecated." - START_FLEET=1 - fi - -# If user-data is a cloud-config, do not do c10n -elif head -n 1 $TMP | grep -q '^#cloud-config'; then - # no c10n if this is a cloudconfig - C10N_TOKEN="" - -# Validate the user-data as an SSH key, installing it if so -else - depwarn "Interpreting user-data as an SSH key is deprecated." - - # This just validates the key - ssh-keygen -l -f $TMP > /dev/null 2>&1 - - if [ $? -eq 0 ]; then - update-ssh-keys -a c10n $TMP - fi -fi - -# After all that, if a script happened to set the discovery URL, write it to disk for etcd-bootstrap -if [ -n "${ETCD_DISCOVERY_URL}" ]; then - echo "Using '${ETCD_DISCOVERY_URL}' as etcd discovery url" - echo "[Service] -Environment=ETCD_DISCOVERY=${ETCD_DISCOVERY_URL}" > ${ETCD_SERVICE_D}/21-c10n.conf -# ...otherwise, we treat the provided user-data as a legacy c10n URL -elif [ -n "${C10N_TOKEN}" ]; then - depwarn "Bootstrapping etcd with the c10n service is deprecated." - - echo "Using '$C10N_TOKEN' as c10n token" - - # Assert we have networking up and able to access the c10n service - /usr/bin/block-until-url $C10N_ENDPOINT - - ETCD_PEERS=$(curl -s $C10N_ENDPOINT -d "c10n_url=$C10N_TOKEN" -d"ip_list=$IP") - IPS=$(echo "$ETCD_PEERS" | grep -v $IP | grep -v '^$' | sed 's/$/:7001/'| tr '\n' ','| sed 's/^,//' | sed 's/,$//') - echo "[Service]" > ${ETCD_SERVICE_D}/22-c10n.conf - echo "Environment=ETCD_PEERS=${IPS}" >> ${ETCD_SERVICE_D}/22-c10n.conf -fi - -if [ "$START_FLEET" = "1" ]; then - echo "Starting fleet" - systemctl start --no-block fleet -fi - -# on generic images, we only set the name to the internal IP -echo "[Service] -Environment=ETCD_NAME=${IP} -Environment=ETCD_ADDR=${IP}:4001 -Environment=ETCD_PEER_ADDR=${IP}:7001" > ${ETCD_SERVICE_D}/23-c10n.conf - -systemctl daemon-reload -systemctl --no-block start etcd diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/etcd-bootstrap b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/etcd-bootstrap deleted file mode 100755 index 4a8ba417c1..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/files/etcd-bootstrap +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -#TODO: Generating a config file rather than args so etcd-bootstrap can run as a -# completely separate unit from etcd - -STATE=/var/lib/etcd -ARGS="-f -data-dir $STATE -bind-addr 0.0.0.0" - -ARGS="${ARGS} -peer-election-timeout 1200" - -BOOTSTRAP_PEERS="/var/run/etcd/bootstrap.config" -BOOTSTRAP_DISCO="/var/run/etcd/bootstrap.disco" - -META_URL="http://169.254.169.254/latest" -MY_IP=$(curl --fail -s $META_URL/meta-data/local-ipv4) -if [ $? -ne 0 ]; then - echo "Request to meta-data service failed" >&2 - exit 1 -fi - -ARGS="${ARGS} -name ${MY_IP} -addr ${MY_IP}:4001 -peer-addr ${MY_IP}:7001 -peer-bind-addr 0.0.0.0" - -if [ -e $BOOTSTRAP_DISCO ]; then - DISCOVERY_URL="$(cat $BOOTSTRAP_DISCO)" - ARGS="${ARGS} -discovery ${DISCOVERY_URL}" - -elif [ -e $BOOTSTRAP_PEERS ]; then - IPS=$(grep -v $MY_IP $BOOTSTRAP_PEERS | grep -v '^$' | sed 's/$/:7001/'| tr '\n' ','| sed 's/^,//' | sed 's/,$//') - if [ -n "$IPS" ]; then - ARGS="${ARGS} -C ${IPS}" - fi -fi - -exec /usr/bin/etcd $ARGS diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.1-r13.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.1-r14.ebuild similarity index 100% rename from sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.1-r13.ebuild rename to sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.1-r14.ebuild diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.1.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.1.ebuild index 20b9967ba4..ba97b4ac5c 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.1.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ec2-compat/oem-ec2-compat-0.0.1.ebuild @@ -43,8 +43,6 @@ src_install() { into "/usr/share/oem" dobin ${FILESDIR}/ec2-ssh-key dobin ${FILESDIR}/coreos-setup-environment - dobin ${FILESDIR}/coreos-c10n - dobin ${FILESDIR}/etcd-bootstrap insinto "/usr/share/oem" doins ${T}/cloud-config.yml