Merge pull request #5028 from heyitsanthony/etcdmain-unsupported-envvar

etcdmain: start on unsupported arch when ETCD_UNSUPPORTED_ARCH is set
This commit is contained in:
Anthony Romano 2016-04-10 19:55:34 -07:00
commit f5f0280a63
3 changed files with 21 additions and 37 deletions

View File

@ -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

View File

@ -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)
}

View File

@ -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)
}