!7 release v3.4.7

Merge pull request !7 from jiangxinyu/release-v3.4.7
This commit is contained in:
openeuler-ci-bot 2020-08-18 19:11:39 +08:00 committed by Gitee
commit fb44fc6e32
13 changed files with 656 additions and 211 deletions

View File

@ -0,0 +1,264 @@
diff -up etcd-3.4.3/etcdmain/config.go.orig etcd-3.4.3/etcdmain/config.go
--- etcd-3.4.3/etcdmain/config.go.orig 2019-10-23 19:11:46.000000000 +0200
+++ etcd-3.4.3/etcdmain/config.go 2020-02-06 01:16:58.443641282 +0100
@@ -123,14 +123,15 @@ func newConfig() *config {
),
}
- fs := cfg.cf.flagSet
- fs.Usage = func() {
+ fs := InitFlagSet(cfg.cf.flagSet)
+ cfg.cf.flagSet.Usage = func() {
fmt.Fprintln(os.Stderr, usageline)
}
fs.StringVar(&cfg.configFile, "config-file", "", "Path to the server configuration file. Note that if a configuration file is provided, other command line flags and environment variables will be ignored.")
// member
+ fs.AddGroup("member")
fs.StringVar(&cfg.ec.Dir, "data-dir", cfg.ec.Dir, "Path to the data directory.")
fs.StringVar(&cfg.ec.WalDir, "wal-dir", cfg.ec.WalDir, "Path to the dedicated wal directory.")
fs.Var(
@@ -163,7 +164,7 @@ func newConfig() *config {
fs.DurationVar(&cfg.ec.GRPCKeepAliveInterval, "grpc-keepalive-interval", cfg.ec.GRPCKeepAliveInterval, "Frequency duration of server-to-client ping to check if a connection is alive (0 to disable).")
fs.DurationVar(&cfg.ec.GRPCKeepAliveTimeout, "grpc-keepalive-timeout", cfg.ec.GRPCKeepAliveTimeout, "Additional duration of wait before closing a non-responsive connection (0 to disable).")
- // clustering
+ fs.AddGroup("clustering")
fs.Var(
flags.NewUniqueURLsWithExceptions(embed.DefaultInitialAdvertisePeerURLs, ""),
"initial-advertise-peer-urls",
@@ -188,7 +189,7 @@ func newConfig() *config {
fs.BoolVar(&cfg.ec.EnableV2, "enable-v2", cfg.ec.EnableV2, "Accept etcd V2 client requests.")
fs.BoolVar(&cfg.ec.PreVote, "pre-vote", cfg.ec.PreVote, "Enable to run an additional Raft election phase.")
- // proxy
+ fs.AddGroup("proxy")
fs.Var(cfg.cf.proxy, "proxy", fmt.Sprintf("Valid values include %q", cfg.cf.proxy.Valids()))
fs.UintVar(&cfg.cp.ProxyFailureWaitMs, "proxy-failure-wait", cfg.cp.ProxyFailureWaitMs, "Time (in milliseconds) an endpoint will be held in a failed state.")
fs.UintVar(&cfg.cp.ProxyRefreshIntervalMs, "proxy-refresh-interval", cfg.cp.ProxyRefreshIntervalMs, "Time (in milliseconds) of the endpoints refresh interval.")
@@ -196,7 +197,7 @@ func newConfig() *config {
fs.UintVar(&cfg.cp.ProxyWriteTimeoutMs, "proxy-write-timeout", cfg.cp.ProxyWriteTimeoutMs, "Time (in milliseconds) for a write to timeout.")
fs.UintVar(&cfg.cp.ProxyReadTimeoutMs, "proxy-read-timeout", cfg.cp.ProxyReadTimeoutMs, "Time (in milliseconds) for a read to timeout.")
- // security
+ fs.AddGroup("security")
fs.StringVar(&cfg.ec.ClientTLSInfo.CertFile, "cert-file", "", "Path to the client server TLS cert file.")
fs.StringVar(&cfg.ec.ClientTLSInfo.KeyFile, "key-file", "", "Path to the client server TLS key file.")
fs.BoolVar(&cfg.ec.ClientTLSInfo.ClientCertAuth, "client-cert-auth", false, "Enable client cert authentication.")
@@ -222,7 +223,7 @@ func newConfig() *config {
)
fs.Var(flags.NewUniqueStringsValue("*"), "host-whitelist", "Comma-separated acceptable hostnames from HTTP client requests, if server is not secure (empty means allow all).")
- // logging
+ fs.AddGroup("logging")
fs.StringVar(&cfg.ec.Logger, "logger", "capnslog", "Specify 'zap' for structured logging or 'capnslog'. WARN: 'capnslog' is being deprecated in v3.5.")
fs.Var(flags.NewUniqueStringsValue(embed.DefaultLogOutput), "log-output", "[TO BE DEPRECATED IN v3.5] use '--log-outputs'.")
fs.Var(flags.NewUniqueStringsValue(embed.DefaultLogOutput), "log-outputs", "Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd, or list of comma separated output targets.")
@@ -230,26 +231,26 @@ func newConfig() *config {
fs.StringVar(&cfg.ec.LogLevel, "log-level", logutil.DefaultLogLevel, "Configures log level. Only supports debug, info, warn, error, panic, or fatal. Default 'info'.")
fs.StringVar(&cfg.ec.LogPkgLevels, "log-package-levels", "", "[TO BE DEPRECATED IN v3.5] Specify a particular log level for each etcd package (eg: 'etcdmain=CRITICAL,etcdserver=DEBUG').")
- // version
+ fs.AddGroup("version")
fs.BoolVar(&cfg.printVersion, "version", false, "Print the version and exit.")
fs.StringVar(&cfg.ec.AutoCompactionRetention, "auto-compaction-retention", "0", "Auto compaction retention for mvcc key value store. 0 means disable auto compaction.")
fs.StringVar(&cfg.ec.AutoCompactionMode, "auto-compaction-mode", "periodic", "interpret 'auto-compaction-retention' one of: periodic|revision. 'periodic' for duration based retention, defaulting to hours if no time unit is provided (e.g. '5m'). 'revision' for revision number based retention.")
- // pprof profiler via HTTP
+ fs.AddGroup("profiling")
fs.BoolVar(&cfg.ec.EnablePprof, "enable-pprof", false, "Enable runtime profiling data via HTTP server. Address is at client URL + \"/debug/pprof/\"")
// additional metrics
fs.StringVar(&cfg.ec.Metrics, "metrics", cfg.ec.Metrics, "Set level of detail for exported metrics, specify 'extensive' to include histogram metrics")
- // auth
+ fs.AddGroup("auth")
fs.StringVar(&cfg.ec.AuthToken, "auth-token", cfg.ec.AuthToken, "Specify auth token specific options.")
fs.UintVar(&cfg.ec.BcryptCost, "bcrypt-cost", cfg.ec.BcryptCost, "Specify bcrypt algorithm cost factor for auth password hashing.")
- // gateway
+ fs.AddGroup("gateway")
fs.BoolVar(&cfg.ec.EnableGRPCGateway, "enable-grpc-gateway", true, "Enable GRPC gateway.")
- // experimental
+ fs.AddGroup("experimental")
fs.BoolVar(&cfg.ec.ExperimentalInitialCorruptCheck, "experimental-initial-corrupt-check", cfg.ec.ExperimentalInitialCorruptCheck, "Enable to check data corruption before serving any client/peer traffic.")
fs.DurationVar(&cfg.ec.ExperimentalCorruptCheckTime, "experimental-corrupt-check-time", cfg.ec.ExperimentalCorruptCheckTime, "Duration of time between cluster corruption check passes.")
fs.StringVar(&cfg.ec.ExperimentalEnableV2V3, "experimental-enable-v2v3", cfg.ec.ExperimentalEnableV2V3, "v3 prefix for serving emulated v2 state.")
@@ -257,9 +258,12 @@ func newConfig() *config {
fs.BoolVar(&cfg.ec.ExperimentalEnableLeaseCheckpoint, "experimental-enable-lease-checkpoint", false, "Enable to persist lease remaining TTL to prevent indefinite auto-renewal of long lived leases.")
fs.IntVar(&cfg.ec.ExperimentalCompactionBatchLimit, "experimental-compaction-batch-limit", cfg.ec.ExperimentalCompactionBatchLimit, "Sets the maximum revisions deleted in each compaction batch.")
- // unsafe
+ fs.AddGroup("unsafe")
fs.BoolVar(&cfg.ec.ForceNewCluster, "force-new-cluster", false, "Force to create a new one member cluster.")
+ fs.GenMan()
+ os.Exit(0)
+
// ignored
for _, f := range cfg.ignored {
fs.Var(&flags.IgnoredFlag{Name: f}, f, "")
diff -up etcd-3.4.3/etcdmain/fake_flagset.go.orig etcd-3.4.3/etcdmain/fake_flagset.go
--- etcd-3.4.3/etcdmain/fake_flagset.go.orig 2020-02-06 01:14:12.639989665 +0100
+++ etcd-3.4.3/etcdmain/fake_flagset.go 2020-02-06 01:14:12.639989665 +0100
@@ -0,0 +1,157 @@
+package etcdmain
+
+import (
+ "flag"
+ "fmt"
+ "strconv"
+ "strings"
+ "time"
+)
+
+type flagInfo struct {
+ value fmt.Stringer
+ name string
+ usage string
+}
+
+type stringValue string
+
+func (s *stringValue) String() string { return string(*s) }
+
+type uintValue uint
+
+func (i *uintValue) String() string { return strconv.FormatUint(uint64(*i), 10) }
+
+type uint64Value uint64
+
+func (i *uint64Value) String() string { return strconv.FormatUint(uint64(*i), 10) }
+
+type int64Value int64
+
+func (i *int64Value) String() string { return strconv.FormatInt(int64(*i), 10) }
+
+type durationValue time.Duration
+
+func (d *durationValue) String() string { return (*time.Duration)(d).String() }
+
+type boolValue bool
+
+func (b *boolValue) String() string { return strconv.FormatBool(bool(*b)) }
+
+type FakeFlagSet struct {
+ fs *flag.FlagSet
+ flags map[string][]flagInfo
+ groups []string
+ lastGroup string
+}
+
+func InitFlagSet(fs *flag.FlagSet) *FakeFlagSet {
+ return &FakeFlagSet{
+ fs: fs,
+ flags: make(map[string][]flagInfo),
+ }
+}
+
+func (fs *FakeFlagSet) AddGroup(name string) {
+ fs.flags[name] = nil
+ fs.groups = append(fs.groups, name)
+ fs.lastGroup = name
+}
+
+func (fs *FakeFlagSet) Var(value flag.Value, name string, usage string) {
+ fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
+ value: value,
+ name: name,
+ usage: usage,
+ })
+ fs.fs.Var(value, name, usage)
+}
+
+func (fs *FakeFlagSet) StringVar(p *string, name string, value string, usage string) {
+ fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
+ value: (*stringValue)(&value),
+ name: name,
+ usage: usage,
+ })
+ fs.fs.StringVar(p, name, value, usage)
+}
+
+// -- int Value
+type intValue int
+
+func (i *intValue) String() string { return strconv.Itoa(int(*i)) }
+
+func (fs *FakeFlagSet) UintVar(p *uint, name string, value uint, usage string) {
+ fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
+ value: (*uintValue)(&value),
+ name: name,
+ usage: usage,
+ })
+ fs.fs.UintVar(p, name, value, usage)
+}
+
+func (fs *FakeFlagSet) Uint64Var(p *uint64, name string, value uint64, usage string) {
+ fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
+ value: (*uint64Value)(&value),
+ name: name,
+ usage: usage,
+ })
+ fs.fs.Uint64Var(p, name, value, usage)
+}
+
+func (fs *FakeFlagSet) IntVar(p *int, name string, value int, usage string) {
+ fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
+ value: (*intValue)(&value),
+ name: name,
+ usage: usage,
+ })
+ fs.fs.IntVar(p, name, value, usage)
+}
+
+func (fs *FakeFlagSet) Int64Var(p *int64, name string, value int64, usage string) {
+ fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
+ value: (*int64Value)(&value),
+ name: name,
+ usage: usage,
+ })
+ fs.fs.Int64Var(p, name, value, usage)
+}
+
+func (fs *FakeFlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string) {
+ fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
+ value: (*durationValue)(&value),
+ name: name,
+ usage: usage,
+ })
+ fs.fs.DurationVar(p, name, value, usage)
+}
+
+func (fs *FakeFlagSet) BoolVar(p *bool, name string, value bool, usage string) {
+ fs.flags[fs.lastGroup] = append(fs.flags[fs.lastGroup], flagInfo{
+ value: (*boolValue)(&value),
+ name: name,
+ usage: usage,
+ })
+ fs.fs.BoolVar(p, name, value, usage)
+}
+
+func (fs *FakeFlagSet) GenMan() {
+ fmt.Printf(".TH \"ETCD\" \"1\" \" etcd User Manuals\" \"Etcd contributors\" \"Nov 2017\" \"\"\n")
+ fmt.Printf(".SH NAME:\netcd - Distributed reliable key-value store for the most critical data of a distributed system\n\n")
+ fmt.Printf(".SH USAGE:\netcd [flags]\n\n")
+ fmt.Printf(".SH DESCRIPTION:\nEtcd is a distributed key-value store designed to reliably and quickly preserve and provide access to critical data. It enables reliable distributed coordination through distributed locking, leader elections, and write barriers. An etcd cluster is intended for high availability and permanent data storage and retrieval.\n\n")
+ fmt.Printf(".SH GENERAL OPTIONS\n\n")
+ for _, group := range fs.groups {
+ fmt.Printf(".I %v flags\n\n", strings.Title(group))
+ for _, flag := range fs.flags[group] {
+ var flagstr string
+ if len(flag.name) == 1 {
+ flagstr = "-" + flag.name
+ } else {
+ flagstr = "--" + flag.name
+ }
+ fmt.Printf(".RS\n\\fB%v %v\\fP\n %v\n\n.RE\n", flagstr, flag.value.String(), flag.usage)
+ }
+ }
+ fmt.Printf(".SH SEE ALSO:\n\\fBetcdctl(1)\\fP, \\fBetcdctl2(1)\\fP, \\fBetcdctl3(1)\\fP\n\n")
+}

