From e6b4539b92b6a9168c80402d90088a1295fc00cd Mon Sep 17 00:00:00 2001 From: Alex Polvi Date: Mon, 17 Mar 2014 14:53:28 -0700 Subject: [PATCH 1/9] fix(etcd.service): refactor to support cloudinit and easy c10n slaughtering --- .../oem-ami/files/cloud-config.yml | 25 ++++--------- .../coreos-base/oem-ami/files/coreos-c10n | 14 +++++--- .../oem-ami/files/coreos-setup-environment | 2 +- .../coreos-base/oem-ami/oem-ami-0.0.1.ebuild | 2 +- .../dev-db/etcd/etcd-0.3.0-r6.ebuild | 1 + ...{etcd-0.3.0-r5.ebuild => etcd-9999.ebuild} | 9 +++-- .../dev-db/etcd/etcd-99999.ebuild | 35 ------------------- .../dev-db/etcd/files/etcd.service | 15 +++----- 8 files changed, 31 insertions(+), 72 deletions(-) create mode 120000 sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r6.ebuild rename sdk_container/src/third_party/coreos-overlay/dev-db/etcd/{etcd-0.3.0-r5.ebuild => etcd-9999.ebuild} (82%) delete mode 100644 sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-99999.ebuild diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/cloud-config.yml b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/cloud-config.yml index f0137b00ef..d312630dd8 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/cloud-config.yml +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/cloud-config.yml @@ -11,7 +11,7 @@ coreos: [Service] Type=oneshot StandardOutput=journal+console - ExecStart=/usr/share/oem/usr/bin/ec2-ssh-key + ExecStart=/usr/share/oem/bin/ec2-ssh-key - name: ec2-cloudinit.service runtime: yes content: | @@ -32,21 +32,10 @@ coreos: [Service] Type=oneshot RemainAfterExit=no - ExecStart=/usr/share/oem/usr/bin/coreos-c10n - - name: etcd.service - runtime: yes - content: | - [Unit] - Description=etcd with ec2 auto-bootstrap - Requires=ec2-c10n.service - After=ec2-c10n.service + ExecStart=/usr/share/oem/bin/coreos-c10n - [Service] - User=etcd - PermissionsStartOnly=true - ExecStart=/usr/share/oem/usr/bin/etcd-bootstrap - Restart=always - RestartSec=10s - - [Install] - WantedBy=multi-user.target +write_files: + - path: /etc/systemd/system/etcd.service.d/10-oem.conf + contents: | + [Service] + Environment=ETCD_PEER_ELECTION_TIMEOUT=1200 diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n index 0789f2e523..b97a07e779 100755 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n @@ -9,8 +9,8 @@ depwarn() { C10N_ENDPOINT=https://core-api.appspot.com/v1/c10n/group META_URL="http://169.254.169.254/latest" -BOOTSTRAP_PEERS="/var/run/etcd/bootstrap.config" -BOOTSTRAP_DISCOVERY="/var/run/etcd/bootstrap.disco" +ETCD_SERVICE_D="/run/systemd/system/etcd.service.d" +mkdir -p $ETCD_SERVICE_D /usr/bin/block-until-url $META_URL @@ -64,7 +64,7 @@ if head -n 1 $TMP | grep -q '^#!'; then START_FLEET=1 fi -# If user-data is a cloud-config, hand it off to the new hotness +# If user-data is a cloud-config, do not do c10n elif head -n 1 $TMP | grep -q '^#cloud-config'; then # If an etcd discovery URL was found, we can assume the new hotness # will handle bootstrapping, allowing us to clear the c10n token @@ -87,7 +87,8 @@ 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 "${ETCD_DISCOVERY_URL}" > $BOOTSTRAP_DISCOVERY + echo "[Service] +Environment=ETCD_DISCOVERY=${ETCD_DISCOVERY}" > ${ETCD_SERVICE_D}/11-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." @@ -98,7 +99,10 @@ elif [ -n "${C10N_TOKEN}" ]; then /usr/bin/block-until-url $C10N_ENDPOINT IP=$(curl -s $META_URL/meta-data/local-ipv4) - curl -s $C10N_ENDPOINT -d "c10n_url=$C10N_TOKEN" -d"ip_list=$IP" > $BOOTSTRAP_PEERS + # XXX: change to append a valid ETCD_PEERS to /usr/share/oem/etcd.env + ETCD_PEERS=$(curl -s $C10N_ENDPOINT -d "c10n_url=$C10N_TOKEN" -d"ip_list=$IP") + echo "[Service] +Environment=ETCD_PEERS=${ETCD_PEERS}" > ${ETCD_SERVICE_D}/12-c10n.conf fi if [ "$START_FLEET" = "1" ]; then diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-setup-environment b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-setup-environment index dfbae79f9e..c148d23fe3 100755 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-setup-environment +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-setup-environment @@ -1,4 +1,4 @@ -#!/bin/bash +x +#!/bin/bash ENV=$1 diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1.ebuild index 1d9ff6def6..66f8a7d16e 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1.ebuild @@ -16,7 +16,7 @@ IUSE="" S="${WORKDIR}" src_install() { - into "/usr" + into "/" dobin ${FILESDIR}/ec2-ssh-key dobin ${FILESDIR}/coreos-setup-environment dobin ${FILESDIR}/coreos-c10n diff --git a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r6.ebuild b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r6.ebuild new file mode 120000 index 0000000000..f972b32dc1 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r6.ebuild @@ -0,0 +1 @@ +etcd-9999.ebuild \ No newline at end of file diff --git a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r5.ebuild b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-9999.ebuild similarity index 82% rename from sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r5.ebuild rename to sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-9999.ebuild index 312ed6aa7f..ea8c96f046 100644 --- a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r5.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-9999.ebuild @@ -9,16 +9,21 @@ EAPI=4 CROS_WORKON_PROJECT="coreos/etcd" CROS_WORKON_LOCALNAME="etcd" CROS_WORKON_REPO="git://github.com" -CROS_WORKON_COMMIT="040c1f591efa735e24e794d5084ad07782123e3c" # v0.3.0 + v1 API fix inherit toolchain-funcs cros-workon systemd +if [[ "${PV}" == 9999 ]]; then + KEYWORDS="~amd64" +else + CROS_WORKON_COMMIT="040c1f591efa735e24e794d5084ad07782123e3c" + KEYWORDS="amd64" +fi + DESCRIPTION="etcd" HOMEPAGE="https://github.com/coreos/etcd" SRC_URI="" LICENSE="Apache-2.0" SLOT="0" -KEYWORDS="amd64 x86" IUSE="" DEPEND=">=dev-lang/go-1.2" diff --git a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-99999.ebuild b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-99999.ebuild deleted file mode 100644 index 57e4e6541a..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-99999.ebuild +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. -# Copyright (c) 2013 CoreOS, Inc.. All rights reserved. -# Distributed under the terms of the GNU General Public License v2 -# $Header:$ -# - -EAPI=4 -CROS_WORKON_PROJECT="coreos/etcd" -CROS_WORKON_LOCALNAME="etcd" -CROS_WORKON_REPO="git://github.com" -inherit toolchain-funcs cros-workon systemd - -DESCRIPTION="etcd" -HOMEPAGE="https://github.com/coreos/etcd" -SRC_URI="" - -LICENSE="Apache-2.0" -SLOT="0" -KEYWORDS="~amd64" -IUSE="" - -DEPEND=">=dev-lang/go-1.2" - -src_compile() { - ./build -} - -src_install() { - dobin ${S}/bin/${PN} - - systemd_dounit "${FILESDIR}"/${PN}.service - systemd_enable_service multi-user.target ${PN}.service - systemd_dotmpfilesd "${FILESDIR}"/${PN}.conf -} diff --git a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service index 30b3999314..1f903ecd1e 100644 --- a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service +++ b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service @@ -1,19 +1,14 @@ [Unit] Description=etcd -RequiresMountsFor=/usr/share/oem -# oem will setup etcd for auto bootstrapping -ConditionPathExists=!/usr/share/oem/cloud-config.yml +# this will setup cloudinit and user envs +Wants=coreos-cloudinit-oem.service +After=coreos-cloudinit-oem.service [Service] User=etcd PermissionsStartOnly=true -# Default, this will be overwritten with a cloud-config -ExecStart=/usr/bin/etcd -f -data-dir /var/lib/etcd -bind-addr 0.0.0.0 -n default - -Restart=always -# Set a longish timeout in case this machine isn't behaving -# nicely and bothering the rest of the cluster -RestartSec=10s +Environment=ETCD_DATA_DIR=/var/lib/etcd ETCD_NAME=default +ExecStart=/usr/bin/etcd [Install] WantedBy=multi-user.target From 34af23e3a302f1763eb63f238c3086c6bcec6f13 Mon Sep 17 00:00:00 2001 From: Alex Polvi Date: Mon, 17 Mar 2014 16:22:20 -0700 Subject: [PATCH 2/9] content instead of contents --- .../coreos-base/oem-ami/files/cloud-config.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/cloud-config.yml b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/cloud-config.yml index d312630dd8..1f8e941114 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/cloud-config.yml +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/cloud-config.yml @@ -15,11 +15,15 @@ coreos: - name: ec2-cloudinit.service runtime: yes content: | + [Service] + Requires=coreos-setup-environment.service + After=coreos-setup-environment.service [Unit] Description=Cloudinit from EC2 metadata [Service] Type=oneshot + EnvironmentFile=/etc/environment ExecStart=/usr/bin/coreos-cloudinit -from-url=http://169.254.169.254/latest/user-data - name: ec2-c10n.service runtime: yes @@ -36,6 +40,7 @@ coreos: write_files: - path: /etc/systemd/system/etcd.service.d/10-oem.conf - contents: | + permissions: 0644 + content: | [Service] Environment=ETCD_PEER_ELECTION_TIMEOUT=1200 From 138afee423ec883a319634c3483a858146975a9d Mon Sep 17 00:00:00 2001 From: Alex Polvi Date: Mon, 17 Mar 2014 14:53:28 -0700 Subject: [PATCH 3/9] fix(etcd.service): refactor to support cloudinit and easy c10n slaughtering --- .../oem-ami/files/cloud-config.yml | 25 ++++--------- .../coreos-base/oem-ami/files/coreos-c10n | 14 +++++--- .../oem-ami/files/coreos-setup-environment | 2 +- .../coreos-base/oem-ami/oem-ami-0.0.1.ebuild | 2 +- .../dev-db/etcd/etcd-0.3.0-r6.ebuild | 1 + ...{etcd-0.3.0-r5.ebuild => etcd-9999.ebuild} | 9 +++-- .../dev-db/etcd/etcd-99999.ebuild | 35 ------------------- .../dev-db/etcd/files/etcd.service | 15 +++----- 8 files changed, 31 insertions(+), 72 deletions(-) create mode 120000 sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r6.ebuild rename sdk_container/src/third_party/coreos-overlay/dev-db/etcd/{etcd-0.3.0-r5.ebuild => etcd-9999.ebuild} (82%) delete mode 100644 sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-99999.ebuild diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/cloud-config.yml b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/cloud-config.yml index f0137b00ef..d312630dd8 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/cloud-config.yml +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/cloud-config.yml @@ -11,7 +11,7 @@ coreos: [Service] Type=oneshot StandardOutput=journal+console - ExecStart=/usr/share/oem/usr/bin/ec2-ssh-key + ExecStart=/usr/share/oem/bin/ec2-ssh-key - name: ec2-cloudinit.service runtime: yes content: | @@ -32,21 +32,10 @@ coreos: [Service] Type=oneshot RemainAfterExit=no - ExecStart=/usr/share/oem/usr/bin/coreos-c10n - - name: etcd.service - runtime: yes - content: | - [Unit] - Description=etcd with ec2 auto-bootstrap - Requires=ec2-c10n.service - After=ec2-c10n.service + ExecStart=/usr/share/oem/bin/coreos-c10n - [Service] - User=etcd - PermissionsStartOnly=true - ExecStart=/usr/share/oem/usr/bin/etcd-bootstrap - Restart=always - RestartSec=10s - - [Install] - WantedBy=multi-user.target +write_files: + - path: /etc/systemd/system/etcd.service.d/10-oem.conf + contents: | + [Service] + Environment=ETCD_PEER_ELECTION_TIMEOUT=1200 diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n index 0789f2e523..b97a07e779 100755 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n @@ -9,8 +9,8 @@ depwarn() { C10N_ENDPOINT=https://core-api.appspot.com/v1/c10n/group META_URL="http://169.254.169.254/latest" -BOOTSTRAP_PEERS="/var/run/etcd/bootstrap.config" -BOOTSTRAP_DISCOVERY="/var/run/etcd/bootstrap.disco" +ETCD_SERVICE_D="/run/systemd/system/etcd.service.d" +mkdir -p $ETCD_SERVICE_D /usr/bin/block-until-url $META_URL @@ -64,7 +64,7 @@ if head -n 1 $TMP | grep -q '^#!'; then START_FLEET=1 fi -# If user-data is a cloud-config, hand it off to the new hotness +# If user-data is a cloud-config, do not do c10n elif head -n 1 $TMP | grep -q '^#cloud-config'; then # If an etcd discovery URL was found, we can assume the new hotness # will handle bootstrapping, allowing us to clear the c10n token @@ -87,7 +87,8 @@ 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 "${ETCD_DISCOVERY_URL}" > $BOOTSTRAP_DISCOVERY + echo "[Service] +Environment=ETCD_DISCOVERY=${ETCD_DISCOVERY}" > ${ETCD_SERVICE_D}/11-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." @@ -98,7 +99,10 @@ elif [ -n "${C10N_TOKEN}" ]; then /usr/bin/block-until-url $C10N_ENDPOINT IP=$(curl -s $META_URL/meta-data/local-ipv4) - curl -s $C10N_ENDPOINT -d "c10n_url=$C10N_TOKEN" -d"ip_list=$IP" > $BOOTSTRAP_PEERS + # XXX: change to append a valid ETCD_PEERS to /usr/share/oem/etcd.env + ETCD_PEERS=$(curl -s $C10N_ENDPOINT -d "c10n_url=$C10N_TOKEN" -d"ip_list=$IP") + echo "[Service] +Environment=ETCD_PEERS=${ETCD_PEERS}" > ${ETCD_SERVICE_D}/12-c10n.conf fi if [ "$START_FLEET" = "1" ]; then diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-setup-environment b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-setup-environment index dfbae79f9e..c148d23fe3 100755 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-setup-environment +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-setup-environment @@ -1,4 +1,4 @@ -#!/bin/bash +x +#!/bin/bash ENV=$1 diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1.ebuild index 1d9ff6def6..66f8a7d16e 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1.ebuild @@ -16,7 +16,7 @@ IUSE="" S="${WORKDIR}" src_install() { - into "/usr" + into "/" dobin ${FILESDIR}/ec2-ssh-key dobin ${FILESDIR}/coreos-setup-environment dobin ${FILESDIR}/coreos-c10n diff --git a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r6.ebuild b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r6.ebuild new file mode 120000 index 0000000000..f972b32dc1 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r6.ebuild @@ -0,0 +1 @@ +etcd-9999.ebuild \ No newline at end of file diff --git a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r5.ebuild b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-9999.ebuild similarity index 82% rename from sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r5.ebuild rename to sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-9999.ebuild index 312ed6aa7f..ea8c96f046 100644 --- a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r5.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-9999.ebuild @@ -9,16 +9,21 @@ EAPI=4 CROS_WORKON_PROJECT="coreos/etcd" CROS_WORKON_LOCALNAME="etcd" CROS_WORKON_REPO="git://github.com" -CROS_WORKON_COMMIT="040c1f591efa735e24e794d5084ad07782123e3c" # v0.3.0 + v1 API fix inherit toolchain-funcs cros-workon systemd +if [[ "${PV}" == 9999 ]]; then + KEYWORDS="~amd64" +else + CROS_WORKON_COMMIT="040c1f591efa735e24e794d5084ad07782123e3c" + KEYWORDS="amd64" +fi + DESCRIPTION="etcd" HOMEPAGE="https://github.com/coreos/etcd" SRC_URI="" LICENSE="Apache-2.0" SLOT="0" -KEYWORDS="amd64 x86" IUSE="" DEPEND=">=dev-lang/go-1.2" diff --git a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-99999.ebuild b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-99999.ebuild deleted file mode 100644 index 57e4e6541a..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-99999.ebuild +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. -# Copyright (c) 2013 CoreOS, Inc.. All rights reserved. -# Distributed under the terms of the GNU General Public License v2 -# $Header:$ -# - -EAPI=4 -CROS_WORKON_PROJECT="coreos/etcd" -CROS_WORKON_LOCALNAME="etcd" -CROS_WORKON_REPO="git://github.com" -inherit toolchain-funcs cros-workon systemd - -DESCRIPTION="etcd" -HOMEPAGE="https://github.com/coreos/etcd" -SRC_URI="" - -LICENSE="Apache-2.0" -SLOT="0" -KEYWORDS="~amd64" -IUSE="" - -DEPEND=">=dev-lang/go-1.2" - -src_compile() { - ./build -} - -src_install() { - dobin ${S}/bin/${PN} - - systemd_dounit "${FILESDIR}"/${PN}.service - systemd_enable_service multi-user.target ${PN}.service - systemd_dotmpfilesd "${FILESDIR}"/${PN}.conf -} diff --git a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service index 30b3999314..1f903ecd1e 100644 --- a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service +++ b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service @@ -1,19 +1,14 @@ [Unit] Description=etcd -RequiresMountsFor=/usr/share/oem -# oem will setup etcd for auto bootstrapping -ConditionPathExists=!/usr/share/oem/cloud-config.yml +# this will setup cloudinit and user envs +Wants=coreos-cloudinit-oem.service +After=coreos-cloudinit-oem.service [Service] User=etcd PermissionsStartOnly=true -# Default, this will be overwritten with a cloud-config -ExecStart=/usr/bin/etcd -f -data-dir /var/lib/etcd -bind-addr 0.0.0.0 -n default - -Restart=always -# Set a longish timeout in case this machine isn't behaving -# nicely and bothering the rest of the cluster -RestartSec=10s +Environment=ETCD_DATA_DIR=/var/lib/etcd ETCD_NAME=default +ExecStart=/usr/bin/etcd [Install] WantedBy=multi-user.target From 141dba89cd13019a7f1803d3d36c9e35bdc33c40 Mon Sep 17 00:00:00 2001 From: Alex Polvi Date: Tue, 18 Mar 2014 01:17:17 +0000 Subject: [PATCH 4/9] updates from testing --- .../coreos-base/oem-ami/files/coreos-c10n | 13 ++++++------- .../oem-ami/files/coreos-setup-environment | 2 ++ .../coreos-overlay/dev-db/etcd/etcd-9999.ebuild | 1 - .../coreos-overlay/dev-db/etcd/files/etcd.service | 6 ------ 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n index b97a07e779..486935fe77 100755 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n @@ -66,11 +66,8 @@ if head -n 1 $TMP | grep -q '^#!'; then # If user-data is a cloud-config, do not do c10n elif head -n 1 $TMP | grep -q '^#cloud-config'; then - # If an etcd discovery URL was found, we can assume the new hotness - # will handle bootstrapping, allowing us to clear the c10n token - if grep -q 'discovery_url:' $TMP; then - C10N_TOKEN="" - fi + # no c10n if this is a cloudconfig + C10N_TOKEN="" # Validate the user-data as an SSH key, installing it if so else @@ -101,8 +98,10 @@ elif [ -n "${C10N_TOKEN}" ]; then IP=$(curl -s $META_URL/meta-data/local-ipv4) # XXX: change to append a valid ETCD_PEERS to /usr/share/oem/etcd.env ETCD_PEERS=$(curl -s $C10N_ENDPOINT -d "c10n_url=$C10N_TOKEN" -d"ip_list=$IP") - echo "[Service] -Environment=ETCD_PEERS=${ETCD_PEERS}" > ${ETCD_SERVICE_D}/12-c10n.conf + echo "[Service]" > ${ETCD_SERVICE_D}/12-c10n.conf + for peer in $ETCD_PEERS; do + echo "Environment=ETCD_PEERS=${peer}" >> ${ETCD_SERVICE_D}/12-c10n.conf + done fi if [ "$START_FLEET" = "1" ]; then diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-setup-environment b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-setup-environment index c148d23fe3..4e3b0c4dee 100755 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-setup-environment +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-setup-environment @@ -17,6 +17,8 @@ sed -i -e '/^COREOS_PUBLIC_IPV4=/d' \ -e '/^COREOS_PRIVATE_IPV4=/d' \ "${ENV}" +/usr/bin/block-until-url http://169.254.169.254/latest/meta-data/public-ipv4 + # get public ip from metadata PUB_IP_URL=http://169.254.169.254/latest/meta-data/public-ipv4 IP=$(/usr/bin/curl --fail -s "$PUB_IP_URL") diff --git a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-9999.ebuild b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-9999.ebuild index ea8c96f046..6072824a15 100644 --- a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-9999.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-9999.ebuild @@ -36,6 +36,5 @@ src_install() { dobin ${S}/bin/${PN} systemd_dounit "${FILESDIR}"/${PN}.service - systemd_enable_service multi-user.target ${PN}.service systemd_dotmpfilesd "${FILESDIR}"/${PN}.conf } diff --git a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service index 1f903ecd1e..946f52650d 100644 --- a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service +++ b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service @@ -1,14 +1,8 @@ [Unit] Description=etcd -# this will setup cloudinit and user envs -Wants=coreos-cloudinit-oem.service -After=coreos-cloudinit-oem.service [Service] User=etcd PermissionsStartOnly=true Environment=ETCD_DATA_DIR=/var/lib/etcd ETCD_NAME=default ExecStart=/usr/bin/etcd - -[Install] -WantedBy=multi-user.target From 0b1b197be6769d13972447e83e397428db6a7c5e Mon Sep 17 00:00:00 2001 From: Alex Polvi Date: Tue, 18 Mar 2014 03:29:25 +0000 Subject: [PATCH 5/9] move cloudinit service file to ebuild --- .../coreos-cloudinit-9999.ebuild | 4 +++- .../files/coreos-cloudinit-oem.service | 23 +++++++++++++++++++ .../coreos-init/coreos-init-9999.ebuild | 1 - 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/files/coreos-cloudinit-oem.service diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/coreos-cloudinit-9999.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/coreos-cloudinit-9999.ebuild index f2d34ad715..4f31399738 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/coreos-cloudinit-9999.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/coreos-cloudinit-9999.ebuild @@ -9,7 +9,7 @@ CROS_WORKON_REPO="git://github.com" if [[ "${PV}" == 9999 ]]; then KEYWORDS="~amd64" else - CROS_WORKON_COMMIT="e4965ec33d06f0c71622aad59d5f59f9aaca7c00" # v0.1.2 + CROS_WORKON_COMMIT="5185fe48dafd601917660c4df41ed0c3332e5f98" # v0.1.2 KEYWORDS="amd64" fi @@ -35,4 +35,6 @@ src_compile() { src_install() { dobin ${S}/bin/coreos-cloudinit + systemd_dounit "${FILESDIR}"/coreos-cloudinit-oem.service + systemd_enable_service default.target coreos-cloudinit-oem.service } diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/files/coreos-cloudinit-oem.service b/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/files/coreos-cloudinit-oem.service new file mode 100644 index 0000000000..7f6aa1e3d6 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/files/coreos-cloudinit-oem.service @@ -0,0 +1,23 @@ +[Unit] +Description=coreos-cloudinit for /usr/share/oem/cloud-config.yml +Requires=dbus.service +After=dbus.service +Requires=coreos-setup-environment.service +After=coreos-setup-environment.service +RequiresMountsFor=/usr/share/oem +ConditionPathExists=/usr/share/oem/cloud-config.yml + +# We use this to start etcd, since cloudinit will reconfigure etcd +#Wants=etcd.service +#After=etcd.service + +[Service] +Type=oneshot +EnvironmentFile=/etc/environment +# XXX: We could not figure out a better way. The above Wants/After does not do this. +ExecStartPre=/usr/bin/coreos-cloudinit --from-file=/usr/share/oem/cloud-config.yml +ExecStart=/usr/bin/systemctl daemon-reload +ExecStartPost=/usr/bin/systemctl start etcd + +[Install] +WantedBy=multi-user.target diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-init/coreos-init-9999.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-init/coreos-init-9999.ebuild index 8f3223dca5..930b1bae14 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-init/coreos-init-9999.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-init/coreos-init-9999.ebuild @@ -52,7 +52,6 @@ src_install() { systemd_enable_service basic.target coreos-startup.target # Services! - systemd_enable_service default.target coreos-cloudinit-oem.service systemd_enable_service default.target local-enable.service systemd_enable_service default.target sshd-keygen.service systemd_enable_service default.target sshd.socket From 2bca0818afe6b71463a08b2abc458ba26201265f Mon Sep 17 00:00:00 2001 From: Alex Polvi Date: Tue, 18 Mar 2014 15:34:11 +0000 Subject: [PATCH 6/9] fix comment --- .../coreos-overlay/coreos-base/oem-ami/files/coreos-c10n | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n index 486935fe77..7cd4af0205 100755 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/coreos-c10n @@ -96,7 +96,6 @@ elif [ -n "${C10N_TOKEN}" ]; then /usr/bin/block-until-url $C10N_ENDPOINT IP=$(curl -s $META_URL/meta-data/local-ipv4) - # XXX: change to append a valid ETCD_PEERS to /usr/share/oem/etcd.env ETCD_PEERS=$(curl -s $C10N_ENDPOINT -d "c10n_url=$C10N_TOKEN" -d"ip_list=$IP") echo "[Service]" > ${ETCD_SERVICE_D}/12-c10n.conf for peer in $ETCD_PEERS; do From de0def339fb0d6829332946dc857fa83a59e1b63 Mon Sep 17 00:00:00 2001 From: Alex Polvi Date: Tue, 18 Mar 2014 16:41:56 +0000 Subject: [PATCH 7/9] correctly document cloudinit version --- .../coreos-base/coreos-cloudinit/coreos-cloudinit-9999.ebuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/coreos-cloudinit-9999.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/coreos-cloudinit-9999.ebuild index 4f31399738..133dfb43be 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/coreos-cloudinit-9999.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/coreos-cloudinit-9999.ebuild @@ -9,7 +9,7 @@ CROS_WORKON_REPO="git://github.com" if [[ "${PV}" == 9999 ]]; then KEYWORDS="~amd64" else - CROS_WORKON_COMMIT="5185fe48dafd601917660c4df41ed0c3332e5f98" # v0.1.2 + CROS_WORKON_COMMIT="5185fe48dafd601917660c4df41ed0c3332e5f98" # v0.1.2+git KEYWORDS="amd64" fi From 1f3d02db362929c338f28a6eb71055a4698a8818 Mon Sep 17 00:00:00 2001 From: Alex Polvi Date: Tue, 18 Mar 2014 10:52:01 -0700 Subject: [PATCH 8/9] add cloud-config.target and make etcd hang off of that --- .../coreos-cloudinit/coreos-cloudinit-9999.ebuild | 2 ++ .../coreos-base/coreos-cloudinit/files/cloud-config.target | 6 ++++++ .../coreos-cloudinit/files/coreos-cloudinit-oem.service | 7 +------ .../coreos-overlay/dev-db/etcd/etcd-9999.ebuild | 1 + .../coreos-overlay/dev-db/etcd/files/etcd.service | 5 +++++ 5 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/files/cloud-config.target diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/coreos-cloudinit-9999.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/coreos-cloudinit-9999.ebuild index 133dfb43be..571b94741a 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/coreos-cloudinit-9999.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/coreos-cloudinit-9999.ebuild @@ -36,5 +36,7 @@ src_compile() { src_install() { dobin ${S}/bin/coreos-cloudinit systemd_dounit "${FILESDIR}"/coreos-cloudinit-oem.service + systemd_dounit "${FILESDIR}"/cloud-config.target systemd_enable_service default.target coreos-cloudinit-oem.service + systemd_enable_service default.target cloud-config.target } diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/files/cloud-config.target b/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/files/cloud-config.target new file mode 100644 index 0000000000..71901cafd1 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/files/cloud-config.target @@ -0,0 +1,6 @@ +[Unit] +Requires=coreos-cloudinit-oem.service +After=coreos-cloudinit-oem.service + +[Install] +WantedBy=multi-user.target diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/files/coreos-cloudinit-oem.service b/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/files/coreos-cloudinit-oem.service index 7f6aa1e3d6..2731b2d2ed 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/files/coreos-cloudinit-oem.service +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/coreos-cloudinit/files/coreos-cloudinit-oem.service @@ -7,17 +7,12 @@ After=coreos-setup-environment.service RequiresMountsFor=/usr/share/oem ConditionPathExists=/usr/share/oem/cloud-config.yml -# We use this to start etcd, since cloudinit will reconfigure etcd -#Wants=etcd.service -#After=etcd.service - [Service] Type=oneshot EnvironmentFile=/etc/environment -# XXX: We could not figure out a better way. The above Wants/After does not do this. ExecStartPre=/usr/bin/coreos-cloudinit --from-file=/usr/share/oem/cloud-config.yml ExecStart=/usr/bin/systemctl daemon-reload -ExecStartPost=/usr/bin/systemctl start etcd [Install] WantedBy=multi-user.target +WantedBy=cloudinit.target diff --git a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-9999.ebuild b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-9999.ebuild index 6072824a15..fe68a02cf0 100644 --- a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-9999.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-9999.ebuild @@ -37,4 +37,5 @@ src_install() { systemd_dounit "${FILESDIR}"/${PN}.service systemd_dotmpfilesd "${FILESDIR}"/${PN}.conf + systemd_enable_service multi-user.target ${PN}.service } diff --git a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service index 946f52650d..30e941449e 100644 --- a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service +++ b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service @@ -1,8 +1,13 @@ [Unit] Description=etcd +After=cloud-config.target +Wants=cloud-config.target [Service] User=etcd PermissionsStartOnly=true Environment=ETCD_DATA_DIR=/var/lib/etcd ETCD_NAME=default ExecStart=/usr/bin/etcd + +[Install] +WantedBy=multi-user.target From 81b2c916ebfe5eb50167757681016cf7f2bc350b Mon Sep 17 00:00:00 2001 From: Alex Polvi Date: Tue, 18 Mar 2014 10:53:36 -0700 Subject: [PATCH 9/9] add back restart --- .../third_party/coreos-overlay/dev-db/etcd/files/etcd.service | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service index 30e941449e..c5033b2b4b 100644 --- a/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service +++ b/sdk_container/src/third_party/coreos-overlay/dev-db/etcd/files/etcd.service @@ -8,6 +8,8 @@ User=etcd PermissionsStartOnly=true Environment=ETCD_DATA_DIR=/var/lib/etcd ETCD_NAME=default ExecStart=/usr/bin/etcd +Restart=always +RestartSec=10s [Install] WantedBy=multi-user.target