From c4caa65c51e3d06a3b9cab8447fb91e34e49b049 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Sun, 10 Apr 2016 12:08:44 -0700 Subject: [PATCH] etcdmain: start on unsupported arch when ETCD_UNSUPPORTED_ARCH is set --- README.md | 9 ++++++--- etcdmain/etcd.go | 18 +++++++++++++++--- etcdmain/etcd_phony.go | 31 ------------------------------- 3 files changed, 21 insertions(+), 37 deletions(-) delete mode 100644 etcdmain/etcd_phony.go diff --git a/README.md b/README.md index 9ea7b355b..bc33f1bf2 100644 --- a/README.md +++ b/README.md @@ -137,12 +137,15 @@ curl -L http://127.0.0.1:2379/version The `v2` API responses should not change after the 2.0.0 release but new features will be added over time. -#### 32-bit systems +#### 32-bit and other unsupported systems etcd has known issues on 32-bit systems due to a bug in the Go runtime. See #[358][358] for more information. -To avoid inadvertantly producing an unstable etcd server, 32-bit builds emit an `etcd` that prints -a warning message and immediately exits. +To avoid inadvertantly running a possibly unstable etcd server, `etcd` on unsupported architectures will print +a warning message and immediately exit if the environment variable `ETCD_UNSUPPORTED_ARCH` is not set to +the target architecture. + +Currently only the amd64 architecture is officially supported by `etcd`. [358]: https://github.com/coreos/etcd/issues/358 diff --git a/etcdmain/etcd.go b/etcdmain/etcd.go index e3f5e4da8..c46cca57f 100644 --- a/etcdmain/etcd.go +++ b/etcdmain/etcd.go @@ -12,9 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// TODO: support arm64 -// +build amd64 - package etcdmain import ( @@ -79,6 +76,8 @@ var ( ) func Main() { + checkSupportArch() + cfg := NewConfig() err := cfg.Parse(os.Args[1:]) if err != nil { @@ -605,3 +604,16 @@ func setupLogging(cfg *config) { repoLog.SetLogLevel(settings) } } + +func checkSupportArch() { + // TODO qualify arm64 + if runtime.GOARCH == "amd64" { + return + } + if env, ok := os.LookupEnv("ETCD_UNSUPPORTED_ARCH"); ok && env == runtime.GOARCH { + plog.Warningf("running etcd on unsupported architecture %q since ETCD_UNSUPPORTED_ARCH is set", env) + return + } + plog.Errorf("etcd on unsupported platform without ETCD_UNSUPPORTED_ARCH=%s set.", runtime.GOARCH) + os.Exit(1) +} diff --git a/etcdmain/etcd_phony.go b/etcdmain/etcd_phony.go deleted file mode 100644 index f30851770..000000000 --- a/etcdmain/etcd_phony.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 CoreOS, Inc. -// -// 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. - -// +build !amd64 - -package etcdmain - -import ( - "fmt" - "os" - - "github.com/coreos/pkg/capnslog" -) - -var plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "etcdmain") - -func Main() { - fmt.Println("unsupported architecture; unreliable, unstable") - os.Exit(-1) -}