View File

@ -0,0 +1,120 @@
diff -up etcd-e1ca3b4434945e57e8e3a451cdbde74a903cc8e1/etcdctl/ctlv2/ctl.go.hack2 etcd-e1ca3b4434945e57e8e3a451cdbde74a903cc8e1/etcdctl/ctlv2/ctl.go
--- etcd-e1ca3b4434945e57e8e3a451cdbde74a903cc8e1/etcdctl/ctlv2/ctl.go.hack2 2019-03-12 20:09:09.000000000 +0100
+++ etcd-e1ca3b4434945e57e8e3a451cdbde74a903cc8e1/etcdctl/ctlv2/ctl.go 2019-03-14 20:20:04.887079104 +0100
@@ -36,6 +36,68 @@ func Start() {
}
app.Usage = "A simple command line client for etcd."
+ cli.AppHelpTemplate = `.TH "ETCD" "1" " etcd User Manuals" "Etcd contributors" "Nov 2017" ""
+.SH NAME:
+{{.Name}} - {{.Usage}}
+
+{{if .Version}}
+.SH VERSION:
+ {{.Version}}
+{{end}}
+
+.SH USAGE:
+ {{.HelpName}} {{if .VisibleFlags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
+ {{if .Commands}}
+
+.SH COMMANDS:
+{{range .Commands}}{{if not .HideHelp}}\fB{{ .Name }}\fP{{ "\n\t\t\t" }}{{.Usage}}{{ "\n" }}
+
+{{end}}{{end}}{{end}}{{if .VisibleFlags}}
+
+.SH GLOBAL OPTIONS:
+{{range .VisibleFlags}}{{ . }}
+
+{{end}}{{end}}
+
+.SH SEE ALSO
+{{range .Commands}}{{if not .HideHelp}}{{if ne .Name "help" }}\fBetcdctl-{{ .Name }}(1)\fP,
+{{end}}{{end}}{{end}}
+`
+
+ cli.CommandHelpTemplate = `.TH "ETCD" "1" " etcd User Manuals" "Etcd contributors" "Nov 2017" ""
+.SH NAME:
+ {{.HelpName}} - {{.Usage}}
+
+.SH USAGE:
+ {{.HelpName}}{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
+
+{{if .VisibleFlags}}
+.SH OPTIONS:
+ {{range .VisibleFlags}}{{.}}
+ {{end}}{{end}}
+`
+
+
+ cli.SubcommandHelpTemplate = `.TH "ETCD" "1" " etcd User Manuals" "Etcd contributors" "Nov 2017" ""
+.SH NAME:
+ {{.HelpName}} - {{.Usage}}
+
+.SH USAGE:
+ {{.HelpName}} command{{if .VisibleFlags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
+
+.SH COMMANDS:
+{{range .VisibleCategories}}{{if .Name}}
+{{.Name}}:{{end}}{{range .VisibleCommands}}
+\fB{{ .Name }}\fP{{"\n\t\t\t"}}{{.Usage}}{{ "\n" }}{{end}}
+{{end}}
+
+{{if .VisibleFlags}}
+.SH OPTIONS:
+{{range .VisibleFlags}}{{.}}
+{{end}}{{end}}
+`
+
+
app.Flags = []cli.Flag{
cli.BoolFlag{Name: "debug", Usage: "output cURL commands which can be used to reproduce the request"},
cli.BoolFlag{Name: "no-sync", Usage: "don't synchronize cluster information before sending request"},
diff -up etcd-e1ca3b4434945e57e8e3a451cdbde74a903cc8e1/etcdctl/ctlv3/ctl_nocov.go.hack2 etcd-e1ca3b4434945e57e8e3a451cdbde74a903cc8e1/etcdctl/ctlv3/ctl_nocov.go
--- etcd-e1ca3b4434945e57e8e3a451cdbde74a903cc8e1/etcdctl/ctlv3/ctl_nocov.go.hack2 2019-03-14 20:20:04.888079103 +0100
+++ etcd-e1ca3b4434945e57e8e3a451cdbde74a903cc8e1/etcdctl/ctlv3/ctl_nocov.go 2019-03-14 20:32:35.376178988 +0100
@@ -16,13 +16,20 @@
package ctlv3
-import "go.etcd.io/etcd/etcdctl/ctlv3/command"
+//import "github.com/coreos/etcd/etcdctl/ctlv3/command"
+import cobra "github.com/spf13/cobra/doc"
func Start() {
rootCmd.SetUsageFunc(usageFunc)
// Make help just show the usage
rootCmd.SetHelpTemplate(`{{.UsageString}}`)
- if err := rootCmd.Execute(); err != nil {
- command.ExitWithError(command.ExitError, err)
+ //if err := rootCmd.Execute(); err != nil {
+ // command.ExitWithError(command.ExitError, err)
+ //}
+ header := &cobra.GenManHeader{
+ Title: "etcdctl3",
+ Section: "1",
}
+
+ cobra.GenManTree(rootCmd, header, "")
}
diff -up etcd-e1ca3b4434945e57e8e3a451cdbde74a903cc8e1/vendor/github.com/urfave/cli/flag.go.hack2 etcd-e1ca3b4434945e57e8e3a451cdbde74a903cc8e1/vendor/github.com/urfave/cli/flag.go
--- etcd-e1ca3b4434945e57e8e3a451cdbde74a903cc8e1/vendor/github.com/urfave/cli/flag.go.hack2 2019-03-12 20:09:09.000000000 +0100
+++ etcd-e1ca3b4434945e57e8e3a451cdbde74a903cc8e1/vendor/github.com/urfave/cli/flag.go 2019-03-14 20:20:04.883079109 +0100
@@ -670,7 +670,7 @@ func prefixedNames(fullName, placeholder
parts := strings.Split(fullName, ",")
for i, name := range parts {
name = strings.Trim(name, " ")
- prefixed += prefixFor(name) + name
+ prefixed += "\\fB" + prefixFor(name) + name + "\\fP"
if placeholder != "" {
prefixed += " " + placeholder
}
@@ -745,7 +745,7 @@ func stringifyFlag(f Flag) string {
usageWithDefault := strings.TrimSpace(fmt.Sprintf("%s%s", usage, defaultValueString))
return withEnvHint(fv.FieldByName("EnvVar").String(),
- fmt.Sprintf("%s\t%s", prefixedNames(fv.FieldByName("Name").String(), placeholder), usageWithDefault))
+ fmt.Sprintf("%s\n\t\t\t%s", prefixedNames(fv.FieldByName("Name").String(), placeholder), usageWithDefault))
}
func stringifyIntSliceFlag(f IntSliceFlag) string {

View File

@ -0,0 +1,37 @@
From 2c95b49b63651ae3e0a3f63c45c05295d1af2c42 Mon Sep 17 00:00:00 2001
From: lsytj0413 <511121939@qq.com>
Date: Thu, 19 Sep 2019 09:51:51 +0800
Subject: [PATCH] test(functional): remove unknown field Etcd.Debug
---
functional/tester/cluster_test.go | 3 ---
1 file changed, 3 deletions(-)
diff --git a/functional/tester/cluster_test.go b/functional/tester/cluster_test.go
index 7c7b25f2ad..2948c00e7f 100644
--- a/functional/tester/cluster_test.go
+++ b/functional/tester/cluster_test.go
@@ -64,7 +64,6 @@ func Test_read(t *testing.T) {
InitialCorruptCheck: true,
Logger: "zap",
LogOutputs: []string{"/tmp/etcd-functional-1/etcd.log"},
- Debug: true,
},
ClientCertData: "",
ClientCertPath: "",
@@ -117,7 +116,6 @@ func Test_read(t *testing.T) {
InitialCorruptCheck: true,
Logger: "zap",
LogOutputs: []string{"/tmp/etcd-functional-2/etcd.log"},
- Debug: true,
},
ClientCertData: "",
ClientCertPath: "",
@@ -170,7 +168,6 @@ func Test_read(t *testing.T) {
InitialCorruptCheck: true,
Logger: "zap",
LogOutputs: []string{"/tmp/etcd-functional-3/etcd.log"},
- Debug: true,
},
ClientCertData: "",
ClientCertPath: "",

View File

@ -1,56 +0,0 @@
From 7ad700a716c2122c3b6db6677a6f717919b88926 Mon Sep 17 00:00:00 2001
From: Jan Chaloupka <jchaloup@redhat.com>
Date: Tue, 2 May 2017 09:56:02 +0200
Subject: [PATCH] bz1350875-disaster-recovery-with-copies:
---
etcdctl/ctlv2/command/backup_command.go | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/etcdctl/ctlv2/command/backup_command.go b/etcdctl/ctlv2/command/backup_command.go
index feda4b1..e77791f 100644
--- a/etcdctl/ctlv2/command/backup_command.go
+++ b/etcdctl/ctlv2/command/backup_command.go
@@ -18,6 +18,7 @@ import (
"fmt"
"log"
"path/filepath"
+ "strconv"
"time"
"github.com/coreos/etcd/etcdserver/etcdserverpb"
@@ -40,6 +41,9 @@ func NewBackupCommand() cli.Command {
cli.StringFlag{Name: "wal-dir", Value: "", Usage: "Path to the etcd wal dir"},
cli.StringFlag{Name: "backup-dir", Value: "", Usage: "Path to the backup dir"},
cli.StringFlag{Name: "backup-wal-dir", Value: "", Usage: "Path to the backup wal dir"},
+ cli.BoolFlag{Name: "keep-cluster-id", Usage: "Do not rewrite the cluster id"},
+ cli.StringFlag{Name: "node-id", Value: "", Usage: "Use custom node id instead of a random value"},
+
},
Action: handleBackup,
}
@@ -99,8 +103,19 @@ func handleBackup(c *cli.Context) error {
var metadata etcdserverpb.Metadata
pbutil.MustUnmarshal(&metadata, wmetadata)
idgen := idutil.NewGenerator(0, time.Now())
- metadata.NodeID = idgen.Next()
- metadata.ClusterID = idgen.Next()
+ explicitNodeId := c.String("node-id")
+ if explicitNodeId != "" {
+ metadata.NodeID, err = strconv.ParseUint(explicitNodeId, 16, 64)
+ if err != nil {
+ log.Fatal(err)
+ }
+ } else {
+ metadata.NodeID = idgen.Next()
+ }
+ keepClusterId := c.Bool("keep-cluster-id")
+ if !keepClusterId {
+ metadata.ClusterID = idgen.Next()
+ }
neww, err := wal.Create(destWAL, pbutil.MustMarshal(&metadata))
if err != nil {
--
2.7.4

BIN
etcd-3.4.7.tar.gz Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,35 +1,31 @@
#[Member]
#ETCD_CORS=""
# [member]
ETCD_NAME=default
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
#ETCD_WAL_DIR=""
#ETCD_SNAPSHOT_COUNT="10000"
#ETCD_HEARTBEAT_INTERVAL="100"
#ETCD_ELECTION_TIMEOUT="1000"
#ETCD_LISTEN_PEER_URLS="http://localhost:2380"
ETCD_LISTEN_CLIENT_URLS="http://localhost:2379"
#ETCD_MAX_SNAPSHOTS="5"
#ETCD_MAX_WALS="5"
ETCD_NAME="default"
#ETCD_SNAPSHOT_COUNT="100000"
#ETCD_HEARTBEAT_INTERVAL="100"
#ETCD_ELECTION_TIMEOUT="1000"
#ETCD_QUOTA_BACKEND_BYTES="0"
#ETCD_MAX_REQUEST_BYTES="1572864"
#ETCD_GRPC_KEEPALIVE_MIN_TIME="5s"
#ETCD_GRPC_KEEPALIVE_INTERVAL="2h0m0s"
#ETCD_GRPC_KEEPALIVE_TIMEOUT="20s"
#ETCD_CORS=""
#
#[Clustering]
#[cluster]
#ETCD_INITIAL_ADVERTISE_PEER_URLS="http://localhost:2380"
# if you use different ETCD_NAME (e.g. test), set ETCD_INITIAL_CLUSTER value for this name, i.e. "test=http://..."
#ETCD_INITIAL_CLUSTER="default=http://localhost:2380"
#ETCD_INITIAL_CLUSTER_STATE="new"
#ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"
#ETCD_DISCOVERY=""
#ETCD_DISCOVERY_SRV=""
#ETCD_DISCOVERY_FALLBACK="proxy"
#ETCD_DISCOVERY_PROXY=""
#ETCD_DISCOVERY_SRV=""
#ETCD_INITIAL_CLUSTER="default=http://localhost:2380"
#ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
#ETCD_INITIAL_CLUSTER_STATE="new"
#ETCD_STRICT_RECONFIG_CHECK="true"
#ETCD_ENABLE_V2="true"
#ETCD_STRICT_RECONFIG_CHECK="false"
#ETCD_AUTO_COMPACTION_RETENTION="0"
#
#[Proxy]
#[proxy]
#ETCD_PROXY="off"
#ETCD_PROXY_FAILURE_WAIT="5000"
#ETCD_PROXY_REFRESH_INTERVAL="30000"
@ -37,7 +33,7 @@ ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"
#ETCD_PROXY_WRITE_TIMEOUT="5000"
#ETCD_PROXY_READ_TIMEOUT="0"
#
#[Security]
#[security]
#ETCD_CERT_FILE=""
#ETCD_KEY_FILE=""
#ETCD_CLIENT_CERT_AUTH="false"
@ -49,21 +45,7 @@ ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"
#ETCD_PEER_TRUSTED_CA_FILE=""
#ETCD_PEER_AUTO_TLS="false"
#
#[Logging]
#[logging]
#ETCD_DEBUG="false"
# examples for -log-package-levels etcdserver=WARNING,security=DEBUG
#ETCD_LOG_PACKAGE_LEVELS=""
#ETCD_LOG_OUTPUT="default"
#
#[Unsafe]
#ETCD_FORCE_NEW_CLUSTER="false"
#
#[Version]
#ETCD_VERSION="false"
#ETCD_AUTO_COMPACTION_RETENTION="0"
#
#[Profiling]
#ETCD_ENABLE_PPROF="false"
#ETCD_METRICS="basic"
#
#[Auth]
#ETCD_AUTH_TOKEN="simple"

View File

@ -8,9 +8,11 @@ Wants=network-online.target
Type=notify
WorkingDirectory=/var/lib/etcd/
EnvironmentFile=-/etc/etcd/etcd.conf
Environment=ETCD_NAME
Environment=ETCD_UNSUPPORTED_ARCH=arm64
User=etcd
# set GOMAXPROCS to number of processors
ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"${ETCD_NAME}\" --data-dir=\"${ETCD_DATA_DIR}\" --listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\""
ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd"
Restart=on-failure
LimitNOFILE=65536

267
etcd.spec
View File

@ -1,129 +1,220 @@
%global with_debug 1
# Generated by go2rpm
%bcond_without check
%if 0%{?with_debug}
%global _dwz_low_mem_die_limit 0
%else
%global debug_package %{nil}
%endif
# https://github.com/etcd-io/etcd
%global goipath go.etcd.io/etcd
%global forgeurl https://github.com/etcd-io/etcd
Version: 3.4.7
%if ! 0%{?gobuild:1}
%define gobuild(o:) go build -buildmode pie -tags=rpm_crashtraceback -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '-Wl,-z,relro,-z,now'" -a -v -x %{?**};
%endif
%gometa
%global provider github
%global provider_tld com
%global project coreos
%global repo etcd
# https://github.com/coreos/etcd
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path %{provider_prefix}
%global commit 3ac81f3ae2264b21871128a170c78f8a9b2a3187
%global shortcommit %(c=%{commit}; echo ${c:0:7})
# Remove in F33
%global godevelheader %{expand:
Obsoletes: etcd-devel < 3.3.12-5
}
%global system_name etcd
%global man_version 3.2.21
%global goaltipaths github.com/coreos/etcd
%global man_version 3.4.7
Name: etcd
Version: 3.2.21
Release: 2%{?dist}
Summary: A highly-available key value store for shared configuration
License: ASL 2.0
URL: https://%{provider_prefix}
Source0: https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
Source1: %{system_name}.service
Source2: %{system_name}.conf
%global common_description %{expand:
Distributed reliable key-value store for the most critical data of a distributed
system.}
%global golicenses LICENSE NOTICE
%global godocs CONTRIBUTING.md README.md Documentation\\\
README-*.md READMEv2-etcdctl.md
%global gosupfiles integration/fixtures/* etcdserver/api/v2http/testdata/*
%define debug_package %{nil}
Name: etcd
Release: 1%{?dist}
Summary: Distributed reliable key-value store for the most critical data of a distributed system
# Upstream license specification: Apache-2.0
License: ASL 2.0
URL: %{gourl}
Source0: %{gosource}
Source1: %{name}.service
Source2: %{name}.conf
Source3: man-%{man_version}.tar.gz
Patch3: bz1350875-disaster-recovery-with-copies.patch
Patch4: expand-etcd-arch-validation.patch
# sh genmanpages.sh path_to_built_source
Source10: genmanpages.sh
# Not patches to apply here, but used on the source to generate man pages
# Source11: 0001-hack-etcdmain-to-generate-etcd.1.patch
# Source12: 0001-hack-to-generate-man-pages.patch
# Fix a test
Patch0: 0001-remove-unknown-field-Etcd.Debug.patch
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:x86_64 aarch64 ppc64le s390x}
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
BuildRequires: go-compilers-golang-compiler
BuildRequires: compiler(go-compiler)
# BuildRequires: golang(github.com/bgentry/speakeasy)
# BuildRequires: golang(github.com/cockroachdb/datadriven)
# BuildRequires: golang(github.com/coreos/go-semver/semver)
# BuildRequires: golang(github.com/coreos/go-systemd/daemon)
# BuildRequires: golang(github.com/coreos/go-systemd/journal)
# BuildRequires: golang(github.com/coreos/pkg/capnslog)
# BuildRequires: golang(github.com/creack/pty)
# BuildRequires: golang(github.com/dgrijalva/jwt-go)
# BuildRequires: golang(github.com/dustin/go-humanize)
# BuildRequires: golang(github.com/gogo/protobuf/gogoproto)
# BuildRequires: golang(github.com/gogo/protobuf/proto)
# BuildRequires: golang(github.com/golang/groupcache/lru)
# BuildRequires: golang(github.com/golang/protobuf/proto)
# BuildRequires: golang(github.com/google/btree)
# BuildRequires: golang(github.com/google/uuid)
# BuildRequires: golang(github.com/grpc-ecosystem/go-grpc-middleware)
# BuildRequires: golang(github.com/grpc-ecosystem/go-grpc-prometheus)
# BuildRequires: golang(github.com/grpc-ecosystem/grpc-gateway/runtime)
# BuildRequires: golang(github.com/grpc-ecosystem/grpc-gateway/utilities)
# BuildRequires: golang(github.com/jonboulle/clockwork)
# BuildRequires: golang(github.com/json-iterator/go)
# BuildRequires: golang(github.com/modern-go/reflect2)
# BuildRequires: golang(github.com/olekukonko/tablewriter)
# BuildRequires: golang(github.com/prometheus/client_golang/prometheus)
# BuildRequires: golang(github.com/prometheus/client_golang/prometheus/promhttp)
# BuildRequires: golang(github.com/soheilhy/cmux)
# BuildRequires: golang(github.com/spf13/cobra)
# BuildRequires: golang(github.com/spf13/pflag)
# BuildRequires: golang(github.com/tmc/grpc-websocket-proxy/wsproxy)
# BuildRequires: golang(github.com/urfave/cli)
# BuildRequires: golang(github.com/xiang90/probing)
# BuildRequires: golang(go.etcd.io/bbolt)
# BuildRequires: golang(go.uber.org/zap)
# BuildRequires: golang(go.uber.org/zap/zapcore)
# BuildRequires: golang(golang.org/x/crypto/bcrypt)
# BuildRequires: golang(golang.org/x/net/context)
# BuildRequires: golang(golang.org/x/net/http2)
# BuildRequires: golang(golang.org/x/net/trace)
# BuildRequires: golang(golang.org/x/time/rate)
# BuildRequires: golang(google.golang.org/grpc)
# BuildRequires: golang(google.golang.org/grpc/balancer)
# BuildRequires: golang(google.golang.org/grpc/codes)
# BuildRequires: golang(google.golang.org/grpc/connectivity)
# BuildRequires: golang(google.golang.org/grpc/credentials)
# BuildRequires: golang(google.golang.org/grpc/grpclog)
# BuildRequires: golang(google.golang.org/grpc/health)
# BuildRequires: golang(google.golang.org/grpc/health/grpc_health_v1)
# BuildRequires: golang(google.golang.org/grpc/keepalive)
# BuildRequires: golang(google.golang.org/grpc/metadata)
# BuildRequires: golang(google.golang.org/grpc/naming)
# BuildRequires: golang(google.golang.org/grpc/peer)
# BuildRequires: golang(google.golang.org/grpc/resolver)
# BuildRequires: golang(google.golang.org/grpc/resolver/dns)
# BuildRequires: golang(google.golang.org/grpc/resolver/passthrough)
# BuildRequires: golang(google.golang.org/grpc/status)
# BuildRequires: golang(gopkg.in/cheggaaa/pb.v1)
# BuildRequires: golang(gopkg.in/yaml.v2)
# BuildRequires: golang(sigs.k8s.io/yaml)
Obsoletes: etcd3 < 3.0.15
Provides: etcd3 = %{version}-%{release}
BuildRequires: python3-devel
# BuildRequires: %%{py3_dist sphinx sphinx-rtd-theme}
%{?systemd_requires}
BuildRequires: systemd
Requires(pre): shadow-utils
BuildRequires: libpcap-devel
BuildRequires: systemd
Requires(pre): shadow-utils
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%if %{with check}
# Tests
# BuildRequires: golang(github.com/prometheus/client_model/go)
%endif
%description
A highly-available key value store for shared configuration.
%{common_description}
%{?enable_gotoolset7}
%gopkg
%prep
%setup -q -n man-%{man_version} -T -b 3
%setup -q -n %{repo}-%{commit}
#%goprep
%forgesetup
%patch0 -p1
rm -rf cmd/vendor
rm -rf raft/rafttest
# For compatibility
cp -aR etcdserver/api/snap snap
cp -aR etcdserver/api/membership etcdserver/membership
cp -aR etcdserver/api/v2store store
for d in client clientv3 contrib etcdctl functional hack; do
mv $d/README.md README-$d.md
done
mv etcdctl/READMEv2.md READMEv2-etcdctl.md
mkdir -p man/man1
cp ../man-%{man_version}/*.1 man/man1/.
# move content of vendor under Godeps as has been so far
mkdir -p Godeps/_workspace/src
mv cmd/vendor/* Godeps/_workspace/src/.
%patch3 -p1
%patch4 -p1
%build
mkdir -p src/github.com/coreos
ln -s ../../../ src/github.com/coreos/etcd
GO111MODULE=on GOFLAGS=-mod=vendor go build -o %{gobuilddir}/bin/etcd %{goipath}
for cmd in etcdctl; do
GO111MODULE=on GOFLAGS=-mod=vendor go build -o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/$cmd
done
export GOPATH=$(pwd):$(pwd)/Godeps/_workspace:%{gopath}
export LDFLAGS="-X %{import_path}/version.GitSHA=%{shortcommit} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')"
%gobuild -o bin/%{system_name} %{import_path}
%gobuild -o bin/%{system_name}ctl %{import_path}/%{system_name}ctl
# make -C docs help
# make -C docs html
%install
install -D -p -m 0755 bin/%{system_name} %{buildroot}%{_bindir}/%{system_name}
install -D -p -m 0755 bin/%{system_name}ctl %{buildroot}%{_bindir}/%{system_name}ctl
install -D -p -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{system_name}.service
install -d -m 0755 %{buildroot}%{_sysconfdir}/%{system_name}
install -m 644 -t %{buildroot}%{_sysconfdir}/%{system_name} %{SOURCE2}
#%gopkginstall
install -m 0755 -vd %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
install -Dpm 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
install -dm 0755 %{buildroot}%{_sysconfdir}/%{name}
install -pm 644 -t %{buildroot}%{_sysconfdir}/%{name} %{SOURCE2}
# install manpages
install -d %{buildroot}%{_mandir}/man1
install -p -m 644 man/man1/* %{buildroot}%{_mandir}/man1
install -pm 644 man/man1/* %{buildroot}%{_mandir}/man1
# And create /var/lib/etcd
install -d -m 0755 %{buildroot}%{_sharedstatedir}/%{system_name}
install -dm 0755 %{buildroot}%{_sharedstatedir}/%{name}
#%if %{with check}
#%check
#%gocheck -d clientv3 \
# -d e2e \
# -d functional/rpcpb \
# -d functional/tester \
# -d tools/functional-tester/etcd-agent \
# -d integration \
# -d clientv3/integration \
# -d clientv3/balancer \
# -d clientv3/snapshot \
# -d clientv3/ordering \
# -d pkg/expect \
# -d pkg/flags \
# -d pkg/proxy \
# -d pkg/tlsutil \
# -d pkg/transport \
# -t raft \
# -t tests/e2e
#%endif
%pre
getent group %{system_name} >/dev/null || groupadd -r %{system_name}
getent passwd %{system_name} >/dev/null || useradd -r -g %{system_name} -d %{_sharedstatedir}/%{system_name} \
-s /sbin/nologin -c "etcd user" %{system_name}
getent group %{name} >/dev/null || groupadd -r %{name}
getent passwd %{name} >/dev/null || useradd -r -g %{name} -d %{_sharedstatedir}/%{name} \
-s /sbin/nologin -c "etcd user" %{name}
%post
%systemd_post %{system_name}.service
%systemd_post %{name}.service
%preun
%systemd_preun %{system_name}.service
%systemd_preun %{name}.service
%postun
%systemd_postun %{system_name}.service
#define license tag if not already defined
%{!?_licensedir:%global license %doc}
%systemd_postun %{name}.service
%files
%license LICENSE
%doc *.md
%doc glide.lock
%config(noreplace) %{_sysconfdir}/%{system_name}
%{_bindir}/%{system_name}
%{_bindir}/%{system_name}ctl
%dir %attr(-,%{system_name},%{system_name}) %{_sharedstatedir}/%{system_name}
%{_unitdir}/%{system_name}.service
%license LICENSE NOTICE
%doc CONTRIBUTING.md README.md
%doc Documentation README-*.md READMEv2-etcdctl.md
%{_bindir}/*
%config(noreplace) %{_sysconfdir}/%{name}
%dir %attr(-,%{name},%{name}) %{_sharedstatedir}/%{name}
%{_unitdir}/%{name}.service
%{_mandir}/man1/*.1*
#%gopkgfiles
%changelog
* Tue Aug 11 2020 jiangxinyu <jiangxinyu@kylinos.cn> - 3.2.21-2
* Thu Aug 13 2020 jiangxinyu <jiangxinyu@kylinos.cn> - 3.4.7-1
- Init etcd project

View File

@ -1,30 +0,0 @@
From b3e78645c1ffa84bcde511c90df4e3dde652c3fa Mon Sep 17 00:00:00 2001
From: Jan Chaloupka <jchaloup@redhat.com>
Date: Tue, 8 Aug 2017 15:01:04 +0200
Subject: [PATCH] expand etcd arch validation
---
etcdmain/etcd.go | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/etcdmain/etcd.go b/etcdmain/etcd.go
index 2f7f00d..61553d4 100644
--- a/etcdmain/etcd.go
+++ b/etcdmain/etcd.go
@@ -396,6 +396,13 @@ func checkSupportArch() {
if runtime.GOARCH == "amd64" || runtime.GOARCH == "ppc64le" {
return
}
+
+ if runtime.GOARCH == "arm64" || runtime.GOARCH == "s390x" {
+ plog.Warningf("Running etcd on %s architecture is experimental.", runtime.GOARCH)
+ plog.Warningf("Please report any bugs you encounter: https://bugzilla.redhat.com/")
+ 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
--
2.7.5

35
genmanpages.sh Normal file
View File

@ -0,0 +1,35 @@
#!/bin/sh
rm -rf man
mkdir -p man/etcdctl2 man/etcdctl3
pushd man/etcdctl3
ETCDCTL_API=3 ../../$1/bin/etcdctl --help
# rename to etcdctl3...
for line in $(ls *.1); do mv $line $(echo $line | sed "s/etcdctl/etcdctl3/"); done
# rename refs
sed -i "s/\\\fBetcdctl\\\-/\\\fBetcdctl3\\\-/g" *.1
# stress ETCDCTL_API use
sed -i s"/^\\\fBetcdctl /\\\fBETCDCTL=3 etcdctl /" etcdctl3*.1
cd ../etcdctl2
../../$1/bin/etcdctl --help > etcdctl.1
for cmd in $(cat etcdctl.1 | grep "\fBetcdctl\\\-" | cut -d'-' -f2-3 | cut -d'(' -f1); do ../../$1/bin/etcdctl $cmd --help > etcdctl-$cmd.1; done
# rename to etcdctl2
for line in $(ls *.1); do mv $line $(echo $line | sed "s/etcdctl/etcdctl2/"); done
# rename refs
sed -i "s/\\\fBetcdctl\\\-/\\\fBetcdctl2\\\-/g" *.1
cd ..
mv etcdctl2/* .
mv etcdctl3/* .
rm -rf etcdctl2 etcdctl3
cp ../etcdctl.1 .
# Gen etcd.1
../$1/bin/etcd --help > etcd.1

Binary file not shown.

BIN
man-3.4.7.tar.gz Normal file

Binary file not shown.