Browse Source

Merge pull request #3249 from philips/get-etcd-running-under-arm64

Get etcd running under arm64
Brandon Philips 10 years ago
parent
commit
45f3a0c547
4 changed files with 23 additions and 9 deletions
  1. 7 5
      etcdserver/raft.go
  2. 4 2
      etcdserver/server.go
  3. 5 1
      store/watcher_hub.go
  4. 7 1
      test

+ 7 - 5
etcdserver/raft.go

@@ -79,6 +79,13 @@ type apply struct {
 }
 
 type raftNode struct {
+	// Cache of the latest raft index and raft term the server has seen.
+	// These three unit64 fields must be the first elements to keep 64-bit
+	// alignment for atomic access to the fields.
+	index uint64
+	term  uint64
+	lead  uint64
+
 	raft.Node
 
 	// a chan to send out apply
@@ -99,11 +106,6 @@ type raftNode struct {
 	// If transport is nil, server will panic.
 	transport rafthttp.Transporter
 
-	// Cache of the latest raft index and raft term the server has seen
-	index uint64
-	term  uint64
-	lead  uint64
-
 	stopped chan struct{}
 	done    chan struct{}
 }

+ 4 - 2
etcdserver/server.go

@@ -141,11 +141,13 @@ type Server interface {
 
 // EtcdServer is the production implementation of the Server interface
 type EtcdServer struct {
+	// r must be the first element to keep 64-bit alignment for atomic
+	// access to fields
+	r raftNode
+
 	cfg       *ServerConfig
 	snapCount uint64
 
-	r raftNode
-
 	w          wait.Wait
 	stop       chan struct{}
 	done       chan struct{}

+ 5 - 1
store/watcher_hub.go

@@ -31,9 +31,13 @@ import (
 // event happens between the end of the first watch command and the start
 // of the second command.
 type watcherHub struct {
+	// count must be the first element to keep 64-bit alignment for atomic
+	// access
+
+	count int64 // current number of watchers.
+
 	mutex        sync.Mutex
 	watchers     map[string]*list.List
-	count        int64 // current number of watchers.
 	EventHistory *EventHistory
 }
 

+ 7 - 1
test

@@ -45,7 +45,13 @@ split=(${NO_RACE_TEST// / })
 NO_RACE_TEST=${split[@]/#/${REPO_PATH}/}
 
 echo "Running tests..."
-go test -timeout 3m ${COVER} $@ ${TEST} --race -cpu 1,2,4
+
+MACHINE_TYPE=$(uname -m)
+if [ $MACHINE_TYPE != "armv7l" ]; then
+  RACE="--race"
+fi
+
+go test -timeout 3m ${COVER} $@ ${TEST} ${RACE} -cpu 1,2,4
 go test -timeout 3m ${COVER} $@ ${NO_RACE_TEST} -cpu 1,2,4
 
 if [ -n "$INTEGRATION" ]; then