├── contrib ├── lock │ ├── client │ │ └── .gitignore │ └── storage │ │ └── .gitignore ├── systemd │ ├── sysusers.d │ │ └── 20-etcd.conf │ └── etcd.service ├── README.md ├── raftexample │ ├── Procfile │ └── doc.go └── mixin │ └── README.md ├── scripts ├── README ├── codecov_upload.sh ├── install-marker.sh ├── update_dep.sh ├── build-release.sh └── fix.sh ├── tools ├── benchmark │ ├── .gitignore │ ├── README.md │ ├── doc.go │ ├── cmd │ │ └── doc.go │ └── main.go ├── mod │ ├── install_all.sh │ └── libs.go ├── etcd-dump-logs │ ├── testdecoder │ │ ├── decoder_wrongoutputformat.sh │ │ └── decoder_correctoutputformat.sh │ ├── expectedoutput │ │ ├── listIRRLeaseRevoke.output │ │ ├── listIRRCompaction.output │ │ ├── listIRRLeaseGrant.output │ │ ├── listIRRPut.output │ │ ├── listIRRDeleteRange.output │ │ ├── listIRRRange.output │ │ ├── listIRRTxn.output │ │ ├── listConfigChange.output │ │ ├── listConfigChangeIRRCompaction.output │ │ └── listRequest.output │ └── doc.go ├── local-tester │ ├── bridge.sh │ └── README.md ├── etcd-dump-metrics │ ├── README │ └── install_windows.go ├── etcd-dump-db │ ├── doc.go │ └── utils.go └── rw-heatmaps │ └── README.md ├── tests ├── docker-dns │ ├── resolv.conf │ ├── certs │ │ ├── gencert.json │ │ ├── ca-csr.json │ │ ├── server-ca-csr.json │ │ └── gencerts.sh │ ├── certs-gateway │ │ ├── gencert.json │ │ ├── ca-csr.json │ │ ├── server-ca-csr.json │ │ └── gencerts.sh │ ├── certs-san-dns │ │ ├── gencert.json │ │ ├── ca-csr.json │ │ ├── server-ca-csr-1.json │ │ ├── server-ca-csr-2.json │ │ └── server-ca-csr-3.json │ ├── certs-wildcard │ │ ├── gencert.json │ │ ├── ca-csr.json │ │ ├── server-ca-csr.json │ │ └── gencerts.sh │ ├── certs-common-name-auth │ │ ├── gencert.json │ │ ├── ca-csr.json │ │ ├── server-ca-csr.json │ │ └── gencerts.sh │ ├── certs-common-name-multi │ │ ├── gencert.json │ │ ├── ca-csr.json │ │ ├── server-ca-csr-1.json │ │ ├── server-ca-csr-2.json │ │ └── server-ca-csr-3.json │ ├── rdns.zone │ ├── etcd.zone │ └── named.conf ├── docker-dns-srv │ ├── resolv.conf │ ├── certs │ │ ├── gencert.json │ │ ├── ca-csr.json │ │ ├── server-ca-csr.json │ │ └── gencerts.sh │ ├── certs-gateway │ │ ├── gencert.json │ │ ├── ca-csr.json │ │ ├── server-ca-csr.json │ │ └── gencerts.sh │ ├── certs-wildcard │ │ ├── gencert.json │ │ ├── ca-csr.json │ │ ├── server-ca-csr.json │ │ ├── gencerts.sh │ │ └── run.sh │ ├── rdns.zone │ └── named.conf ├── fixtures │ ├── revoke.crl │ ├── server-ecdsa.key.insecure │ ├── ca-csr.json │ ├── server-ca-csr-ip.json │ ├── server-ca-csr-ipv6.json │ ├── server-ca-csr3.json │ ├── client-ca-csr-nocn.json │ ├── server-ca-csr.json │ ├── server-ca-csr2.json │ ├── server-ca-csr-ecdsa.json │ ├── server-ca-csr-wildcard.json │ └── gencert.json ├── integration │ ├── fixtures-expired │ │ ├── README │ │ ├── gencert.json │ │ ├── ca-csr.json │ │ ├── server-ca-csr-ip.json │ │ └── server-ca-csr.json │ ├── snapshot │ │ └── testdata │ │ │ └── corrupted_backup.db │ ├── main_test.go │ ├── client │ │ ├── main_test.go │ │ └── doc.go │ ├── clientv3 │ │ ├── main_test.go │ │ ├── lease │ │ │ ├── main_test.go │ │ │ └── doc.go │ │ ├── naming │ │ │ └── main_test.go │ │ ├── connectivity │ │ │ ├── main_test.go │ │ │ └── doc.go │ │ └── doc.go │ ├── embed │ │ └── embed_proxy_test.go │ └── doc.go ├── semaphore.test.bash ├── docker-static-ip │ ├── certs │ │ ├── gencert.json │ │ ├── ca-csr.json │ │ ├── server-ca-csr.json │ │ ├── gencerts.sh │ │ └── run.sh │ ├── certs-metrics-proxy │ │ ├── gencert.json │ │ ├── ca-csr.json │ │ ├── server-ca-csr.json │ │ └── gencerts.sh │ └── Dockerfile ├── functional │ ├── scripts │ │ ├── docker-local-tester.sh │ │ └── genproto.sh │ ├── build │ ├── agent │ │ └── doc.go │ ├── tester │ │ ├── doc.go │ │ ├── checker_no_check.go │ │ └── checker.go │ └── cmd │ │ └── etcd-runner │ │ └── main.go ├── e2e │ ├── v2_test.go │ ├── v2v3_test.go │ ├── cluster_direct_test.go │ └── doc.go └── revive.toml ├── hack ├── README.md ├── insta-discovery │ ├── README.md │ ├── discovery │ └── Procfile ├── tls-setup │ └── config │ │ ├── ca-config.json │ │ ├── ca-csr.json │ │ └── req-csr.json ├── kubernetes-deploy │ ├── vulcand.yml │ └── README.md └── benchmark │ └── README.md ├── client ├── v3 │ ├── example_test.go │ ├── example_kv_test.go │ ├── example_auth_test.go │ ├── example_cluster_test.go │ ├── example_lease_test.go │ ├── example_metrics_test.go │ ├── example_watch_test.go │ ├── concurrency │ │ ├── example_stm_test.go │ │ ├── example_mutex_test.go │ │ ├── example_election_test.go │ │ └── doc.go │ ├── example_maintenance_test.go │ ├── snapshot │ │ └── doc.go │ ├── mock │ │ └── mockserver │ │ │ └── doc.go │ ├── experimental │ │ └── recipes │ │ │ └── doc.go │ ├── go.mod │ ├── sort.go │ └── compact_op_test.go ├── v2 │ ├── example_keys_test.go │ ├── cancelreq.go │ ├── go.mod │ └── cluster_error.go └── pkg │ ├── go.mod │ ├── transport │ ├── sockopt_windows.go │ ├── sockopt_unix.go │ └── doc.go │ ├── logutil │ ├── doc.go │ └── log_level.go │ ├── systemd │ └── doc.go │ ├── tlsutil │ └── doc.go │ ├── fileutil │ ├── doc.go │ ├── lock.go │ ├── preallocate_unsupported.go │ ├── dir_unix.go │ ├── sync.go │ └── lock_unix.go │ ├── types │ ├── doc.go │ ├── slice.go │ └── slice_test.go │ ├── testutil │ └── var.go │ └── pathutil │ └── path.go ├── .github ├── ISSUE_TEMPLATE.md ├── SECURITY.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── self-hosted-linux-arm64-graviton2-tests.yml │ ├── asset-transparency.yaml │ ├── functional.yaml │ └── grpcproxy.yaml ├── logos ├── etcd-offset-bw.png ├── etcd-glyph-color.png ├── etcd-offset-color.png ├── etcd-stacked-bw.png ├── etcd-horizontal-bw.png ├── etcd-stacked-color.png └── etcd-horizontal-color.png ├── security └── SECURITY_AUDIT.pdf ├── test ├── pkg ├── adt │ ├── img │ │ ├── red-black-tree-01-insertion.png │ │ ├── red-black-tree-02-delete-514.png │ │ ├── red-black-tree-03-delete-11.png │ │ ├── red-black-tree-04-delete-11.png │ │ ├── red-black-tree-05-delete-11.png │ │ ├── red-black-tree-06-delete-11.png │ │ ├── red-black-tree-07-delete-11.png │ │ ├── red-black-tree-08-delete-11.png │ │ └── red-black-tree-09-delete-11.png │ └── adt.go ├── README.md ├── proxy │ ├── fixtures │ │ ├── gencert.json │ │ ├── ca-csr.json │ │ ├── server-ca-csr.json │ │ └── gencerts.sh │ └── doc.go ├── report │ └── doc.go ├── stringutil │ ├── doc.go │ └── rand_test.go ├── debugutil │ └── doc.go ├── go.mod ├── netutil │ ├── doc.go │ └── routes_linux_test.go ├── cpuutil │ └── doc.go ├── contention │ └── doc.go ├── schedule │ └── doc.go ├── osutil │ ├── signal.go │ ├── signal_linux.go │ └── interrupt_windows.go ├── runtime │ └── fds_other.go └── ioutil │ └── reader_test.go ├── raft ├── confchange │ └── testdata │ │ ├── zero.txt │ │ ├── update.txt │ │ ├── joint_idempotency.txt │ │ ├── joint_learners_next.txt │ │ ├── joint_autoleave.txt │ │ └── simple_idempotency.txt ├── OWNERS ├── go.mod ├── rafttest │ ├── doc.go │ └── interaction_env_handler_campaign.go └── quorum │ └── voteresult_string.go ├── code-of-conduct.md ├── Documentation └── README.md ├── CHANGELOG-2.3.md ├── Dockerfile-release.ppc64le ├── Dockerfile-release.s390x ├── server ├── mvcc │ ├── backend │ │ ├── export_test.go │ │ ├── doc.go │ │ ├── config_default.go │ │ └── config_windows.go │ └── doc.go ├── auth │ ├── main_test.go │ └── doc.go ├── etcdserver │ ├── api │ │ ├── snap │ │ │ ├── snappb │ │ │ │ └── snap.proto │ │ │ └── doc.go │ │ ├── v2http │ │ │ └── doc.go │ │ ├── v3lock │ │ │ └── doc.go │ │ ├── etcdhttp │ │ │ └── doc.go │ │ ├── v2v3 │ │ │ └── doc.go │ │ ├── rafthttp │ │ │ ├── doc.go │ │ │ └── coder.go │ │ ├── v3election │ │ │ └── doc.go │ │ ├── doc.go │ │ ├── membership │ │ │ └── doc.go │ │ ├── v3compactor │ │ │ └── doc.go │ │ └── v2store │ │ │ ├── doc.go │ │ │ └── event_queue.go │ ├── doc.go │ └── cindex │ │ └── doc.go ├── lease │ ├── leasepb │ │ └── lease.proto │ ├── leasehttp │ │ └── doc.go │ └── doc.go ├── mock │ ├── mockwait │ │ └── doc.go │ ├── mockstore │ │ └── doc.go │ └── mockstorage │ │ └── doc.go ├── etcdmain │ └── doc.go ├── proxy │ ├── grpcproxy │ │ ├── doc.go │ │ └── adapter │ │ │ └── doc.go │ ├── tcpproxy │ │ └── doc.go │ └── httpproxy │ │ └── doc.go ├── datadir │ ├── doc.go │ └── datadir_test.go ├── wal │ └── walpb │ │ └── record.proto ├── verify │ └── doc.go └── embed │ ├── config_logging_journal_windows.go │ └── util.go ├── bill-of-materials.override.json ├── Dockerfile-release.arm64 ├── .gitignore ├── codecov.yml ├── .header ├── api ├── go.mod ├── v3rpc │ └── rpctypes │ │ ├── doc.go │ │ ├── metadatafields.go │ │ └── md.go └── authpb │ └── auth.proto ├── etcdutl ├── snapshot │ ├── doc.go │ └── util.go ├── main.go └── etcdutl │ ├── printer_simple.go │ ├── printer_fields.go │ └── common.go ├── etcdctl ├── ctlv2 │ └── command │ │ └── doc.go └── ctlv3 │ └── command │ └── doc.go ├── Dockerfile-release.amd64 ├── Procfile.learner ├── ROADMAP.md ├── dummy.go └── MAINTAINERS /contrib/lock/client/.gitignore: -------------------------------------------------------------------------------- 1 | client -------------------------------------------------------------------------------- /contrib/lock/storage/.gitignore: -------------------------------------------------------------------------------- 1 | storage -------------------------------------------------------------------------------- /scripts/README: -------------------------------------------------------------------------------- 1 | scripts for etcd development -------------------------------------------------------------------------------- /tools/benchmark/.gitignore: -------------------------------------------------------------------------------- 1 | benchmark 2 | -------------------------------------------------------------------------------- /tests/docker-dns/resolv.conf: -------------------------------------------------------------------------------- 1 | nameserver 127.0.0.1 2 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/resolv.conf: -------------------------------------------------------------------------------- 1 | nameserver 127.0.0.1 2 | -------------------------------------------------------------------------------- /hack/README.md: -------------------------------------------------------------------------------- 1 | Various hacks that are used by developers. 2 | -------------------------------------------------------------------------------- /client/v3/example_test.go: -------------------------------------------------------------------------------- 1 | ../../tests/integration/clientv3/examples/example_test.go -------------------------------------------------------------------------------- /client/v3/example_kv_test.go: -------------------------------------------------------------------------------- 1 | ../../tests/integration/clientv3/examples/example_kv_test.go -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | Please read https://etcd.io/docs/latest/reporting_bugs/ 3 | -------------------------------------------------------------------------------- /client/v2/example_keys_test.go: -------------------------------------------------------------------------------- 1 | ../../tests/integration/client/examples/example_keys_test.go -------------------------------------------------------------------------------- /client/v3/example_auth_test.go: -------------------------------------------------------------------------------- 1 | ../../tests/integration/clientv3/examples/example_auth_test.go -------------------------------------------------------------------------------- /client/v3/example_cluster_test.go: -------------------------------------------------------------------------------- 1 | ../../tests/integration/clientv3/examples/example_cluster_test.go -------------------------------------------------------------------------------- /client/v3/example_lease_test.go: -------------------------------------------------------------------------------- 1 | ../../tests/integration/clientv3/examples/example_lease_test.go -------------------------------------------------------------------------------- /client/v3/example_metrics_test.go: -------------------------------------------------------------------------------- 1 | ../../tests/integration/clientv3/examples/example_metrics_test.go -------------------------------------------------------------------------------- /client/v3/example_watch_test.go: -------------------------------------------------------------------------------- 1 | ../../tests/integration/clientv3/examples/example_watch_test.go -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | Please read https://github.com/etcd-io/etcd/blob/main/security/README.md. 3 | -------------------------------------------------------------------------------- /client/v3/concurrency/example_stm_test.go: -------------------------------------------------------------------------------- 1 | ../../../tests/integration/clientv3/concurrency/example_stm_test.go -------------------------------------------------------------------------------- /client/v3/example_maintenance_test.go: -------------------------------------------------------------------------------- 1 | ../../tests/integration/clientv3/examples/example_maintenance_test.go -------------------------------------------------------------------------------- /hack/insta-discovery/README.md: -------------------------------------------------------------------------------- 1 | Starts a cluster via the discovery service locally. Useful for testing. 2 | -------------------------------------------------------------------------------- /logos/etcd-offset-bw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/logos/etcd-offset-bw.png -------------------------------------------------------------------------------- /client/v3/concurrency/example_mutex_test.go: -------------------------------------------------------------------------------- 1 | ../../../tests/integration/clientv3/concurrency/example_mutex_test.go -------------------------------------------------------------------------------- /logos/etcd-glyph-color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/logos/etcd-glyph-color.png -------------------------------------------------------------------------------- /logos/etcd-offset-color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/logos/etcd-offset-color.png -------------------------------------------------------------------------------- /logos/etcd-stacked-bw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/logos/etcd-stacked-bw.png -------------------------------------------------------------------------------- /security/SECURITY_AUDIT.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/security/SECURITY_AUDIT.pdf -------------------------------------------------------------------------------- /tests/fixtures/revoke.crl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/tests/fixtures/revoke.crl -------------------------------------------------------------------------------- /client/v3/concurrency/example_election_test.go: -------------------------------------------------------------------------------- 1 | ../../../tests/integration/clientv3/concurrency/example_election_test.go -------------------------------------------------------------------------------- /logos/etcd-horizontal-bw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/logos/etcd-horizontal-bw.png -------------------------------------------------------------------------------- /logos/etcd-stacked-color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/logos/etcd-stacked-color.png -------------------------------------------------------------------------------- /logos/etcd-horizontal-color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/logos/etcd-horizontal-color.png -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow. 3 | -------------------------------------------------------------------------------- /test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo -e "\\e[91mDEPRECATED!!! Use test.sh script instead.\\e[0m\\n" 4 | sleep 1 5 | 6 | source ./test.sh 7 | -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-01-insertion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/pkg/adt/img/red-black-tree-01-insertion.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-02-delete-514.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/pkg/adt/img/red-black-tree-02-delete-514.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-03-delete-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/pkg/adt/img/red-black-tree-03-delete-11.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-04-delete-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/pkg/adt/img/red-black-tree-04-delete-11.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-05-delete-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/pkg/adt/img/red-black-tree-05-delete-11.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-06-delete-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/pkg/adt/img/red-black-tree-06-delete-11.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-07-delete-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/pkg/adt/img/red-black-tree-07-delete-11.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-08-delete-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/pkg/adt/img/red-black-tree-08-delete-11.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-09-delete-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/pkg/adt/img/red-black-tree-09-delete-11.png -------------------------------------------------------------------------------- /raft/confchange/testdata/zero.txt: -------------------------------------------------------------------------------- 1 | # NodeID zero is ignored. 2 | simple 3 | v1 r0 v0 l0 4 | ---- 5 | voters=(1) 6 | 1: StateProbe match=0 next=0 7 | -------------------------------------------------------------------------------- /tests/integration/fixtures-expired/README: -------------------------------------------------------------------------------- 1 | To generate bad certs 2 | 3 | 1. Manually set system time back to past 4 | 2. Run ./gencerts.sh 5 | 6 | -------------------------------------------------------------------------------- /tests/semaphore.test.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Placeholder until SemaphoreCI is disabled 4 | # E2e tests were migrated to GitHub Actions 5 | -------------------------------------------------------------------------------- /tools/mod/install_all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd ./tools/mod || exit 2 4 | go list --tags tools -f '{{ join .Imports "\n" }}' | xargs gobin -p 5 | -------------------------------------------------------------------------------- /code-of-conduct.md: -------------------------------------------------------------------------------- 1 | ## etcd Community Code of Conduct 2 | 3 | etcd follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). 4 | -------------------------------------------------------------------------------- /tests/integration/snapshot/testdata/corrupted_backup.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Netflix-Skunkworks/etcd/main/tests/integration/snapshot/testdata/corrupted_backup.db -------------------------------------------------------------------------------- /contrib/systemd/sysusers.d/20-etcd.conf: -------------------------------------------------------------------------------- 1 | # etcd - https://github.com/etcd-io/etcd 2 | 3 | #Type Name ID GECOS Home 4 | u etcd - "etcd user" /var/lib/etcd 5 | -------------------------------------------------------------------------------- /tools/etcd-dump-logs/testdecoder/decoder_wrongoutputformat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | while read line 3 | do 4 | echo "$line" | tr 1234567890 abcdefghij 5 | done < "${1:-/dev/stdin}" 6 | -------------------------------------------------------------------------------- /Documentation/README.md: -------------------------------------------------------------------------------- 1 | The etcd docs are hosted at [etcd.io](https://etcd.io/), and so most files formerly in this directory have moved to the [website](https://github.com/etcd-io/website/) repo. 2 | -------------------------------------------------------------------------------- /pkg/README.md: -------------------------------------------------------------------------------- 1 | pkg/ is a collection of utility packages used by etcd without being specific to etcd itself. A package belongs here 2 | only if it could possibly be moved out into its own repository in the future. 3 | -------------------------------------------------------------------------------- /hack/insta-discovery/discovery: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -rf infra*.etcd 4 | disc=$(curl -s https://discovery.etcd.io/new?size=3) 5 | echo ETCD_DISCOVERY=${disc} > .env 6 | echo "setup discovery start your cluster" 7 | cat .env 8 | goreman start 9 | -------------------------------------------------------------------------------- /tests/fixtures/server-ecdsa.key.insecure: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PRIVATE KEY----- 2 | MHcCAQEEIEmvbcwNyqDHWXBG2IHZffLme5Ti8oHYzaapBvwkRSWWoAoGCCqGSM49 3 | AwEHoUQDQgAERIQpJcG78xaMzT5K92OTxq0K9coHy+UPl4bzzk0xIxDf88I8PS9E 4 | Go34RPDHfPahA9I/MRwCnkEa7pYL/xVl1w== 5 | -----END EC PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /pkg/proxy/fixtures/gencert.json: -------------------------------------------------------------------------------- 1 | { 2 | "signing": { 3 | "default": { 4 | "usages": [ 5 | "signing", 6 | "key encipherment", 7 | "server auth", 8 | "client auth" 9 | ], 10 | "expiry": "87600h" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /hack/tls-setup/config/ca-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "signing": { 3 | "default": { 4 | "usages": [ 5 | "signing", 6 | "key encipherment", 7 | "server auth", 8 | "client auth" 9 | ], 10 | "expiry": "876000h" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/docker-dns/certs/gencert.json: -------------------------------------------------------------------------------- 1 | { 2 | "signing": { 3 | "default": { 4 | "usages": [ 5 | "signing", 6 | "key encipherment", 7 | "server auth", 8 | "client auth" 9 | ], 10 | "expiry": "87600h" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /client/pkg/go.mod: -------------------------------------------------------------------------------- 1 | module go.etcd.io/etcd/client/pkg/v3 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/coreos/go-systemd/v22 v22.3.1 7 | github.com/stretchr/testify v1.7.0 8 | go.uber.org/zap v1.16.1-0.20210329175301-c23abee72d19 9 | golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 10 | ) 11 | -------------------------------------------------------------------------------- /raft/OWNERS: -------------------------------------------------------------------------------- 1 | approvers: 2 | - heyitsanthony 3 | - philips 4 | - fanminshi 5 | - gyuho 6 | - mitake 7 | - jpbetz 8 | - xiang90 9 | - bdarnell 10 | reviewers: 11 | - heyitsanthony 12 | - philips 13 | - fanminshi 14 | - gyuho 15 | - mitake 16 | - jpbetz 17 | - xiang90 18 | - bdarnell 19 | - tschottdorf 20 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/certs/gencert.json: -------------------------------------------------------------------------------- 1 | { 2 | "signing": { 3 | "default": { 4 | "usages": [ 5 | "signing", 6 | "key encipherment", 7 | "server auth", 8 | "client auth" 9 | ], 10 | "expiry": "87600h" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-gateway/gencert.json: -------------------------------------------------------------------------------- 1 | { 2 | "signing": { 3 | "default": { 4 | "usages": [ 5 | "signing", 6 | "key encipherment", 7 | "server auth", 8 | "client auth" 9 | ], 10 | "expiry": "87600h" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-san-dns/gencert.json: -------------------------------------------------------------------------------- 1 | { 2 | "signing": { 3 | "default": { 4 | "usages": [ 5 | "signing", 6 | "key encipherment", 7 | "server auth", 8 | "client auth" 9 | ], 10 | "expiry": "87600h" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/docker-static-ip/certs/gencert.json: -------------------------------------------------------------------------------- 1 | { 2 | "signing": { 3 | "default": { 4 | "usages": [ 5 | "signing", 6 | "key encipherment", 7 | "server auth", 8 | "client auth" 9 | ], 10 | "expiry": "87600h" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/integration/fixtures-expired/gencert.json: -------------------------------------------------------------------------------- 1 | { 2 | "signing": { 3 | "default": { 4 | "usages": [ 5 | "signing", 6 | "key encipherment", 7 | "server auth", 8 | "client auth" 9 | ], 10 | "expiry": "1h" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/certs-gateway/gencert.json: -------------------------------------------------------------------------------- 1 | { 2 | "signing": { 3 | "default": { 4 | "usages": [ 5 | "signing", 6 | "key encipherment", 7 | "server auth", 8 | "client auth" 9 | ], 10 | "expiry": "87600h" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/certs-wildcard/gencert.json: -------------------------------------------------------------------------------- 1 | { 2 | "signing": { 3 | "default": { 4 | "usages": [ 5 | "signing", 6 | "key encipherment", 7 | "server auth", 8 | "client auth" 9 | ], 10 | "expiry": "87600h" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-wildcard/gencert.json: -------------------------------------------------------------------------------- 1 | { 2 | "signing": { 3 | "default": { 4 | "usages": [ 5 | "signing", 6 | "key encipherment", 7 | "server auth", 8 | "client auth" 9 | ], 10 | "expiry": "87600h" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-common-name-auth/gencert.json: -------------------------------------------------------------------------------- 1 | { 2 | "signing": { 3 | "default": { 4 | "usages": [ 5 | "signing", 6 | "key encipherment", 7 | "server auth", 8 | "client auth" 9 | ], 10 | "expiry": "87600h" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-common-name-multi/gencert.json: -------------------------------------------------------------------------------- 1 | { 2 | "signing": { 3 | "default": { 4 | "usages": [ 5 | "signing", 6 | "key encipherment", 7 | "server auth", 8 | "client auth" 9 | ], 10 | "expiry": "87600h" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tests/docker-static-ip/certs-metrics-proxy/gencert.json: -------------------------------------------------------------------------------- 1 | { 2 | "signing": { 3 | "default": { 4 | "usages": [ 5 | "signing", 6 | "key encipherment", 7 | "server auth", 8 | "client auth" 9 | ], 10 | "expiry": "87600h" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tools/etcd-dump-logs/testdecoder/decoder_correctoutputformat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | while read line 3 | do 4 | LEN=$(echo ${#line}) 5 | if [ $LEN -ge 20 ]; then 6 | echo "OK|$line" | tr 1234567890 abcdefghij 7 | else 8 | echo "ERROR|$line" | tr 1234567890 abcdefghij 9 | fi 10 | done < "${1:-/dev/stdin}" 11 | -------------------------------------------------------------------------------- /CHANGELOG-2.3.md: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | ## [v2.3.8](https://github.com/etcd-io/etcd/releases/tag/v2.3.8) (2017-02-17) 7 | 8 | See [code changes](https://github.com/etcd-io/etcd/compare/v2.3.7...v2.3.8). 9 | 10 | ### Go 11 | 12 | - Compile with [*Go 1.7.5*](https://golang.org/doc/devel/release.html#go1.7). 13 | 14 | 15 |
16 | 17 | -------------------------------------------------------------------------------- /Dockerfile-release.ppc64le: -------------------------------------------------------------------------------- 1 | FROM k8s.gcr.io/build-image/debian-base-ppc64le:buster-v1.4.0 2 | 3 | ADD etcd /usr/local/bin/ 4 | ADD etcdctl /usr/local/bin/ 5 | ADD etcdutl /usr/local/bin/ 6 | ADD var/etcd /var/etcd 7 | ADD var/lib/etcd /var/lib/etcd 8 | 9 | EXPOSE 2379 2380 10 | 11 | # Define default command. 12 | CMD ["/usr/local/bin/etcd"] 13 | -------------------------------------------------------------------------------- /Dockerfile-release.s390x: -------------------------------------------------------------------------------- 1 | FROM k8s.gcr.io/build-image/debian-base-s390x:buster-v1.4.0 2 | 3 | ADD etcd /usr/local/bin/ 4 | ADD etcdctl /usr/local/bin/ 5 | ADD etcdutl /usr/local/bin/ 6 | ADD var/etcd /var/etcd 7 | ADD var/lib/etcd /var/lib/etcd 8 | 9 | EXPOSE 2379 2380 10 | 11 | # Define default command. 12 | CMD ["/usr/local/bin/etcd"] 13 | -------------------------------------------------------------------------------- /server/mvcc/backend/export_test.go: -------------------------------------------------------------------------------- 1 | package backend 2 | 3 | import bolt "go.etcd.io/bbolt" 4 | 5 | func DbFromBackendForTest(b Backend) *bolt.DB { 6 | return b.(*backend).db 7 | } 8 | 9 | func DefragLimitForTest() int { 10 | return defragLimit 11 | } 12 | 13 | func CommitsForTest(b Backend) int64 { 14 | return b.(*backend).Commits() 15 | } 16 | -------------------------------------------------------------------------------- /tools/benchmark/README.md: -------------------------------------------------------------------------------- 1 | # etcd/tools/benchmark 2 | 3 | `etcd/tools/benchmark` is the official benchmarking tool for etcd clusters. 4 | 5 | ## Download and install 6 | To get `benchmark` from the `main` branch via `go get`: 7 | ```sh 8 | $ go get go.etcd.io/etcd/tools/benchmark 9 | # GOPATH should be set 10 | $ ls $GOPATH/bin 11 | benchmark 12 | ``` 13 | -------------------------------------------------------------------------------- /bill-of-materials.override.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "project": "sigs.k8s.io/yaml", 4 | "licenses": [ 5 | { 6 | "type": "BSD 3-clause \"New\" or \"Revised\" License" 7 | } 8 | ] 9 | }, 10 | { 11 | "project": "github.com/inconshreveable/mousetrap", 12 | "licenses": [ 13 | { 14 | "type": "Apache License 2.0" 15 | } 16 | ] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /tests/fixtures/ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "ca", 16 | "ca": { 17 | "expiry": "87600h" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /pkg/proxy/fixtures/ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "ca", 16 | "ca": { 17 | "expiry": "87600h" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tools/etcd-dump-logs/expectedoutput/listIRRLeaseRevoke.output: -------------------------------------------------------------------------------- 1 | Snapshot: 2 | empty 3 | Start dumping log entries from snapshot. 4 | WAL metadata: 5 | nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0 6 | WAL entries: 7 | lastIndex=34 8 | term index type data 9 | 10 16 norm ID:11 lease_revoke: 10 | 11 | Entry types (IRRLeaseRevoke) count is : 1 12 | -------------------------------------------------------------------------------- /tests/docker-dns/certs/ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "ca", 16 | "ca": { 17 | "expiry": "87600h" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tools/etcd-dump-logs/expectedoutput/listIRRCompaction.output: -------------------------------------------------------------------------------- 1 | Snapshot: 2 | empty 3 | Start dumping log entries from snapshot. 4 | WAL metadata: 5 | nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0 6 | WAL entries: 7 | lastIndex=34 8 | term index type data 9 | 8 14 norm ID:9 compaction: 10 | 11 | Entry types (IRRCompaction) count is : 1 12 | -------------------------------------------------------------------------------- /tools/etcd-dump-logs/expectedoutput/listIRRLeaseGrant.output: -------------------------------------------------------------------------------- 1 | Snapshot: 2 | empty 3 | Start dumping log entries from snapshot. 4 | WAL metadata: 5 | nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0 6 | WAL entries: 7 | lastIndex=34 8 | term index type data 9 | 9 15 norm ID:10 lease_grant: 10 | 11 | Entry types (IRRLeaseGrant) count is : 1 12 | -------------------------------------------------------------------------------- /Dockerfile-release.arm64: -------------------------------------------------------------------------------- 1 | FROM k8s.gcr.io/build-image/debian-base-arm64:buster-v1.4.0 2 | 3 | ADD etcd /usr/local/bin/ 4 | ADD etcdctl /usr/local/bin/ 5 | ADD etcdutl /usr/local/bin/ 6 | ADD var/etcd /var/etcd 7 | ADD var/lib/etcd /var/lib/etcd 8 | ENV ETCD_UNSUPPORTED_ARCH=arm64 9 | 10 | EXPOSE 2379 2380 11 | 12 | # Define default command. 13 | CMD ["/usr/local/bin/etcd"] 14 | -------------------------------------------------------------------------------- /hack/tls-setup/config/ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "CN": "Autogenerated CA", 3 | "key": { 4 | "algo": "rsa", 5 | "size": 2048 6 | }, 7 | "names": [ 8 | { 9 | "O": "Honest Achmed's Used Certificates", 10 | "OU": "Hastily-Generated Values Divison", 11 | "L": "San Francisco", 12 | "ST": "California", 13 | "C": "US" 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/certs/ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "ca", 16 | "ca": { 17 | "expiry": "87600h" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/docker-static-ip/certs/ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "ca", 16 | "ca": { 17 | "expiry": "87600h" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/fixtures/server-ca-csr-ip.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "example.com", 16 | "hosts": [ 17 | "127.0.0.1" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /tests/fixtures/server-ca-csr-ipv6.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "example.com", 16 | "hosts": [ 17 | "::1" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/certs-gateway/ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "ca", 16 | "ca": { 17 | "expiry": "87600h" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-gateway/ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "ca", 16 | "ca": { 17 | "expiry": "87600h" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-san-dns/ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "ca", 16 | "ca": { 17 | "expiry": "87600h" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-wildcard/ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "ca", 16 | "ca": { 17 | "expiry": "87600h" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/docker-static-ip/certs/server-ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "hosts": [ 16 | "127.0.0.1", 17 | "localhost" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /tests/integration/fixtures-expired/ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "ca", 16 | "ca": { 17 | "expiry": "87600h" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/certs-wildcard/ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "ca", 16 | "ca": { 17 | "expiry": "87600h" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-common-name-auth/ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "ca", 16 | "ca": { 17 | "expiry": "87600h" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/fixtures/server-ca-csr3.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "", 16 | "hosts": [ 17 | "127.0.0.1", 18 | "localhost" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /tools/etcd-dump-logs/expectedoutput/listIRRPut.output: -------------------------------------------------------------------------------- 1 | Snapshot: 2 | empty 3 | Start dumping log entries from snapshot. 4 | WAL metadata: 5 | nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0 6 | WAL entries: 7 | lastIndex=34 8 | term index type data 9 | 5 11 norm ID:6 put: 10 | 11 | Entry types (IRRPut) count is : 1 12 | -------------------------------------------------------------------------------- /contrib/README.md: -------------------------------------------------------------------------------- 1 | ## Contrib 2 | 3 | Scripts and files which may be useful but aren't part of the core etcd project. 4 | 5 | * [systemd](systemd) - an example unit file for deploying etcd on systemd-based distributions 6 | * [raftexample](raftexample) - an example distributed key-value store using raft 7 | * [systemd/etcd3-multinode](systemd/etcd3-multinode) - multi-node cluster setup with systemd 8 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-common-name-multi/ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "ca", 16 | "ca": { 17 | "expiry": "87600h" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/docker-static-ip/certs-metrics-proxy/ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "ca", 16 | "ca": { 17 | "expiry": "87600h" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/fixtures/client-ca-csr-nocn.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "", 16 | "hosts": [ 17 | "127.0.0.1", 18 | "localhost" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-san-dns/server-ca-csr-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "etcd.local", 16 | "hosts": [ 17 | "m1.etcd.local" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /tests/docker-static-ip/certs-metrics-proxy/server-ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "hosts": [ 16 | "127.0.0.1", 17 | "localhost" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /tests/fixtures/server-ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "example.com", 16 | "hosts": [ 17 | "127.0.0.1", 18 | "localhost" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /tests/integration/fixtures-expired/server-ca-csr-ip.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "example.com", 16 | "hosts": [ 17 | "127.0.0.1" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /tools/etcd-dump-logs/expectedoutput/listIRRDeleteRange.output: -------------------------------------------------------------------------------- 1 | Snapshot: 2 | empty 3 | Start dumping log entries from snapshot. 4 | WAL metadata: 5 | nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0 6 | WAL entries: 7 | lastIndex=34 8 | term index type data 9 | 6 12 norm ID:7 delete_range: 10 | 11 | Entry types (IRRDeleteRange) count is : 1 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /agent-* 2 | /coverage 3 | /covdir 4 | /gopath 5 | /gopath.proto 6 | /release 7 | /bin 8 | *.etcd 9 | *.log 10 | *.swp 11 | /etcd 12 | /hack/insta-discovery/.env 13 | *.coverprofile 14 | *.test 15 | hack/tls-setup/certs 16 | .idea 17 | /contrib/raftexample/raftexample 18 | /contrib/raftexample/raftexample-* 19 | /vendor 20 | /tests/e2e/default.proxy 21 | *.tmp 22 | *.bak 23 | .gobincache/ 24 | -------------------------------------------------------------------------------- /pkg/proxy/fixtures/server-ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "example.com", 16 | "hosts": [ 17 | "127.0.0.1", 18 | "localhost" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /server/auth/main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package auth 6 | 7 | import ( 8 | "testing" 9 | 10 | "go.etcd.io/etcd/client/pkg/v3/testutil" 11 | ) 12 | 13 | func TestMain(m *testing.M) { 14 | testutil.MustTestMainWithLeakDetection(m) 15 | } 16 | -------------------------------------------------------------------------------- /tests/fixtures/server-ca-csr2.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "example2.com", 16 | "hosts": [ 17 | "127.0.0.1", 18 | "localhost" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /tests/fixtures/server-ca-csr-ecdsa.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "ecdsa", 4 | "size": 256 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "example.com", 16 | "hosts": [ 17 | "127.0.0.1", 18 | "localhost" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /tools/local-tester/bridge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exec tools/local-tester/bridge/bridge \ 4 | -delay-accept \ 5 | -reset-listen \ 6 | -conn-fault-rate=0.25 \ 7 | -immediate-close \ 8 | -blackhole \ 9 | -time-close \ 10 | -write-remote-only \ 11 | -read-remote-only \ 12 | -random-blackhole \ 13 | -corrupt-receive \ 14 | -corrupt-send \ 15 | -reorder \ 16 | $@ 17 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-wildcard/server-ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "hosts": [ 16 | "*.etcd.local", 17 | "127.0.0.1", 18 | "localhost" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /tests/integration/main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package integration 6 | 7 | import ( 8 | "testing" 9 | 10 | "go.etcd.io/etcd/client/pkg/v3/testutil" 11 | ) 12 | 13 | func TestMain(m *testing.M) { 14 | testutil.MustTestMainWithLeakDetection(m) 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/fixtures-expired/server-ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "example.com", 16 | "hosts": [ 17 | "127.0.0.1", 18 | "localhost" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /hack/tls-setup/config/req-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "CN": "etcd", 3 | "hosts": [ 4 | "localhost", 5 | "127.0.0.1", 6 | "9.145.89.120", 7 | "9.145.89.173", 8 | "9.145.89.225" 9 | ], 10 | "key": { 11 | "algo": "rsa", 12 | "size": 2048 13 | }, 14 | "names": [ 15 | { 16 | "O": "autogenerated", 17 | "OU": "etcd cluster", 18 | "L": "the internet" 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /tests/integration/client/main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package integration 6 | 7 | import ( 8 | "testing" 9 | 10 | "go.etcd.io/etcd/client/pkg/v3/testutil" 11 | ) 12 | 13 | func TestMain(m *testing.M) { 14 | testutil.MustTestMainWithLeakDetection(m) 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/clientv3/main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package clientv3test 6 | 7 | import ( 8 | "testing" 9 | 10 | "go.etcd.io/etcd/client/pkg/v3/testutil" 11 | ) 12 | 13 | func TestMain(m *testing.M) { 14 | testutil.MustTestMainWithLeakDetection(m) 15 | } 16 | -------------------------------------------------------------------------------- /tests/integration/clientv3/lease/main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package lease_test 6 | 7 | import ( 8 | "testing" 9 | 10 | "go.etcd.io/etcd/client/pkg/v3/testutil" 11 | ) 12 | 13 | func TestMain(m *testing.M) { 14 | testutil.MustTestMainWithLeakDetection(m) 15 | } 16 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-san-dns/server-ca-csr-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "etcd.local", 16 | "hosts": [ 17 | "m2.etcd.local" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-san-dns/server-ca-csr-3.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "etcd.local", 16 | "hosts": [ 17 | "m3.etcd.local" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /tests/integration/clientv3/naming/main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package naming_test 6 | 7 | import ( 8 | "testing" 9 | 10 | "go.etcd.io/etcd/client/pkg/v3/testutil" 11 | ) 12 | 13 | func TestMain(m *testing.M) { 14 | testutil.MustTestMainWithLeakDetection(m) 15 | } 16 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/certs-wildcard/server-ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "hosts": [ 16 | "*.etcd.local", 17 | "etcd.local", 18 | "127.0.0.1", 19 | "localhost" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /tests/integration/clientv3/connectivity/main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package connectivity 6 | 7 | import ( 8 | "testing" 9 | 10 | "go.etcd.io/etcd/client/pkg/v3/testutil" 11 | ) 12 | 13 | func TestMain(m *testing.M) { 14 | testutil.MustTestMainWithLeakDetection(m) 15 | } 16 | -------------------------------------------------------------------------------- /tests/docker-dns/rdns.zone: -------------------------------------------------------------------------------- 1 | $TTL 86400 2 | @ IN SOA etcdns.local. root.etcdns.local. ( 3 | 100500 ; Serial 4 | 604800 ; Refresh 5 | 86400 ; Retry 6 | 2419200 ; Expire 7 | 86400 ) ; Negative Cache TTL 8 | IN NS ns.etcdns.local. 9 | IN A 127.0.0.1 10 | 11 | 1 IN PTR m1.etcd.local. 12 | 1 IN PTR m2.etcd.local. 13 | 1 IN PTR m3.etcd.local. 14 | -------------------------------------------------------------------------------- /server/etcdserver/api/snap/snappb/snap.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package snappb; 3 | 4 | import "gogoproto/gogo.proto"; 5 | 6 | option (gogoproto.marshaler_all) = true; 7 | option (gogoproto.sizer_all) = true; 8 | option (gogoproto.unmarshaler_all) = true; 9 | option (gogoproto.goproto_getters_all) = false; 10 | 11 | message snapshot { 12 | optional uint32 crc = 1 [(gogoproto.nullable) = false]; 13 | optional bytes data = 2; 14 | } 15 | -------------------------------------------------------------------------------- /tests/docker-dns/etcd.zone: -------------------------------------------------------------------------------- 1 | $TTL 86400 2 | @ IN SOA etcdns.local. root.etcdns.local. ( 3 | 100500 ; Serial 4 | 604800 ; Refresh 5 | 86400 ; Retry 6 | 2419200 ; Expire 7 | 86400 ) ; Negative Cache TTL 8 | IN NS ns.etcdns.local. 9 | IN A 127.0.0.1 10 | 11 | ns IN A 127.0.0.1 12 | m1 IN A 127.0.0.1 13 | m2 IN A 127.0.0.1 14 | m3 IN A 127.0.0.1 15 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-common-name-multi/server-ca-csr-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "etcd.local", 16 | "hosts": [ 17 | "m1.etcd.local", 18 | "127.0.0.1", 19 | "localhost" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /tools/etcd-dump-logs/expectedoutput/listIRRRange.output: -------------------------------------------------------------------------------- 1 | Snapshot: 2 | empty 3 | Start dumping log entries from snapshot. 4 | WAL metadata: 5 | nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0 6 | WAL entries: 7 | lastIndex=34 8 | term index type data 9 | 4 10 norm ID:5 range: 10 | 11 | Entry types (IRRRange) count is : 1 12 | -------------------------------------------------------------------------------- /tools/etcd-dump-logs/expectedoutput/listIRRTxn.output: -------------------------------------------------------------------------------- 1 | Snapshot: 2 | empty 3 | Start dumping log entries from snapshot. 4 | WAL metadata: 5 | nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0 6 | WAL entries: 7 | lastIndex=34 8 | term index type data 9 | 7 13 norm ID:8 txn: > failure: > > 10 | 11 | Entry types (IRRTxn) count is : 1 12 | -------------------------------------------------------------------------------- /tests/docker-dns/certs/server-ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "hosts": [ 16 | "m1.etcd.local", 17 | "m2.etcd.local", 18 | "m3.etcd.local", 19 | "127.0.0.1", 20 | "localhost" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /tests/fixtures/server-ca-csr-wildcard.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "example.com", 16 | "hosts": [ 17 | "*.etcd.local", 18 | "etcd.local", 19 | "127.0.0.1", 20 | "localhost" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-gateway/server-ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "hosts": [ 16 | "m1.etcd.local", 17 | "m2.etcd.local", 18 | "m3.etcd.local", 19 | "127.0.0.1", 20 | "localhost" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /contrib/raftexample/Procfile: -------------------------------------------------------------------------------- 1 | # Use goreman to run `go get github.com/mattn/goreman` 2 | raftexample1: ./raftexample --id 1 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 12380 3 | raftexample2: ./raftexample --id 2 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 22380 4 | raftexample3: ./raftexample --id 3 --cluster http://127.0.0.1:12379,http://127.0.0.1:22379,http://127.0.0.1:32379 --port 32380 5 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/certs-gateway/server-ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "hosts": [ 16 | "m1.etcd.local", 17 | "m2.etcd.local", 18 | "m3.etcd.local", 19 | "etcd.local", 20 | "127.0.0.1", 21 | "localhost" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-common-name-multi/server-ca-csr-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "etcd.local", 16 | "hosts": [ 17 | "m2.etcd.local", 18 | "127.0.0.1", 19 | "localhost" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-common-name-multi/server-ca-csr-3.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "etcd.local", 16 | "hosts": [ 17 | "m3.etcd.local", 18 | "127.0.0.1", 19 | "localhost" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /client/v2/cancelreq.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // borrowed from golang/net/context/ctxhttp/cancelreq.go 6 | 7 | package client 8 | 9 | import "net/http" 10 | 11 | func requestCanceler(tr CancelableTransport, req *http.Request) func() { 12 | ch := make(chan struct{}) 13 | req.Cancel = ch 14 | 15 | return func() { 16 | close(ch) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-common-name-auth/server-ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "CN": "test-common-name", 16 | "hosts": [ 17 | "m1.etcd.local", 18 | "m2.etcd.local", 19 | "m3.etcd.local", 20 | "127.0.0.1", 21 | "localhost" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /tools/etcd-dump-metrics/README: -------------------------------------------------------------------------------- 1 | 2 | go install -v ./tools/etcd-dump-metrics 3 | 4 | # for latest main branch 5 | etcd-dump-metrics > Documentation/metrics/latest 6 | 7 | # Or download etcd v3.3.9 to ./bin 8 | goreman start 9 | etcd-dump-metrics --addr http://localhost:2379/metrics > Documentation/metrics/v3.3.9 10 | 11 | # Or download etcd v3.3.9 to temporary directory to fetch metrics 12 | etcd-dump-metrics --debug --download-ver v3.3.9 13 | etcd-dump-metrics --download-ver v3.3.9 > Documentation/metrics/v3.3.9 14 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/rdns.zone: -------------------------------------------------------------------------------- 1 | $TTL 86400 2 | @ IN SOA etcdns.local. root.etcdns.local. ( 3 | 100500 ; Serial 4 | 604800 ; Refresh 5 | 86400 ; Retry 6 | 2419200 ; Expire 7 | 86400 ) ; Negative Cache TTL 8 | IN NS ns.etcdns.local. 9 | IN A 127.0.0.1 10 | 11 | 1 IN PTR m1.etcd.local. 12 | 1 IN PTR m2.etcd.local. 13 | 1 IN PTR m3.etcd.local. 14 | 1 IN PTR m4.etcd.local. 15 | 1 IN PTR m5.etcd.local. 16 | 1 IN PTR m6.etcd.local. 17 | 18 | -------------------------------------------------------------------------------- /tests/functional/scripts/docker-local-tester.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if ! [[ "${0}" =~ "scripts/docker-local-tester.sh" ]]; then 4 | echo "must be run from functional" 5 | exit 255 6 | fi 7 | 8 | if [[ -z "${GO_VERSION}" ]]; then 9 | GO_VERSION=1.14.3 10 | fi 11 | echo "Running with GO_VERSION:" ${GO_VERSION} 12 | 13 | docker run \ 14 | --rm \ 15 | --net=host \ 16 | --name tester \ 17 | gcr.io/etcd-development/etcd-functional:go${GO_VERSION} \ 18 | /bin/bash -c "./bin/etcd-tester --config ./functional.yaml" 19 | -------------------------------------------------------------------------------- /tools/etcd-dump-logs/expectedoutput/listConfigChange.output: -------------------------------------------------------------------------------- 1 | Snapshot: 2 | empty 3 | Start dumping log entries from snapshot. 4 | WAL metadata: 5 | nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0 6 | WAL entries: 7 | lastIndex=34 8 | term index type data 9 | 1 1 conf method=ConfChangeAddNode id=2 10 | 2 2 conf method=ConfChangeRemoveNode id=2 11 | 2 3 conf method=ConfChangeUpdateNode id=2 12 | 2 4 conf method=ConfChangeAddLearnerNode id=3 13 | 14 | Entry types (ConfigChange) count is : 4 15 | -------------------------------------------------------------------------------- /hack/kubernetes-deploy/vulcand.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | labels: 5 | app: vulcand 6 | name: vulcand 7 | spec: 8 | containers: 9 | - command: 10 | - /go/bin/vulcand 11 | - -apiInterface=0.0.0.0 12 | - --etcd=http://etcd-client:2379 13 | image: mailgun/vulcand:v0.8.0-beta.2 14 | name: vulcand 15 | ports: 16 | - containerPort: 8081 17 | name: api 18 | protocol: TCP 19 | - containerPort: 8082 20 | name: server 21 | protocol: TCP 22 | restartPolicy: Always 23 | -------------------------------------------------------------------------------- /contrib/systemd/etcd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=etcd key-value store 3 | Documentation=https://github.com/etcd-io/etcd 4 | After=network-online.target local-fs.target remote-fs.target time-sync.target 5 | Wants=network-online.target local-fs.target remote-fs.target time-sync.target 6 | 7 | [Service] 8 | User=etcd 9 | Type=notify 10 | Environment=ETCD_DATA_DIR=/var/lib/etcd 11 | Environment=ETCD_NAME=%m 12 | ExecStart=/usr/bin/etcd 13 | Restart=always 14 | RestartSec=10s 15 | LimitNOFILE=40000 16 | 17 | [Install] 18 | WantedBy=multi-user.target 19 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/certs/server-ca-csr.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": { 3 | "algo": "rsa", 4 | "size": 2048 5 | }, 6 | "names": [ 7 | { 8 | "O": "etcd", 9 | "OU": "etcd Security", 10 | "L": "San Francisco", 11 | "ST": "California", 12 | "C": "USA" 13 | } 14 | ], 15 | "hosts": [ 16 | "m1.etcd.local", 17 | "m2.etcd.local", 18 | "m3.etcd.local", 19 | "m4.etcd.local", 20 | "m5.etcd.local", 21 | "m6.etcd.local", 22 | "etcd.local", 23 | "127.0.0.1", 24 | "localhost" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | token: "6040de41-c073-4d6f-bbf8-d89256ef31e1" 3 | disable_default_path_fixes: true 4 | 5 | fixes: 6 | - "go.etcd.io/etcd/api/v3/::api/" 7 | - "go.etcd.io/etcd/client/v3/::client/v3/" 8 | - "go.etcd.io/etcd/client/v2/::client/v2/" 9 | - "go.etcd.io/etcd/etcdctl/v3/::etcdctl/" 10 | - "go.etcd.io/etcd/pkg/v3/::pkg/" 11 | - "go.etcd.io/etcd/raft/v3/::raft/" 12 | - "go.etcd.io/etcd/server/v3/::server/" 13 | 14 | ignore: 15 | - "**/*.pb.go" 16 | - "**/*.pb.gw.go" 17 | - "tests/**/*" 18 | - "go.etcd.io/etcd/tests/**/*" 19 | -------------------------------------------------------------------------------- /hack/benchmark/README.md: -------------------------------------------------------------------------------- 1 | ## Usage 2 | 3 | Benchmark 3-member etcd cluster to get its read and write performance. 4 | 5 | ## Instructions 6 | 7 | 1. Start 3-member etcd cluster on 3 machines 8 | 2. Update `$leader` and `$servers` in the script 9 | 3. Run the script in a separate machine 10 | 11 | ## Caveat 12 | 13 | 1. Set environment variable `GOMAXPROCS` as the number of available cores to maximize CPU resources for both etcd member and bench process. 14 | 2. Set the number of open files per process as 10000 for amounts of client connections for both etcd member and benchmark process. 15 | -------------------------------------------------------------------------------- /raft/confchange/testdata/update.txt: -------------------------------------------------------------------------------- 1 | # Nobody cares about ConfChangeUpdateNode, but at least use it once. It is used 2 | # by etcd as a convenient way to pass a blob through their conf change machinery 3 | # that updates information tracked outside of raft. 4 | 5 | simple 6 | v1 7 | ---- 8 | voters=(1) 9 | 1: StateProbe match=0 next=0 10 | 11 | simple 12 | v2 u1 13 | ---- 14 | voters=(1 2) 15 | 1: StateProbe match=0 next=0 16 | 2: StateProbe match=0 next=1 17 | 18 | simple 19 | u1 u2 u3 u1 u2 u3 20 | ---- 21 | voters=(1 2) 22 | 1: StateProbe match=0 next=0 23 | 2: StateProbe match=0 next=1 24 | -------------------------------------------------------------------------------- /client/pkg/transport/sockopt_windows.go: -------------------------------------------------------------------------------- 1 | //go:build windows 2 | // +build windows 3 | 4 | package transport 5 | 6 | import ( 7 | "fmt" 8 | "syscall" 9 | ) 10 | 11 | func setReusePort(network, address string, c syscall.RawConn) error { 12 | return fmt.Errorf("port reuse is not supported on Windows") 13 | } 14 | 15 | // Windows supports SO_REUSEADDR, but it may cause undefined behavior, as 16 | // there is no protection against port hijacking. 17 | func setReuseAddress(network, addr string, conn syscall.RawConn) error { 18 | return fmt.Errorf("address reuse is not supported on Windows") 19 | } 20 | -------------------------------------------------------------------------------- /scripts/codecov_upload.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Script used to collect and upload test coverage (mostly by travis). 4 | # Usage ./test_coverage_upload.sh [log_file] 5 | 6 | set -o pipefail 7 | 8 | LOG_FILE=${1:-test-coverage.log} 9 | 10 | # We collect the coverage 11 | COVERDIR=covdir PASSES='build build_cov cov' ./test.sh 2>&1 | tee "${LOG_FILE}" 12 | test_success="$?" 13 | 14 | # We try to upload whatever we have: 15 | bash <(curl -s https://codecov.io/bash) -f ./covdir/all.coverprofile -cF all || exit 2 16 | 17 | # Expose the original status of the test coverage execution. 18 | exit ${test_success} 19 | -------------------------------------------------------------------------------- /client/pkg/transport/sockopt_unix.go: -------------------------------------------------------------------------------- 1 | //go:build !windows 2 | // +build !windows 3 | 4 | package transport 5 | 6 | import ( 7 | "syscall" 8 | 9 | "golang.org/x/sys/unix" 10 | ) 11 | 12 | func setReusePort(network, address string, conn syscall.RawConn) error { 13 | return conn.Control(func(fd uintptr) { 14 | syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEPORT, 1) 15 | }) 16 | } 17 | 18 | func setReuseAddress(network, address string, conn syscall.RawConn) error { 19 | return conn.Control(func(fd uintptr) { 20 | syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEADDR, 1) 21 | }) 22 | } 23 | -------------------------------------------------------------------------------- /tools/etcd-dump-logs/expectedoutput/listConfigChangeIRRCompaction.output: -------------------------------------------------------------------------------- 1 | Snapshot: 2 | empty 3 | Start dumping log entries from snapshot. 4 | WAL metadata: 5 | nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0 6 | WAL entries: 7 | lastIndex=34 8 | term index type data 9 | 1 1 conf method=ConfChangeAddNode id=2 10 | 2 2 conf method=ConfChangeRemoveNode id=2 11 | 2 3 conf method=ConfChangeUpdateNode id=2 12 | 2 4 conf method=ConfChangeAddLearnerNode id=3 13 | 8 14 norm ID:9 compaction: 14 | 15 | Entry types (ConfigChange,IRRCompaction) count is : 5 16 | -------------------------------------------------------------------------------- /tests/docker-dns/named.conf: -------------------------------------------------------------------------------- 1 | options { 2 | directory "/var/bind"; 3 | listen-on { 127.0.0.1; }; 4 | listen-on-v6 { none; }; 5 | allow-transfer { 6 | none; 7 | }; 8 | // If you have problems and are behind a firewall: 9 | query-source address * port 53; 10 | pid-file "/var/run/named/named.pid"; 11 | allow-recursion { none; }; 12 | recursion no; 13 | }; 14 | 15 | zone "etcd.local" IN { 16 | type main; 17 | file "/etc/bind/etcd.zone"; 18 | }; 19 | 20 | zone "0.0.127.in-addr.arpa" { 21 | type main; 22 | file "/etc/bind/rdns.zone"; 23 | }; 24 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/named.conf: -------------------------------------------------------------------------------- 1 | options { 2 | directory "/var/bind"; 3 | listen-on { 127.0.0.1; }; 4 | listen-on-v6 { none; }; 5 | allow-transfer { 6 | none; 7 | }; 8 | // If you have problems and are behind a firewall: 9 | query-source address * port 53; 10 | pid-file "/var/run/named/named.pid"; 11 | allow-recursion { none; }; 12 | recursion no; 13 | }; 14 | 15 | zone "etcd.local" IN { 16 | type main; 17 | file "/etc/bind/etcd.zone"; 18 | }; 19 | 20 | zone "0.0.127.in-addr.arpa" { 21 | type main; 22 | file "/etc/bind/rdns.zone"; 23 | }; 24 | -------------------------------------------------------------------------------- /.header: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | -------------------------------------------------------------------------------- /scripts/install-marker.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | ARCH=$1 6 | 7 | if [ -z "$1" ]; then 8 | echo "Usage: ${0} [amd64 or darwin], defaulting to 'amd64'" >> /dev/stderr 9 | ARCH=amd64 10 | fi 11 | 12 | MARKER_URL=https://storage.googleapis.com/etcd/test-binaries/marker-v0.4.0-x86_64-unknown-linux-gnu 13 | if [ ${ARCH} == "darwin" ]; then 14 | MARKER_URL=https://storage.googleapis.com/etcd/test-binaries/marker-v0.4.0-x86_64-apple-darwin 15 | fi 16 | 17 | echo "Installing marker" 18 | curl -L "${MARKER_URL}" -o "${GOPATH}"/bin/marker 19 | chmod 755 "${GOPATH}"/bin/marker 20 | 21 | "${GOPATH}"/bin/marker --version 22 | -------------------------------------------------------------------------------- /tests/functional/build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if ! [[ "$0" =~ "tests/functional/build" ]]; then 4 | echo "must be run from repository root" 5 | exit 255 6 | fi 7 | 8 | ( 9 | cd ./tests 10 | CGO_ENABLED=0 go build -v -installsuffix cgo -ldflags "-s" -o ../bin/etcd-agent ./functional/cmd/etcd-agent 11 | CGO_ENABLED=0 go build -v -installsuffix cgo -ldflags "-s" -o ../bin/etcd-proxy ./functional/cmd/etcd-proxy 12 | CGO_ENABLED=0 go build -v -installsuffix cgo -ldflags "-s" -o ../bin/etcd-runner ./functional/cmd/etcd-runner 13 | CGO_ENABLED=0 go build -v -installsuffix cgo -ldflags "-s" -o ../bin/etcd-tester ./functional/cmd/etcd-tester 14 | ) 15 | -------------------------------------------------------------------------------- /hack/kubernetes-deploy/README.md: -------------------------------------------------------------------------------- 1 | # etcd on Kubernetes 2 | 3 | This is an example setting up etcd as a set of pods and services running on top of kubernetes. Using: 4 | 5 | ``` 6 | $ kubectl create -f etcd.yml 7 | services/etcd-client 8 | pods/etcd0 9 | services/etcd0 10 | pods/etcd1 11 | services/etcd1 12 | pods/etcd2 13 | services/etcd2 14 | $ # now deploy a service that consumes etcd, such as vulcand 15 | $ kubectl create -f vulcand.yml 16 | ``` 17 | 18 | TODO: 19 | 20 | - create a replication controller like service that knows how to add and remove nodes from the cluster correctly 21 | - use kubernetes secrets API to configure TLS for etcd clients and peers 22 | -------------------------------------------------------------------------------- /raft/confchange/testdata/joint_idempotency.txt: -------------------------------------------------------------------------------- 1 | # Verify that operations upon entering the joint state are idempotent, i.e. 2 | # removing an absent node is fine, etc. 3 | 4 | simple 5 | v1 6 | ---- 7 | voters=(1) 8 | 1: StateProbe match=0 next=0 9 | 10 | enter-joint 11 | r1 r2 r9 v2 v3 v4 v2 v3 v4 l2 l2 r4 r4 l1 l1 12 | ---- 13 | voters=(3)&&(1) learners=(2) learners_next=(1) 14 | 1: StateProbe match=0 next=0 15 | 2: StateProbe match=0 next=1 learner 16 | 3: StateProbe match=0 next=1 17 | 18 | leave-joint 19 | ---- 20 | voters=(3) learners=(1 2) 21 | 1: StateProbe match=0 next=0 learner 22 | 2: StateProbe match=0 next=1 learner 23 | 3: StateProbe match=0 next=1 24 | -------------------------------------------------------------------------------- /.github/workflows/self-hosted-linux-arm64-graviton2-tests.yml: -------------------------------------------------------------------------------- 1 | name: Linux ARM64 Graviton2 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | test: 6 | runs-on: [self-hosted, linux, ARM64, graviton2] 7 | steps: 8 | - uses: actions/checkout@v2 9 | - name: install dependencies 10 | run: | 11 | sudo amazon-linux-extras install epel 12 | sudo yum install -y git gcc ShellCheck 13 | - uses: actions/setup-go@v2 14 | with: 15 | go-version: "^1.16" 16 | - run: go version 17 | - run: date 18 | - name: Run tests 19 | run: TEST_OPTS="PASSES='fmt bom dep build unit integration_e2e'" make test 20 | -------------------------------------------------------------------------------- /tests/integration/clientv3/lease/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package lease 16 | -------------------------------------------------------------------------------- /raft/go.mod: -------------------------------------------------------------------------------- 1 | module go.etcd.io/etcd/raft/v3 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054 // indirect 7 | github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5 8 | github.com/gogo/protobuf v1.3.2 9 | github.com/golang/protobuf v1.5.2 10 | github.com/pkg/errors v0.9.1 // indirect 11 | go.etcd.io/etcd/client/pkg/v3 v3.5.0-alpha.0 12 | ) 13 | 14 | // Bad imports are sometimes causing attempts to pull that code. 15 | // This makes the error more explicit. 16 | replace go.etcd.io/etcd => ./FORBIDDEN_DEPENDENCY 17 | 18 | replace go.etcd.io/etcd/v3 => ./FORBIDDEN_DEPENDENCY 19 | 20 | replace go.etcd.io/etcd/client/pkg/v3 => ../client/pkg 21 | -------------------------------------------------------------------------------- /tests/integration/clientv3/connectivity/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package connectivity 16 | -------------------------------------------------------------------------------- /tests/fixtures/gencert.json: -------------------------------------------------------------------------------- 1 | { 2 | "signing": { 3 | "default": { 4 | "usages": [ 5 | "signing", 6 | "key encipherment", 7 | "server auth", 8 | "client auth" 9 | ], 10 | "expiry": "87600h" 11 | }, 12 | "profiles": { 13 | "client-only": { 14 | "usages": [ 15 | "signing", 16 | "key encipherment", 17 | "client auth" 18 | ], 19 | "expiry": "87600h" 20 | }, 21 | "server-only": { 22 | "usages": [ 23 | "signing", 24 | "key encipherment", 25 | "server auth" 26 | ], 27 | "expiry": "87600h" 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /client/v2/go.mod: -------------------------------------------------------------------------------- 1 | module go.etcd.io/etcd/client/v2 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/json-iterator/go v1.1.10 7 | github.com/modern-go/reflect2 v1.0.1 8 | go.etcd.io/etcd/api/v3 v3.5.0-alpha.0 9 | go.etcd.io/etcd/client/pkg/v3 v3.5.0-alpha.0 10 | ) 11 | 12 | replace ( 13 | go.etcd.io/etcd/api/v3 => ../../api 14 | go.etcd.io/etcd/client/pkg/v3 => ../pkg 15 | ) 16 | 17 | // Bad imports are sometimes causing attempts to pull that code. 18 | // This makes the error more explicit. 19 | replace ( 20 | go.etcd.io/etcd => ./FORBIDDEN_DEPENDENCY 21 | go.etcd.io/etcd/pkg/v3 => ./FORBIDDED_DEPENDENCY 22 | go.etcd.io/etcd/tests/v3 => ./FORBIDDEN_DEPENDENCY 23 | go.etcd.io/etcd/v3 => ./FORBIDDEN_DEPENDENCY 24 | ) 25 | -------------------------------------------------------------------------------- /tools/etcd-dump-db/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // etcd-dump-db inspects etcd db files. 16 | package main 17 | -------------------------------------------------------------------------------- /pkg/adt/adt.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package adt implements useful abstract data types. 16 | package adt 17 | -------------------------------------------------------------------------------- /server/mvcc/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package mvcc defines etcd's stable MVCC storage. 16 | package mvcc 17 | -------------------------------------------------------------------------------- /tests/docker-dns/certs/gencerts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if ! [[ "$0" =~ "./gencerts.sh" ]]; then 4 | echo "must be run from 'fixtures'" 5 | exit 255 6 | fi 7 | 8 | if ! which cfssl; then 9 | echo "cfssl is not installed" 10 | exit 255 11 | fi 12 | 13 | cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca 14 | mv ca.pem ca.crt 15 | openssl x509 -in ca.crt -noout -text 16 | 17 | # generate wildcard certificates DNS: *.etcd.local 18 | cfssl gencert \ 19 | --ca ./ca.crt \ 20 | --ca-key ./ca-key.pem \ 21 | --config ./gencert.json \ 22 | ./server-ca-csr.json | cfssljson --bare ./server 23 | mv server.pem server.crt 24 | mv server-key.pem server.key.insecure 25 | 26 | rm -f *.csr *.pem *.stderr *.txt 27 | -------------------------------------------------------------------------------- /tools/etcd-dump-logs/expectedoutput/listRequest.output: -------------------------------------------------------------------------------- 1 | Snapshot: 2 | empty 3 | Start dumping log entries from snapshot. 4 | WAL metadata: 5 | nodeID=0 clusterID=0 term=0 commitIndex=0 vote=0 6 | WAL entries: 7 | lastIndex=34 8 | term index type data 9 | 3 5 norm noop 10 | 3 6 norm method=QGET path="/path1" 11 | 3 7 norm method=SYNC time="1970-01-01 00:00:00.000000001 +0000 UTC" 12 | 3 8 norm method=DELETE path="/path3" 13 | 3 9 norm method=RANDOM path="/path4/superlong/path/path/path/path/path/path/path/path/path/pa"..."path/path/path/path/path/path/path/path/path/path/path/path/path" val="{\"hey\":\"ho\",\"hi\":[\"yo\"]}" 14 | 15 | Entry types (Request) count is : 5 16 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/certs/gencerts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if ! [[ "$0" =~ "./gencerts.sh" ]]; then 4 | echo "must be run from 'fixtures'" 5 | exit 255 6 | fi 7 | 8 | if ! which cfssl; then 9 | echo "cfssl is not installed" 10 | exit 255 11 | fi 12 | 13 | cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca 14 | mv ca.pem ca.crt 15 | openssl x509 -in ca.crt -noout -text 16 | 17 | # generate wildcard certificates DNS: *.etcd.local 18 | cfssl gencert \ 19 | --ca ./ca.crt \ 20 | --ca-key ./ca-key.pem \ 21 | --config ./gencert.json \ 22 | ./server-ca-csr.json | cfssljson --bare ./server 23 | mv server.pem server.crt 24 | mv server-key.pem server.key.insecure 25 | 26 | rm -f *.csr *.pem *.stderr *.txt 27 | -------------------------------------------------------------------------------- /tests/docker-static-ip/certs/gencerts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if ! [[ "$0" =~ "./gencerts.sh" ]]; then 4 | echo "must be run from 'fixtures'" 5 | exit 255 6 | fi 7 | 8 | if ! which cfssl; then 9 | echo "cfssl is not installed" 10 | exit 255 11 | fi 12 | 13 | cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca 14 | mv ca.pem ca.crt 15 | openssl x509 -in ca.crt -noout -text 16 | 17 | # generate wildcard certificates DNS: *.etcd.local 18 | cfssl gencert \ 19 | --ca ./ca.crt \ 20 | --ca-key ./ca-key.pem \ 21 | --config ./gencert.json \ 22 | ./server-ca-csr.json | cfssljson --bare ./server 23 | mv server.pem server.crt 24 | mv server-key.pem server.key.insecure 25 | 26 | rm -f *.csr *.pem *.stderr *.txt 27 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-gateway/gencerts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if ! [[ "$0" =~ "./gencerts.sh" ]]; then 4 | echo "must be run from 'fixtures'" 5 | exit 255 6 | fi 7 | 8 | if ! which cfssl; then 9 | echo "cfssl is not installed" 10 | exit 255 11 | fi 12 | 13 | cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca 14 | mv ca.pem ca.crt 15 | openssl x509 -in ca.crt -noout -text 16 | 17 | # generate wildcard certificates DNS: *.etcd.local 18 | cfssl gencert \ 19 | --ca ./ca.crt \ 20 | --ca-key ./ca-key.pem \ 21 | --config ./gencert.json \ 22 | ./server-ca-csr.json | cfssljson --bare ./server 23 | mv server.pem server.crt 24 | mv server-key.pem server.key.insecure 25 | 26 | rm -f *.csr *.pem *.stderr *.txt 27 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-wildcard/gencerts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if ! [[ "$0" =~ "./gencerts.sh" ]]; then 4 | echo "must be run from 'fixtures'" 5 | exit 255 6 | fi 7 | 8 | if ! which cfssl; then 9 | echo "cfssl is not installed" 10 | exit 255 11 | fi 12 | 13 | cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca 14 | mv ca.pem ca.crt 15 | openssl x509 -in ca.crt -noout -text 16 | 17 | # generate wildcard certificates DNS: *.etcd.local 18 | cfssl gencert \ 19 | --ca ./ca.crt \ 20 | --ca-key ./ca-key.pem \ 21 | --config ./gencert.json \ 22 | ./server-ca-csr.json | cfssljson --bare ./server 23 | mv server.pem server.crt 24 | mv server-key.pem server.key.insecure 25 | 26 | rm -f *.csr *.pem *.stderr *.txt 27 | -------------------------------------------------------------------------------- /pkg/proxy/fixtures/gencerts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if ! [[ "$0" =~ "./gencerts.sh" ]]; then 4 | echo "must be run from 'fixtures'" 5 | exit 255 6 | fi 7 | 8 | if ! which cfssl; then 9 | echo "cfssl is not installed" 10 | exit 255 11 | fi 12 | 13 | cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca 14 | mv ca.pem ca.crt 15 | openssl x509 -in ca.crt -noout -text 16 | 17 | # generate DNS: localhost, IP: 127.0.0.1, CN: example.com certificates 18 | cfssl gencert \ 19 | --ca ./ca.crt \ 20 | --ca-key ./ca-key.pem \ 21 | --config ./gencert.json \ 22 | ./server-ca-csr.json | cfssljson --bare ./server 23 | mv server.pem server.crt 24 | mv server-key.pem server.key.insecure 25 | 26 | rm -f *.csr *.pem *.stderr *.txt 27 | -------------------------------------------------------------------------------- /pkg/report/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package report generates human-readable benchmark reports. 16 | package report 17 | -------------------------------------------------------------------------------- /pkg/stringutil/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package stringutil exports string utility functions. 16 | package stringutil 17 | -------------------------------------------------------------------------------- /server/lease/leasepb/lease.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package leasepb; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "etcd/api/etcdserverpb/rpc.proto"; 6 | 7 | option (gogoproto.marshaler_all) = true; 8 | option (gogoproto.sizer_all) = true; 9 | option (gogoproto.unmarshaler_all) = true; 10 | option (gogoproto.goproto_getters_all) = false; 11 | option (gogoproto.goproto_enum_prefix_all) = false; 12 | 13 | message Lease { 14 | int64 ID = 1; 15 | int64 TTL = 2; 16 | int64 RemainingTTL = 3; 17 | } 18 | 19 | message LeaseInternalRequest { 20 | etcdserverpb.LeaseTimeToLiveRequest LeaseTimeToLiveRequest = 1; 21 | } 22 | 23 | message LeaseInternalResponse { 24 | etcdserverpb.LeaseTimeToLiveResponse LeaseTimeToLiveResponse = 1; 25 | } 26 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/certs-gateway/gencerts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if ! [[ "$0" =~ "./gencerts.sh" ]]; then 4 | echo "must be run from 'fixtures'" 5 | exit 255 6 | fi 7 | 8 | if ! which cfssl; then 9 | echo "cfssl is not installed" 10 | exit 255 11 | fi 12 | 13 | cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca 14 | mv ca.pem ca.crt 15 | openssl x509 -in ca.crt -noout -text 16 | 17 | # generate wildcard certificates DNS: *.etcd.local 18 | cfssl gencert \ 19 | --ca ./ca.crt \ 20 | --ca-key ./ca-key.pem \ 21 | --config ./gencert.json \ 22 | ./server-ca-csr.json | cfssljson --bare ./server 23 | mv server.pem server.crt 24 | mv server-key.pem server.key.insecure 25 | 26 | rm -f *.csr *.pem *.stderr *.txt 27 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/certs-wildcard/gencerts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if ! [[ "$0" =~ "./gencerts.sh" ]]; then 4 | echo "must be run from 'fixtures'" 5 | exit 255 6 | fi 7 | 8 | if ! which cfssl; then 9 | echo "cfssl is not installed" 10 | exit 255 11 | fi 12 | 13 | cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca 14 | mv ca.pem ca.crt 15 | openssl x509 -in ca.crt -noout -text 16 | 17 | # generate wildcard certificates DNS: *.etcd.local 18 | cfssl gencert \ 19 | --ca ./ca.crt \ 20 | --ca-key ./ca-key.pem \ 21 | --config ./gencert.json \ 22 | ./server-ca-csr.json | cfssljson --bare ./server 23 | mv server.pem server.crt 24 | mv server-key.pem server.key.insecure 25 | 26 | rm -f *.csr *.pem *.stderr *.txt 27 | -------------------------------------------------------------------------------- /api/go.mod: -------------------------------------------------------------------------------- 1 | module go.etcd.io/etcd/api/v3 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/coreos/go-semver v0.3.0 7 | github.com/gogo/protobuf v1.3.2 8 | github.com/golang/protobuf v1.5.2 9 | github.com/grpc-ecosystem/grpc-gateway v1.16.0 10 | google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 11 | google.golang.org/grpc v1.37.0 12 | ) 13 | 14 | // Bad imports are sometimes causing attempts to pull that code. 15 | // This makes the error more explicit. 16 | replace ( 17 | go.etcd.io/etcd => ./FORBIDDEN_DEPENDENCY 18 | go.etcd.io/etcd/api/v3 => ./FORBIDDEN_DEPENDENCY 19 | go.etcd.io/etcd/pkg/v3 => ./FORBIDDEN_DEPENDENCY 20 | go.etcd.io/etcd/tests/v3 => ./FORBIDDEN_DEPENDENCY 21 | go.etcd.io/etcd/v3 => ./FORBIDDEN_DEPENDENCY 22 | ) 23 | -------------------------------------------------------------------------------- /client/pkg/logutil/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package logutil includes utilities to facilitate logging. 16 | package logutil 17 | -------------------------------------------------------------------------------- /client/pkg/systemd/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package systemd provides utility functions for systemd. 16 | package systemd 17 | -------------------------------------------------------------------------------- /etcdutl/snapshot/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package snapshot implements utilities around etcd snapshot. 16 | package snapshot 17 | -------------------------------------------------------------------------------- /pkg/debugutil/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package debugutil includes utility functions for debugging. 16 | package debugutil 17 | -------------------------------------------------------------------------------- /pkg/go.mod: -------------------------------------------------------------------------------- 1 | module go.etcd.io/etcd/pkg/v3 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/creack/pty v1.1.11 7 | github.com/dustin/go-humanize v1.0.0 8 | github.com/golang/protobuf v1.5.1 // indirect 9 | github.com/spf13/cobra v1.1.3 10 | github.com/spf13/pflag v1.0.5 11 | github.com/stretchr/testify v1.7.0 12 | go.etcd.io/etcd/client/pkg/v3 v3.5.0-alpha.0 13 | go.uber.org/zap v1.16.1-0.20210329175301-c23abee72d19 14 | google.golang.org/grpc v1.37.0 15 | ) 16 | 17 | replace ( 18 | go.etcd.io/etcd => ./FORBIDDEN_DEPENDENCY 19 | go.etcd.io/etcd/api/v3 => ./FORBIDDEN_DEPENDENCY 20 | go.etcd.io/etcd/client/pkg/v3 => ../client/pkg 21 | go.etcd.io/etcd/tests/v3 => ./FORBIDDEN_DEPENDENCY 22 | go.etcd.io/etcd/v3 => ./FORBIDDEN_DEPENDENCY 23 | ) 24 | -------------------------------------------------------------------------------- /pkg/netutil/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package netutil implements network-related utility functions. 16 | package netutil 17 | -------------------------------------------------------------------------------- /pkg/proxy/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package proxy implements proxy servers for network fault testing. 16 | package proxy 17 | -------------------------------------------------------------------------------- /tests/docker-static-ip/certs-metrics-proxy/gencerts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if ! [[ "$0" =~ "./gencerts.sh" ]]; then 4 | echo "must be run from 'fixtures'" 5 | exit 255 6 | fi 7 | 8 | if ! which cfssl; then 9 | echo "cfssl is not installed" 10 | exit 255 11 | fi 12 | 13 | cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca 14 | mv ca.pem ca.crt 15 | openssl x509 -in ca.crt -noout -text 16 | 17 | # generate wildcard certificates DNS: *.etcd.local 18 | cfssl gencert \ 19 | --ca ./ca.crt \ 20 | --ca-key ./ca-key.pem \ 21 | --config ./gencert.json \ 22 | ./server-ca-csr.json | cfssljson --bare ./server 23 | mv server.pem server.crt 24 | mv server-key.pem server.key.insecure 25 | 26 | rm -f *.csr *.pem *.stderr *.txt 27 | -------------------------------------------------------------------------------- /tests/functional/agent/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package agent implements functional-tester agent server. 16 | package agent 17 | -------------------------------------------------------------------------------- /tools/benchmark/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // benchmark is a program for benchmarking etcd v3 API performance. 16 | package main 17 | -------------------------------------------------------------------------------- /client/pkg/tlsutil/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package tlsutil provides utility functions for handling TLS. 16 | package tlsutil 17 | -------------------------------------------------------------------------------- /client/v3/snapshot/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package snapshot implements utilities around etcd snapshot. 16 | package snapshot 17 | -------------------------------------------------------------------------------- /etcdctl/ctlv2/command/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package command is a set of libraries for etcdctl commands. 16 | package command 17 | -------------------------------------------------------------------------------- /etcdctl/ctlv3/command/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package command is a set of libraries for etcd v3 commands. 16 | package command 17 | -------------------------------------------------------------------------------- /server/mock/mockwait/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package mockwait provides mock implementations for pkg/wait. 16 | package mockwait 17 | -------------------------------------------------------------------------------- /tests/docker-dns/certs-common-name-auth/gencerts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if ! [[ "$0" =~ "./gencerts.sh" ]]; then 4 | echo "must be run from 'fixtures'" 5 | exit 255 6 | fi 7 | 8 | if ! which cfssl; then 9 | echo "cfssl is not installed" 10 | exit 255 11 | fi 12 | 13 | cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca 14 | mv ca.pem ca.crt 15 | openssl x509 -in ca.crt -noout -text 16 | 17 | # generate wildcard certificates DNS: m1/m2/m3.etcd.local 18 | cfssl gencert \ 19 | --ca ./ca.crt \ 20 | --ca-key ./ca-key.pem \ 21 | --config ./gencert.json \ 22 | ./server-ca-csr.json | cfssljson --bare ./server 23 | mv server.pem server.crt 24 | mv server-key.pem server.key.insecure 25 | 26 | rm -f *.csr *.pem *.stderr *.txt 27 | -------------------------------------------------------------------------------- /tests/functional/tester/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package tester implements functional-tester tester server. 16 | package tester 17 | -------------------------------------------------------------------------------- /Dockerfile-release.amd64: -------------------------------------------------------------------------------- 1 | FROM k8s.gcr.io/build-image/debian-base:buster-v1.4.0 2 | 3 | ADD etcd /usr/local/bin/ 4 | ADD etcdctl /usr/local/bin/ 5 | ADD etcdutl /usr/local/bin/ 6 | RUN mkdir -p /var/etcd/ 7 | RUN mkdir -p /var/lib/etcd/ 8 | 9 | # Alpine Linux doesn't use pam, which means that there is no /etc/nsswitch.conf, 10 | # but Golang relies on /etc/nsswitch.conf to check the order of DNS resolving 11 | # (see https://github.com/golang/go/commit/9dee7771f561cf6aee081c0af6658cc81fac3918) 12 | # To fix this we just create /etc/nsswitch.conf and add the following line: 13 | RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf 14 | 15 | EXPOSE 2379 2380 16 | 17 | # Define default command. 18 | CMD ["/usr/local/bin/etcd"] 19 | -------------------------------------------------------------------------------- /pkg/cpuutil/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package cpuutil provides facilities for detecting cpu-specific features. 16 | package cpuutil 17 | -------------------------------------------------------------------------------- /server/auth/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package auth provides client role authentication for accessing keys in etcd. 16 | package auth 17 | -------------------------------------------------------------------------------- /server/etcdmain/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package etcdmain contains the main entry point for the etcd binary. 16 | package etcdmain 17 | -------------------------------------------------------------------------------- /contrib/raftexample/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // raftexample is a simple KV store using the raft and rafthttp libraries. 16 | package main 17 | -------------------------------------------------------------------------------- /pkg/contention/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package contention provides facilities for detecting system contention. 16 | package contention 17 | -------------------------------------------------------------------------------- /raft/confchange/testdata/joint_learners_next.txt: -------------------------------------------------------------------------------- 1 | # Verify that when a voter is demoted in a joint config, it will show up in 2 | # learners_next until the joint config is left, and only then will the progress 3 | # turn into that of a learner, without resetting the progress. Note that this 4 | # last fact is verified by `next`, which can tell us which "round" the progress 5 | # was originally created in. 6 | 7 | simple 8 | v1 9 | ---- 10 | voters=(1) 11 | 1: StateProbe match=0 next=0 12 | 13 | enter-joint 14 | v2 l1 15 | ---- 16 | voters=(2)&&(1) learners_next=(1) 17 | 1: StateProbe match=0 next=0 18 | 2: StateProbe match=0 next=1 19 | 20 | leave-joint 21 | ---- 22 | voters=(2) learners=(1) 23 | 1: StateProbe match=0 next=0 learner 24 | 2: StateProbe match=0 next=1 25 | -------------------------------------------------------------------------------- /raft/rafttest/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package rafttest provides functional tests for etcd's raft implementation. 16 | package rafttest 17 | -------------------------------------------------------------------------------- /server/etcdserver/api/v2http/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package v2http provides etcd client and server implementations. 16 | package v2http 17 | -------------------------------------------------------------------------------- /server/etcdserver/api/v3lock/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package v3lock provides a v3 locking service from an etcdserver. 16 | package v3lock 17 | -------------------------------------------------------------------------------- /server/lease/leasehttp/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package leasehttp serves lease renewals made through HTTP requests. 16 | package leasehttp 17 | -------------------------------------------------------------------------------- /server/proxy/grpcproxy/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package grpcproxy is an OSI level 7 proxy for etcd v3 API requests. 16 | package grpcproxy 17 | -------------------------------------------------------------------------------- /tools/etcd-dump-logs/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // etcd-dump-logs is a program for analyzing etcd server write ahead logs. 16 | package main 17 | -------------------------------------------------------------------------------- /client/pkg/fileutil/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package fileutil implements utility functions related to files and paths. 16 | package fileutil 17 | -------------------------------------------------------------------------------- /pkg/schedule/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package schedule provides mechanisms and policies for scheduling units of work. 16 | package schedule 17 | -------------------------------------------------------------------------------- /server/datadir/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package datadir 16 | 17 | // datadir contains functions to navigate file-layout of etcd data-directory. 18 | -------------------------------------------------------------------------------- /server/etcdserver/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package etcdserver defines how etcd servers interact and store their states. 16 | package etcdserver 17 | -------------------------------------------------------------------------------- /server/mock/mockstore/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package mockstore provides mock structures for the etcd store package. 16 | package mockstore 17 | -------------------------------------------------------------------------------- /server/mvcc/backend/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package backend defines a standard interface for etcd's backend MVCC storage. 16 | package backend 17 | -------------------------------------------------------------------------------- /tools/benchmark/cmd/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package cmd implements individual benchmark commands for the benchmark utility. 16 | package cmd 17 | -------------------------------------------------------------------------------- /server/etcdserver/api/etcdhttp/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package etcdhttp implements HTTP transportation layer for etcdserver. 16 | package etcdhttp 17 | -------------------------------------------------------------------------------- /server/etcdserver/api/v2v3/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package v2v3 provides a ServerV2 implementation backed by clientv3.Client. 16 | package v2v3 17 | -------------------------------------------------------------------------------- /client/pkg/types/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package types declares various data types and implements type-checking 16 | // functions. 17 | package types 18 | -------------------------------------------------------------------------------- /server/etcdserver/api/rafthttp/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package rafthttp implements HTTP transportation layer for etcd/raft pkg. 16 | package rafthttp 17 | -------------------------------------------------------------------------------- /server/etcdserver/api/v3election/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package v3election provides a v3 election service from an etcdserver. 16 | package v3election 17 | -------------------------------------------------------------------------------- /server/proxy/tcpproxy/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package tcpproxy is an OSI level 4 proxy for routing etcd clients to etcd servers. 16 | package tcpproxy 17 | -------------------------------------------------------------------------------- /client/v3/mock/mockserver/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package mockserver provides mock implementations for etcdserver's server interface. 16 | package mockserver 17 | -------------------------------------------------------------------------------- /client/pkg/transport/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package transport implements various HTTP transport utilities based on Go 16 | // net package. 17 | package transport 18 | -------------------------------------------------------------------------------- /server/etcdserver/api/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package api manages the capabilities and features that are exposed to clients by the etcd cluster. 16 | package api 17 | -------------------------------------------------------------------------------- /server/etcdserver/api/membership/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package membership describes individual etcd members and clusters of members. 16 | package membership 17 | -------------------------------------------------------------------------------- /server/etcdserver/cindex/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package cindex provides an interface and implementation for getting/saving consistentIndex. 16 | package cindex 17 | -------------------------------------------------------------------------------- /server/lease/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package lease provides an interface and implementation for time-limited leases over arbitrary resources. 16 | package lease 17 | -------------------------------------------------------------------------------- /server/mock/mockstorage/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package mockstorage provides mock implementations for etcdserver's storage interface. 16 | package mockstorage 17 | -------------------------------------------------------------------------------- /tests/e2e/v2_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build !v2v3 16 | // +build !v2v3 17 | 18 | package e2e 19 | 20 | func addV2Args(args []string) []string { return args } 21 | -------------------------------------------------------------------------------- /api/v3rpc/rpctypes/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package rpctypes has types and values shared by the etcd server and client for v3 RPC interaction. 16 | package rpctypes 17 | -------------------------------------------------------------------------------- /client/v3/experimental/recipes/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package recipe contains experimental client-side distributed 16 | // synchronization primitives. 17 | package recipe 18 | -------------------------------------------------------------------------------- /server/etcdserver/api/v3compactor/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package v3compactor implements automated policies for compacting etcd's mvcc storage. 16 | package v3compactor 17 | -------------------------------------------------------------------------------- /api/v3rpc/rpctypes/metadatafields.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package rpctypes 16 | 17 | var ( 18 | TokenFieldNameGRPC = "token" 19 | TokenFieldNameSwagger = "authorization" 20 | ) 21 | -------------------------------------------------------------------------------- /.github/workflows/asset-transparency.yaml: -------------------------------------------------------------------------------- 1 | name: Publish Release Assets to Asset Transparency Log 2 | 3 | on: 4 | release: 5 | types: [published, created, edited, released] 6 | 7 | jobs: 8 | github_release_asset_transparency_log_publish_job: 9 | runs-on: ubuntu-latest 10 | name: Publish GitHub release asset digests to https://beta-asset.transparencylog.net 11 | steps: 12 | - name: Gather URLs from GitHub release and publish 13 | id: asset-transparency 14 | uses: transparencylog/github-releases-asset-transparency-verify-action@v11 15 | - name: List verified and published URLs 16 | run: echo "Verified URLs ${{ steps.asset-transparency.outputs.verified }}" 17 | - name: List failed URLs 18 | run: echo "Failed URLs ${{ steps.asset-transparency.outputs.failed }}" 19 | -------------------------------------------------------------------------------- /client/pkg/testutil/var.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package testutil 16 | 17 | import "time" 18 | 19 | var ( 20 | ApplyTimeout = time.Second 21 | RequestTimeout = 3 * time.Second 22 | ) 23 | -------------------------------------------------------------------------------- /raft/quorum/voteresult_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type=VoteResult"; DO NOT EDIT. 2 | 3 | package quorum 4 | 5 | import "strconv" 6 | 7 | func _() { 8 | // An "invalid array index" compiler error signifies that the constant values have changed. 9 | // Re-run the stringer command to generate them again. 10 | var x [1]struct{} 11 | _ = x[VotePending-1] 12 | _ = x[VoteLost-2] 13 | _ = x[VoteWon-3] 14 | } 15 | 16 | const _VoteResult_name = "VotePendingVoteLostVoteWon" 17 | 18 | var _VoteResult_index = [...]uint8{0, 11, 19, 26} 19 | 20 | func (i VoteResult) String() string { 21 | i -= 1 22 | if i >= VoteResult(len(_VoteResult_index)-1) { 23 | return "VoteResult(" + strconv.FormatInt(int64(i+1), 10) + ")" 24 | } 25 | return _VoteResult_name[_VoteResult_index[i]:_VoteResult_index[i+1]] 26 | } 27 | -------------------------------------------------------------------------------- /server/etcdserver/api/v2store/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package v2store defines etcd's in-memory key/value store in v2 API. 16 | // To be deprecated in favor of v3 storage. 17 | package v2store 18 | -------------------------------------------------------------------------------- /tests/integration/clientv3/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package clientv3test implements tests built upon embedded etcd, and focuses on 16 | // correctness of etcd client. 17 | package clientv3test 18 | -------------------------------------------------------------------------------- /tools/etcd-dump-db/utils.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import "os" 18 | 19 | func existFileOrDir(name string) bool { 20 | _, err := os.Stat(name) 21 | return err == nil 22 | } 23 | -------------------------------------------------------------------------------- /raft/confchange/testdata/joint_autoleave.txt: -------------------------------------------------------------------------------- 1 | # Test the autoleave argument to EnterJoint. It defaults to false in the 2 | # datadriven tests. The flag has no associated semantics in this package, 3 | # it is simply passed through. 4 | simple 5 | v1 6 | ---- 7 | voters=(1) 8 | 1: StateProbe match=0 next=0 9 | 10 | # Autoleave is reflected in the config. 11 | enter-joint autoleave=true 12 | v2 v3 13 | ---- 14 | voters=(1 2 3)&&(1) autoleave 15 | 1: StateProbe match=0 next=0 16 | 2: StateProbe match=0 next=1 17 | 3: StateProbe match=0 next=1 18 | 19 | # Can't enter-joint twice, even if autoleave changes. 20 | enter-joint autoleave=false 21 | ---- 22 | config is already joint 23 | 24 | leave-joint 25 | ---- 26 | voters=(1 2 3) 27 | 1: StateProbe match=0 next=0 28 | 2: StateProbe match=0 next=1 29 | 3: StateProbe match=0 next=1 30 | -------------------------------------------------------------------------------- /server/etcdserver/api/snap/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package snap handles Raft nodes' states with snapshots. 16 | // The snapshot logic is internal to etcd server and raft package. 17 | package snap 18 | -------------------------------------------------------------------------------- /server/wal/walpb/record.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package walpb; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "raft/raftpb/raft.proto"; 6 | 7 | option (gogoproto.marshaler_all) = true; 8 | option (gogoproto.sizer_all) = true; 9 | option (gogoproto.unmarshaler_all) = true; 10 | option (gogoproto.goproto_getters_all) = false; 11 | 12 | message Record { 13 | optional int64 type = 1 [(gogoproto.nullable) = false]; 14 | optional uint32 crc = 2 [(gogoproto.nullable) = false]; 15 | optional bytes data = 3; 16 | } 17 | 18 | // Keep in sync with raftpb.SnapshotMetadata. 19 | message Snapshot { 20 | optional uint64 index = 1 [(gogoproto.nullable) = false]; 21 | optional uint64 term = 2 [(gogoproto.nullable) = false]; 22 | // Field populated since >=etcd-3.5.0. 23 | optional raftpb.ConfState conf_state = 3; 24 | } 25 | -------------------------------------------------------------------------------- /tests/integration/client/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package integration implements tests built upon embedded etcd, focusing on 16 | // the correctness of the etcd v2 client. 17 | package integration 18 | -------------------------------------------------------------------------------- /client/v3/concurrency/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package concurrency implements concurrency operations on top of 16 | // etcd such as distributed locks, barriers, and elections. 17 | package concurrency 18 | -------------------------------------------------------------------------------- /pkg/osutil/signal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build !linux || cov 16 | // +build !linux cov 17 | 18 | package osutil 19 | 20 | import "syscall" 21 | 22 | func dflSignal(sig syscall.Signal) { /* nop */ } 23 | -------------------------------------------------------------------------------- /.github/workflows/functional.yaml: -------------------------------------------------------------------------------- 1 | name: functional-tests 2 | on: [push, pull_request] 3 | jobs: 4 | test: 5 | runs-on: ubuntu-latest 6 | strategy: 7 | fail-fast: true 8 | matrix: 9 | target: 10 | - linux-amd64-functional 11 | steps: 12 | - uses: actions/checkout@v2 13 | - uses: actions/setup-go@v2 14 | with: 15 | go-version: "^1.16" 16 | - run: date 17 | - env: 18 | TARGET: ${{ matrix.target }} 19 | run: | 20 | echo "${TARGET}" 21 | case "${TARGET}" in 22 | linux-amd64-functional) 23 | GO_BUILD_FLAGS='-v -mod=readonly' ./build.sh && GOARCH=amd64 PASSES='functional' ./test.sh 24 | ;; 25 | *) 26 | echo "Failed to find target" 27 | exit 1 28 | ;; 29 | esac 30 | -------------------------------------------------------------------------------- /server/proxy/grpcproxy/adapter/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package adapter provides gRPC adapters between client and server 16 | // gRPC interfaces without needing to go through a gRPC connection. 17 | package adapter 18 | -------------------------------------------------------------------------------- /tests/e2e/v2v3_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build v2v3 16 | // +build v2v3 17 | 18 | package e2e 19 | 20 | func addV2Args(args []string) []string { 21 | return append(args, "--experimental-enable-v2v3", "v2/") 22 | } 23 | -------------------------------------------------------------------------------- /api/v3rpc/rpctypes/md.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package rpctypes 16 | 17 | var ( 18 | MetadataRequireLeaderKey = "hasleader" 19 | MetadataHasLeader = "true" 20 | 21 | MetadataClientAPIVersionKey = "client-api-version" 22 | ) 23 | -------------------------------------------------------------------------------- /scripts/update_dep.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Usage: 4 | # ./scripts/update_dep.sh module version 5 | # or ./scripts/update_dep.sh module 6 | # e.g. 7 | # ./scripts/update_dep.sh github.com/golang/groupcache 8 | # ./scripts/update_dep.sh github.com/soheilhy/cmux v0.1.5 9 | # 10 | # Updates version of given dependency in all the modules that depend on the mod. 11 | 12 | source ./scripts/test_lib.sh 13 | 14 | mod="$1" 15 | ver="$2" 16 | 17 | function maybe_update_module { 18 | run go mod tidy 19 | 20 | deps=$(go list -f '{{if not .Indirect}}{{if .Version}}{{.Path}},{{.Version}}{{end}}{{end}}' -m all) 21 | if [[ "$deps" == *"${mod}"* ]]; then 22 | if [ -z "${ver}" ]; then 23 | run go get "${mod}" 24 | else 25 | run go get "${mod}@${ver}" 26 | fi 27 | fi 28 | } 29 | 30 | go mod tidy 31 | run_for_modules maybe_update_module 32 | -------------------------------------------------------------------------------- /client/pkg/fileutil/lock.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package fileutil 16 | 17 | import ( 18 | "errors" 19 | "os" 20 | ) 21 | 22 | var ( 23 | ErrLocked = errors.New("fileutil: file already locked") 24 | ) 25 | 26 | type LockedFile struct{ *os.File } 27 | -------------------------------------------------------------------------------- /tests/revive.toml: -------------------------------------------------------------------------------- 1 | ignoreGeneratedHeader = false 2 | severity = "warning" 3 | confidence = 0.8 4 | errorCode = 0 5 | warningCode = 0 6 | 7 | [rule.blank-imports] 8 | [rule.context-as-argument] 9 | [rule.dot-imports] 10 | [rule.error-return] 11 | [rule.error-naming] 12 | [rule.if-return] 13 | [rule.increment-decrement] 14 | [rule.var-declaration] 15 | [rule.package-comments] 16 | [rule.range] 17 | [rule.receiver-naming] 18 | [rule.time-naming] 19 | [rule.indent-error-flow] 20 | [rule.errorf] 21 | 22 | 23 | # TODO: enable following 24 | 25 | # grpcproxy context.WithValue(ctx, rpctypes.TokenFieldNameGRPC, token) 26 | # [rule.context-keys-type] 27 | 28 | # punctuation in error value 29 | # [rule.error-strings] 30 | 31 | # underscore variables 32 | # [rule.var-naming] 33 | 34 | # godoc 35 | # [rule.exported] 36 | 37 | # return unexported type 38 | # [rule.unexported-return] 39 | -------------------------------------------------------------------------------- /tests/e2e/cluster_direct_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build !cluster_proxy 16 | // +build !cluster_proxy 17 | 18 | package e2e 19 | 20 | func newEtcdProcess(cfg *etcdServerProcessConfig) (etcdProcess, error) { 21 | return newEtcdServerProcess(cfg) 22 | } 23 | -------------------------------------------------------------------------------- /server/proxy/httpproxy/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package httpproxy implements etcd httpproxy. The etcd proxy acts as a reverse 16 | // http proxy forwarding client requests to active etcd cluster members, and does 17 | // not participate in consensus. 18 | package httpproxy 19 | -------------------------------------------------------------------------------- /server/verify/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package verify 16 | 17 | // verify package is analyzing persistent state of etcd to find potential 18 | // inconsistencies. 19 | // In particular it covers cross-checking between different aspacts of etcd 20 | // storage like WAL & Backend. 21 | -------------------------------------------------------------------------------- /tests/docker-static-ip/certs/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm -rf /tmp/m1.data /tmp/m2.data /tmp/m3.data 3 | 4 | goreman -f /certs/Procfile start & 5 | 6 | # TODO: remove random sleeps 7 | sleep 7s 8 | 9 | ETCDCTL_API=3 ./etcdctl \ 10 | --cacert=/certs/ca.crt \ 11 | --cert=/certs/server.crt \ 12 | --key=/certs/server.key.insecure \ 13 | --endpoints=https://localhost:2379 \ 14 | endpoint health --cluster 15 | 16 | ETCDCTL_API=3 ./etcdctl \ 17 | --cacert=/certs/ca.crt \ 18 | --cert=/certs/server.crt \ 19 | --key=/certs/server.key.insecure \ 20 | --endpoints=https://localhost:2379,https://localhost:22379,https://localhost:32379 \ 21 | put abc def 22 | 23 | ETCDCTL_API=3 ./etcdctl \ 24 | --cacert=/certs/ca.crt \ 25 | --cert=/certs/server.crt \ 26 | --key=/certs/server.key.insecure \ 27 | --endpoints=https://localhost:2379,https://localhost:22379,https://localhost:32379 \ 28 | get abc 29 | -------------------------------------------------------------------------------- /client/v3/go.mod: -------------------------------------------------------------------------------- 1 | module go.etcd.io/etcd/client/v3 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/dustin/go-humanize v1.0.0 7 | github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 8 | github.com/prometheus/client_golang v1.5.1 9 | go.etcd.io/etcd/api/v3 v3.5.0-alpha.0 10 | go.etcd.io/etcd/client/pkg/v3 v3.5.0-alpha.0 11 | go.uber.org/zap v1.16.1-0.20210329175301-c23abee72d19 12 | google.golang.org/grpc v1.37.0 13 | sigs.k8s.io/yaml v1.2.0 14 | ) 15 | 16 | replace ( 17 | go.etcd.io/etcd/api/v3 => ../../api 18 | go.etcd.io/etcd/client/pkg/v3 => ../pkg 19 | ) 20 | 21 | // Bad imports are sometimes causing attempts to pull that code. 22 | // This makes the error more explicit. 23 | replace ( 24 | go.etcd.io/etcd => ./FORBIDDEN_DEPENDENCY 25 | go.etcd.io/etcd/pkg/v3 => ./FORBIDDEN_DEPENDENCY 26 | go.etcd.io/etcd/v3 => ./FORBIDDEN_DEPENDENCY 27 | go.etcd.io/tests/v3 => ./FORBIDDEN_DEPENDENCY 28 | ) 29 | -------------------------------------------------------------------------------- /tests/integration/embed/embed_proxy_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build cluster_proxy 16 | // +build cluster_proxy 17 | 18 | // The purpose of this (empty) package is too keep following test working: 19 | // # go test -tags=cluster_proxy ./integration/embed 20 | package embed_test 21 | -------------------------------------------------------------------------------- /tools/etcd-dump-metrics/install_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build windows 16 | // +build windows 17 | 18 | package main 19 | 20 | import "errors" 21 | 22 | func install(ver, dir string) (string, error) { 23 | return "", errors.New("windows install is not supported yet") 24 | } 25 | -------------------------------------------------------------------------------- /tests/functional/cmd/etcd-runner/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // etcd-runner is a program for testing etcd clientv3 features 16 | // against a fault injected cluster. 17 | package main 18 | 19 | import "go.etcd.io/etcd/tests/v3/functional/runner" 20 | 21 | func main() { 22 | runner.Start() 23 | } 24 | -------------------------------------------------------------------------------- /tools/benchmark/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "os" 20 | 21 | "go.etcd.io/etcd/v3/tools/benchmark/cmd" 22 | ) 23 | 24 | func main() { 25 | if err := cmd.RootCmd.Execute(); err != nil { 26 | fmt.Fprintln(os.Stderr, err) 27 | os.Exit(-1) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /scripts/build-release.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Build all release binaries and images to directory ./release. 4 | # Run from repository root. 5 | # 6 | set -e 7 | 8 | source ./scripts/test_lib.sh 9 | 10 | VERSION=$1 11 | if [ -z "${VERSION}" ]; then 12 | echo "Usage: ${0} VERSION" >> /dev/stderr 13 | exit 255 14 | fi 15 | 16 | if ! command -v docker >/dev/null; then 17 | echo "cannot find docker" 18 | exit 1 19 | fi 20 | 21 | ETCD_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. 22 | 23 | pushd "${ETCD_ROOT}" >/dev/null 24 | log_callout "Building etcd binary..." 25 | ./scripts/build-binary "${VERSION}" 26 | 27 | for TARGET_ARCH in "amd64" "arm64" "ppc64le" "s390x"; do 28 | log_callout "Building ${TARGET_ARCH} docker image..." 29 | GOOS=linux GOARCH=${TARGET_ARCH} BINARYDIR=release/etcd-${VERSION}-linux-${TARGET_ARCH} BUILDDIR=release ./scripts/build-docker "${VERSION}" 30 | done 31 | popd >/dev/null 32 | -------------------------------------------------------------------------------- /server/mvcc/backend/config_default.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build !linux && !windows 16 | // +build !linux,!windows 17 | 18 | package backend 19 | 20 | import bolt "go.etcd.io/bbolt" 21 | 22 | var boltOpenOptions *bolt.Options 23 | 24 | func (bcfg *BackendConfig) mmapSize() int { return int(bcfg.MmapSize) } 25 | -------------------------------------------------------------------------------- /.github/workflows/grpcproxy.yaml: -------------------------------------------------------------------------------- 1 | name: grpcProxy-tests 2 | on: [push, pull_request] 3 | jobs: 4 | test: 5 | runs-on: ubuntu-latest 6 | strategy: 7 | fail-fast: true 8 | matrix: 9 | target: 10 | - linux-amd64-grpcproxy 11 | steps: 12 | - uses: actions/checkout@v2 13 | - uses: actions/setup-go@v2 14 | with: 15 | go-version: "^1.16" 16 | - run: date 17 | - env: 18 | TARGET: ${{ matrix.target }} 19 | run: | 20 | echo "${TARGET}" 21 | case "${TARGET}" in 22 | linux-amd64-grpcproxy) 23 | PASSES='build grpcproxy' CPU='4' COVER='false' RACE='true' ./test.sh 2>&1 | tee test.log 24 | ! egrep "(--- FAIL:|DATA RACE|panic: test timed out|appears to have leaked)" -B50 -A10 test.log 25 | ;; 26 | *) 27 | echo "Failed to find target" 28 | exit 1 29 | ;; 30 | esac 31 | -------------------------------------------------------------------------------- /etcdutl/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // etcdutl is a command line application that operates on etcd files. 16 | package main 17 | 18 | import ( 19 | "go.etcd.io/etcd/pkg/v3/cobrautl" 20 | ) 21 | 22 | func main() { 23 | if err := Start(); err != nil { 24 | cobrautl.ExitWithError(cobrautl.ExitError, err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Procfile.learner: -------------------------------------------------------------------------------- 1 | # Use goreman to run `go get github.com/mattn/goreman` 2 | 3 | # 1. Start the cluster using Procfile 4 | # 2. Add learner node to the cluster 5 | # % etcdctl member add infra4 --peer-urls="http://127.0.0.1:42380" --learner=true 6 | 7 | # 3. Start learner node with goreman 8 | # Change the path of bin/etcd if etcd is located elsewhere 9 | etcd4: bin/etcd --name infra4 --listen-client-urls http://127.0.0.1:42379 --advertise-client-urls http://127.0.0.1:42379 --listen-peer-urls http://127.0.0.1:42380 --initial-advertise-peer-urls http://127.0.0.1:42380 --initial-cluster-token etcd-cluster-1 --initial-cluster 'infra4=http://127.0.0.1:42380,infra1=http://127.0.0.1:12380,infra2=http://127.0.0.1:22380,infra3=http://127.0.0.1:32380' --initial-cluster-state existing --enable-pprof --logger=zap --log-outputs=stderr 10 | 11 | # 4. The learner node can be promoted to voting member by the command 12 | # % etcdctl member promote 13 | -------------------------------------------------------------------------------- /server/embed/config_logging_journal_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build windows 16 | // +build windows 17 | 18 | package embed 19 | 20 | import ( 21 | "os" 22 | 23 | "go.uber.org/zap/zapcore" 24 | ) 25 | 26 | func getJournalWriteSyncer() (zapcore.WriteSyncer, error) { 27 | return zapcore.AddSync(os.Stderr), nil 28 | } 29 | -------------------------------------------------------------------------------- /tests/functional/scripts/genproto.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | if ! [[ "$0" =~ "scripts/genproto.sh" ]]; then 5 | echo "must be run from repository root" 6 | exit 255 7 | fi 8 | 9 | # protoc version should be the same as one in main etcd scripts. 10 | if [[ $(protoc --version | cut -f2 -d' ') != "3.14.0" ]]; then 11 | echo "could not find protoc 3.14.0, is it installed + in PATH?" 12 | exit 255 13 | fi 14 | 15 | echo "Installing gogo/protobuf..." 16 | GOGOPROTO_ROOT="$GOPATH/src/github.com/gogo/protobuf" 17 | rm -rf $GOGOPROTO_ROOT 18 | go get -v github.com/gogo/protobuf/{proto,protoc-gen-gogo,gogoproto,protoc-gen-gofast} 19 | go get -v golang.org/x/tools/cmd/goimports 20 | pushd "${GOGOPROTO_ROOT}" 21 | git reset --hard HEAD 22 | make install 23 | popd 24 | 25 | printf "Generating agent\n" 26 | protoc --gofast_out=plugins=grpc:. \ 27 | --proto_path=$GOPATH/src:$GOPATH/src/github.com/gogo/protobuf/protobuf:. \ 28 | rpcpb/*.proto; 29 | -------------------------------------------------------------------------------- /client/pkg/types/slice.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | // Uint64Slice implements sort interface 18 | type Uint64Slice []uint64 19 | 20 | func (p Uint64Slice) Len() int { return len(p) } 21 | func (p Uint64Slice) Less(i, j int) bool { return p[i] < p[j] } 22 | func (p Uint64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } 23 | -------------------------------------------------------------------------------- /server/embed/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package embed 16 | 17 | import ( 18 | "path/filepath" 19 | 20 | "go.etcd.io/etcd/server/v3/wal" 21 | ) 22 | 23 | func isMemberInitialized(cfg *Config) bool { 24 | waldir := cfg.WalDir 25 | if waldir == "" { 26 | waldir = filepath.Join(cfg.Dir, "member", "wal") 27 | } 28 | return wal.Exist(waldir) 29 | } 30 | -------------------------------------------------------------------------------- /ROADMAP.md: -------------------------------------------------------------------------------- 1 | # etcd roadmap 2 | 3 | **work in progress** 4 | 5 | This document defines a high level roadmap for etcd development. 6 | 7 | The dates below should not be considered authoritative, but rather indicative of the projected timeline of the project. The [milestones defined in GitHub](https://github.com/etcd-io/etcd/milestones) represent the most up-to-date and issue-for-issue plans. 8 | 9 | etcd 3.3 is our current stable branch. The roadmap below outlines new features that will be added to etcd, and while subject to change, define what future stable will look like. 10 | 11 | ### etcd 3.4 (2019) 12 | 13 | - Stabilization of 3.3 experimental features 14 | - Support/document downgrade 15 | - Snapshot restore as Go library 16 | - Improved client balancer with new gRPC balancer interface 17 | - Improve single-client put performance 18 | - Improve large response handling 19 | - Improve test coverage 20 | - Decrease test runtime 21 | - Migrate to Go module for dependency management 22 | -------------------------------------------------------------------------------- /tests/e2e/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /* 16 | Package e2e implements tests built upon etcd binaries, and focus on 17 | end-to-end testing. 18 | 19 | Features/goals of the end-to-end tests: 20 | 1. test command-line parsing and arguments. 21 | 2. test user-facing command-line API. 22 | 3. launch full processes and check for expected outputs. 23 | */ 24 | package e2e 25 | -------------------------------------------------------------------------------- /tools/local-tester/README.md: -------------------------------------------------------------------------------- 1 | # etcd local-tester 2 | 3 | The etcd local-tester runs a fault injected cluster using local processes. It sets up an etcd cluster with unreliable network bridges on its peer and client interfaces. The cluster runs with a constant stream of `Put` requests to simulate client usage. A fault injection script periodically kills cluster members and disrupts bridge connectivity. 4 | 5 | # Requirements 6 | 7 | local-tester depends on `goreman` to manage its processes and `bash` to run fault injection. 8 | 9 | # Building 10 | 11 | local-tester needs `etcd`, `benchmark`, and `bridge` binaries. To build these binaries, run the following from the etcd repository root: 12 | 13 | ```sh 14 | ./build.sh 15 | pushd tools/benchmark/ && go build && popd 16 | pushd tools/local-tester/bridge && go build && popd 17 | ``` 18 | 19 | # Running 20 | 21 | The fault injected cluster is invoked with `goreman`: 22 | 23 | ```sh 24 | goreman -f tools/local-tester/Procfile start 25 | ``` 26 | -------------------------------------------------------------------------------- /tools/mod/libs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // +build libs 16 | 17 | // This file implements that pattern: 18 | // https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module 19 | // for etcd. Thanks to this file 'go mod tidy' does not removes dependencies. 20 | 21 | package libs 22 | 23 | import ( 24 | _ "github.com/gogo/protobuf/proto" 25 | ) 26 | -------------------------------------------------------------------------------- /pkg/stringutil/rand_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package stringutil 16 | 17 | import ( 18 | "fmt" 19 | "testing" 20 | ) 21 | 22 | func TestUniqueStrings(t *testing.T) { 23 | ss := UniqueStrings(10, 50) 24 | for i := 1; i < len(ss); i++ { 25 | if ss[i-1] == ss[i] { 26 | t.Fatalf("ss[i-1] %q == ss[i] %q", ss[i-1], ss[i]) 27 | } 28 | } 29 | fmt.Println(ss) 30 | } 31 | -------------------------------------------------------------------------------- /server/datadir/datadir_test.go: -------------------------------------------------------------------------------- 1 | package datadir_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | "go.etcd.io/etcd/server/v3/datadir" 8 | ) 9 | 10 | func TestToBackendFileName(t *testing.T) { 11 | result := datadir.ToBackendFileName("/dir/data-dir") 12 | assert.Equal(t, "/dir/data-dir/member/snap/db", result) 13 | } 14 | 15 | func TestToMemberDir(t *testing.T) { 16 | result := datadir.ToMemberDir("/dir/data-dir") 17 | assert.Equal(t, "/dir/data-dir/member", result) 18 | } 19 | 20 | func TestToSnapDir(t *testing.T) { 21 | result := datadir.ToSnapDir("/dir/data-dir") 22 | assert.Equal(t, "/dir/data-dir/member/snap", result) 23 | } 24 | 25 | func TestToWalDir(t *testing.T) { 26 | result := datadir.ToWalDir("/dir/data-dir") 27 | assert.Equal(t, "/dir/data-dir/member/wal", result) 28 | } 29 | 30 | func TestToWalDirSlash(t *testing.T) { 31 | result := datadir.ToWalDir("/dir/data-dir/") 32 | assert.Equal(t, "/dir/data-dir/member/wal", result) 33 | } 34 | -------------------------------------------------------------------------------- /contrib/mixin/README.md: -------------------------------------------------------------------------------- 1 | # Prometheus Monitoring Mixin for etcd 2 | 3 | > NOTE: This project is *alpha* stage. Flags, configuration, behaviour and design may change significantly in following releases. 4 | 5 | A set of customisable Prometheus alerts for etcd. 6 | 7 | Instructions for use are the same as the [kubernetes-mixin](https://github.com/kubernetes-monitoring/kubernetes-mixin). 8 | 9 | ## Background 10 | 11 | * For more information about monitoring mixins, see this [design doc](https://docs.google.com/document/d/1A9xvzwqnFVSOZ5fD3blKODXfsat5fg6ZhnKu9LK3lB4/edit#). 12 | 13 | ## Testing alerts 14 | 15 | Make sure to have [jsonnet](https://jsonnet.org/) and [gojsontoyaml](https://github.com/brancz/gojsontoyaml) installed. 16 | 17 | First compile the mixin to a YAML file, which the promtool will read: 18 | ``` 19 | jsonnet -e '(import "mixin.libsonnet").prometheusAlerts' | gojsontoyaml > mixin.yaml 20 | ``` 21 | 22 | Then run the unit test: 23 | ``` 24 | promtool test rules test.yaml 25 | ``` 26 | -------------------------------------------------------------------------------- /client/pkg/fileutil/preallocate_unsupported.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build !linux && !darwin 16 | // +build !linux,!darwin 17 | 18 | package fileutil 19 | 20 | import "os" 21 | 22 | func preallocExtend(f *os.File, sizeInBytes int64) error { 23 | return preallocExtendTrunc(f, sizeInBytes) 24 | } 25 | 26 | func preallocFixed(f *os.File, sizeInBytes int64) error { return nil } 27 | -------------------------------------------------------------------------------- /etcdutl/snapshot/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package snapshot 16 | 17 | import ( 18 | "encoding/binary" 19 | ) 20 | 21 | type revision struct { 22 | main int64 23 | sub int64 24 | } 25 | 26 | func bytesToRev(bytes []byte) revision { 27 | return revision{ 28 | main: int64(binary.BigEndian.Uint64(bytes[0:8])), 29 | sub: int64(binary.BigEndian.Uint64(bytes[9:])), 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /hack/insta-discovery/Procfile: -------------------------------------------------------------------------------- 1 | # Use goreman to run `go get github.com/mattn/goreman` 2 | # One of the four etcd members falls back to a proxy 3 | etcd1: ../../bin/etcd --name infra1 --listen-client-urls http://127.0.0.1:2379 --advertise-client-urls http://127.0.0.1:2379 --listen-peer-urls http://127.0.0.1:2380 --initial-advertise-peer-urls http://127.0.0.1:2380 4 | etcd2: ../../bin/etcd --name infra2 --listen-client-urls http://127.0.0.1:12379 --advertise-client-urls http://127.0.0.1:12379 --listen-peer-urls http://127.0.0.1:12380 --initial-advertise-peer-urls http://127.0.0.1:12380 5 | etcd3: ../../bin/etcd --name infra3 --listen-client-urls http://127.0.0.1:22379 --advertise-client-urls http://127.0.0.1:22379 --listen-peer-urls http://127.0.0.1:22380 --initial-advertise-peer-urls http://127.0.0.1:22380 6 | etcd4: ../../bin/etcd --name infra4 --listen-client-urls http://127.0.0.1:32379 --advertise-client-urls http://127.0.0.1:32379 --listen-peer-urls http://127.0.0.1:32380 --initial-advertise-peer-urls http://127.0.0.1:32380 7 | -------------------------------------------------------------------------------- /api/authpb/auth.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package authpb; 3 | 4 | import "gogoproto/gogo.proto"; 5 | 6 | option (gogoproto.marshaler_all) = true; 7 | option (gogoproto.sizer_all) = true; 8 | option (gogoproto.unmarshaler_all) = true; 9 | option (gogoproto.goproto_getters_all) = false; 10 | option (gogoproto.goproto_enum_prefix_all) = false; 11 | 12 | message UserAddOptions { 13 | bool no_password = 1; 14 | }; 15 | 16 | // User is a single entry in the bucket authUsers 17 | message User { 18 | bytes name = 1; 19 | bytes password = 2; 20 | repeated string roles = 3; 21 | UserAddOptions options = 4; 22 | } 23 | 24 | // Permission is a single entity 25 | message Permission { 26 | enum Type { 27 | READ = 0; 28 | WRITE = 1; 29 | READWRITE = 2; 30 | } 31 | Type permType = 1; 32 | 33 | bytes key = 2; 34 | bytes range_end = 3; 35 | } 36 | 37 | // Role is a single entry in the bucket authRoles 38 | message Role { 39 | bytes name = 1; 40 | 41 | repeated Permission keyPermission = 2; 42 | } 43 | -------------------------------------------------------------------------------- /client/pkg/fileutil/dir_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build !windows 16 | // +build !windows 17 | 18 | package fileutil 19 | 20 | import "os" 21 | 22 | const ( 23 | // PrivateDirMode grants owner to make/remove files inside the directory. 24 | PrivateDirMode = 0700 25 | ) 26 | 27 | // OpenDir opens a directory for syncing. 28 | func OpenDir(path string) (*os.File, error) { return os.Open(path) } 29 | -------------------------------------------------------------------------------- /client/pkg/types/slice_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "reflect" 19 | "sort" 20 | "testing" 21 | ) 22 | 23 | func TestUint64Slice(t *testing.T) { 24 | g := Uint64Slice{10, 500, 5, 1, 100, 25} 25 | w := Uint64Slice{1, 5, 10, 25, 100, 500} 26 | sort.Sort(g) 27 | if !reflect.DeepEqual(g, w) { 28 | t.Errorf("slice after sort = %#v, want %#v", g, w) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /pkg/runtime/fds_other.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build !linux 16 | // +build !linux 17 | 18 | package runtime 19 | 20 | import ( 21 | "fmt" 22 | "runtime" 23 | ) 24 | 25 | func FDLimit() (uint64, error) { 26 | return 0, fmt.Errorf("cannot get FDLimit on %s", runtime.GOOS) 27 | } 28 | 29 | func FDUsage() (uint64, error) { 30 | return 0, fmt.Errorf("cannot get FDUsage on %s", runtime.GOOS) 31 | } 32 | -------------------------------------------------------------------------------- /tests/docker-dns-srv/certs-wildcard/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | rm -rf /tmp/m1.data /tmp/m2.data /tmp/m3.data 3 | 4 | /etc/init.d/bind9 start 5 | 6 | # get rid of hosts so go lookup won't resolve 127.0.0.1 to localhost 7 | cat /dev/null >/etc/hosts 8 | 9 | goreman -f /certs-wildcard/Procfile start & 10 | 11 | # TODO: remove random sleeps 12 | sleep 7s 13 | 14 | ETCDCTL_API=3 ./etcdctl \ 15 | --cacert=/certs-wildcard/ca.crt \ 16 | --cert=/certs-wildcard/server.crt \ 17 | --key=/certs-wildcard/server.key.insecure \ 18 | --discovery-srv etcd.local \ 19 | endpoint health --cluster 20 | 21 | ETCDCTL_API=3 ./etcdctl \ 22 | --cacert=/certs-wildcard/ca.crt \ 23 | --cert=/certs-wildcard/server.crt \ 24 | --key=/certs-wildcard/server.key.insecure \ 25 | --discovery-srv etcd.local \ 26 | put abc def 27 | 28 | ETCDCTL_API=3 ./etcdctl \ 29 | --cacert=/certs-wildcard/ca.crt \ 30 | --cert=/certs-wildcard/server.crt \ 31 | --key=/certs-wildcard/server.key.insecure \ 32 | --discovery-srv etcd.local \ 33 | get abc 34 | -------------------------------------------------------------------------------- /server/etcdserver/api/rafthttp/coder.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package rafthttp 16 | 17 | import "go.etcd.io/etcd/raft/v3/raftpb" 18 | 19 | type encoder interface { 20 | // encode encodes the given message to an output stream. 21 | encode(m *raftpb.Message) error 22 | } 23 | 24 | type decoder interface { 25 | // decode decodes the message from an input stream. 26 | decode() (raftpb.Message, error) 27 | } 28 | -------------------------------------------------------------------------------- /etcdutl/etcdutl/printer_simple.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package etcdutl 16 | 17 | import ( 18 | "fmt" 19 | "strings" 20 | 21 | "go.etcd.io/etcd/etcdutl/v3/snapshot" 22 | ) 23 | 24 | type simplePrinter struct { 25 | } 26 | 27 | func (s *simplePrinter) DBStatus(ds snapshot.Status) { 28 | _, rows := makeDBStatusTable(ds) 29 | for _, row := range rows { 30 | fmt.Println(strings.Join(row, ", ")) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /client/pkg/logutil/log_level.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package logutil 16 | 17 | import ( 18 | "go.uber.org/zap/zapcore" 19 | ) 20 | 21 | var DefaultLogLevel = "info" 22 | 23 | // ConvertToZapLevel converts log level string to zapcore.Level. 24 | func ConvertToZapLevel(lvl string) zapcore.Level { 25 | var level zapcore.Level 26 | if err := level.Set(lvl); err != nil { 27 | panic(err) 28 | } 29 | return level 30 | } 31 | -------------------------------------------------------------------------------- /server/mvcc/backend/config_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build windows 16 | // +build windows 17 | 18 | package backend 19 | 20 | import bolt "go.etcd.io/bbolt" 21 | 22 | var boltOpenOptions *bolt.Options = nil 23 | 24 | // setting mmap size != 0 on windows will allocate the entire 25 | // mmap size for the file, instead of growing it. So, force 0. 26 | 27 | func (bcfg *BackendConfig) mmapSize() int { return 0 } 28 | -------------------------------------------------------------------------------- /client/v3/sort.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package clientv3 16 | 17 | type SortTarget int 18 | type SortOrder int 19 | 20 | const ( 21 | SortNone SortOrder = iota 22 | SortAscend 23 | SortDescend 24 | ) 25 | 26 | const ( 27 | SortByKey SortTarget = iota 28 | SortByVersion 29 | SortByCreateRevision 30 | SortByModRevision 31 | SortByValue 32 | ) 33 | 34 | type SortOption struct { 35 | Target SortTarget 36 | Order SortOrder 37 | } 38 | -------------------------------------------------------------------------------- /client/pkg/pathutil/path.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package pathutil implements utility functions for handling slash-separated 6 | // paths. 7 | package pathutil 8 | 9 | import "path" 10 | 11 | // CanonicalURLPath returns the canonical url path for p, which follows the rules: 12 | // 1. the path always starts with "/" 13 | // 2. replace multiple slashes with a single slash 14 | // 3. replace each '.' '..' path name element with equivalent one 15 | // 4. keep the trailing slash 16 | // The function is borrowed from stdlib http.cleanPath in server.go. 17 | func CanonicalURLPath(p string) string { 18 | if p == "" { 19 | return "/" 20 | } 21 | if p[0] != '/' { 22 | p = "/" + p 23 | } 24 | np := path.Clean(p) 25 | // path.Clean removes trailing slash except for root, 26 | // put the trailing slash back if necessary. 27 | if p[len(p)-1] == '/' && np != "/" { 28 | np += "/" 29 | } 30 | return np 31 | } 32 | -------------------------------------------------------------------------------- /etcdutl/etcdutl/printer_fields.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package etcdutl 16 | 17 | import ( 18 | "fmt" 19 | 20 | "go.etcd.io/etcd/etcdutl/v3/snapshot" 21 | ) 22 | 23 | type fieldsPrinter struct{ printer } 24 | 25 | func (p *fieldsPrinter) DBStatus(r snapshot.Status) { 26 | fmt.Println(`"Hash" :`, r.Hash) 27 | fmt.Println(`"Revision" :`, r.Revision) 28 | fmt.Println(`"Keys" :`, r.TotalKey) 29 | fmt.Println(`"Size" :`, r.TotalSize) 30 | } 31 | -------------------------------------------------------------------------------- /client/v3/compact_op_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package clientv3 16 | 17 | import ( 18 | "reflect" 19 | "testing" 20 | 21 | "go.etcd.io/etcd/api/v3/etcdserverpb" 22 | ) 23 | 24 | func TestCompactOp(t *testing.T) { 25 | req1 := OpCompact(100, WithCompactPhysical()).toRequest() 26 | req2 := &etcdserverpb.CompactionRequest{Revision: 100, Physical: true} 27 | if !reflect.DeepEqual(req1, req2) { 28 | t.Fatalf("expected %+v, got %+v", req2, req1) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tests/integration/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /* 16 | Package integration implements tests built upon embedded etcd, and focus on 17 | etcd correctness. 18 | 19 | Features/goals of the integration tests: 20 | 1. test the whole code base except command-line parsing. 21 | 2. check internal data, including raft, store and etc. 22 | 3. based on goroutines, which is faster than process. 23 | 4. mainly tests user behavior and user-facing API. 24 | */ 25 | package integration 26 | -------------------------------------------------------------------------------- /tests/docker-static-ip/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | 3 | RUN rm /bin/sh && ln -s /bin/bash /bin/sh 4 | RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections 5 | 6 | RUN apt-get -y update \ 7 | && apt-get -y install \ 8 | build-essential \ 9 | gcc \ 10 | apt-utils \ 11 | pkg-config \ 12 | software-properties-common \ 13 | apt-transport-https \ 14 | libssl-dev \ 15 | sudo \ 16 | bash \ 17 | curl \ 18 | tar \ 19 | git \ 20 | netcat \ 21 | bind9 \ 22 | dnsutils \ 23 | && apt-get -y update \ 24 | && apt-get -y upgrade \ 25 | && apt-get -y autoremove \ 26 | && apt-get -y autoclean 27 | 28 | ENV GOROOT /usr/local/go 29 | ENV GOPATH /go 30 | ENV PATH ${GOPATH}/bin:${GOROOT}/bin:${PATH} 31 | ENV GO_VERSION REPLACE_ME_GO_VERSION 32 | ENV GO_DOWNLOAD_URL https://storage.googleapis.com/golang 33 | RUN rm -rf ${GOROOT} \ 34 | && curl -s ${GO_DOWNLOAD_URL}/go${GO_VERSION}.linux-amd64.tar.gz | tar -v -C /usr/local/ -xz \ 35 | && mkdir -p ${GOPATH}/src ${GOPATH}/bin \ 36 | && go version \ 37 | && go get -v -u github.com/mattn/goreman 38 | -------------------------------------------------------------------------------- /tests/functional/tester/checker_no_check.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package tester 16 | 17 | import "go.etcd.io/etcd/tests/v3/functional/rpcpb" 18 | 19 | type noCheck struct{} 20 | 21 | func newNoChecker() Checker { return &noCheck{} } 22 | func (nc *noCheck) Type() rpcpb.Checker { return rpcpb.Checker_NO_CHECK } 23 | func (nc *noCheck) EtcdClientEndpoints() []string { return nil } 24 | func (nc *noCheck) Check() error { return nil } 25 | -------------------------------------------------------------------------------- /pkg/ioutil/reader_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package ioutil 16 | 17 | import ( 18 | "bytes" 19 | "testing" 20 | ) 21 | 22 | func TestLimitedBufferReaderRead(t *testing.T) { 23 | buf := bytes.NewBuffer(make([]byte, 10)) 24 | ln := 1 25 | lr := NewLimitedBufferReader(buf, ln) 26 | n, err := lr.Read(make([]byte, 10)) 27 | if err != nil { 28 | t.Fatalf("unexpected read error: %v", err) 29 | } 30 | if n != ln { 31 | t.Errorf("len(data read) = %d, want %d", n, ln) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /server/etcdserver/api/v2store/event_queue.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package v2store 16 | 17 | type eventQueue struct { 18 | Events []*Event 19 | Size int 20 | Front int 21 | Back int 22 | Capacity int 23 | } 24 | 25 | func (eq *eventQueue) insert(e *Event) { 26 | eq.Events[eq.Back] = e 27 | eq.Back = (eq.Back + 1) % eq.Capacity 28 | 29 | if eq.Size == eq.Capacity { //dequeue 30 | eq.Front = (eq.Front + 1) % eq.Capacity 31 | } else { 32 | eq.Size++ 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /client/pkg/fileutil/sync.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build !linux && !darwin 16 | // +build !linux,!darwin 17 | 18 | package fileutil 19 | 20 | import "os" 21 | 22 | // Fsync is a wrapper around file.Sync(). Special handling is needed on darwin platform. 23 | func Fsync(f *os.File) error { 24 | return f.Sync() 25 | } 26 | 27 | // Fdatasync is a wrapper around file.Sync(). Special handling is needed on linux platform. 28 | func Fdatasync(f *os.File) error { 29 | return f.Sync() 30 | } 31 | -------------------------------------------------------------------------------- /tools/rw-heatmaps/README.md: -------------------------------------------------------------------------------- 1 | # etcd/tools/rw-heatmaps 2 | 3 | `etcd/tools/rw-heatmaps` is the mixed read/write performance evaluation tool for etcd clusters. 4 | 5 | ## Execute 6 | 7 | ### Benchmark 8 | To get a mixed read/write performance evaluation result: 9 | ```sh 10 | # run with default configurations and specify the working directory 11 | ./rw-benchmark.sh -w ${WORKING_DIR} 12 | ``` 13 | `rw-benchmark.sh` will automatically use the etcd binary compiled under `etcd/bin/` directory. 14 | 15 | Note: the result csv file will be saved to current working directory. The working directory is where etcd database is saved. The working directory is designed for scenarios where a different mounted disk is preferred. 16 | 17 | ### Plot Graph 18 | To generate a image based on the benchmark result csv file: 19 | ```sh 20 | # to generate a image from one data csv file 21 | ./plot_data.py ${FIRST_CSV_FILE} -t ${IMAGE_TITLE} -o ${OUTPUT_IMAGE_NAME} 22 | 23 | 24 | # to generate a image comparing two data csv files 25 | ./plot_data.py ${FIRST_CSV_FILE} ${SECOND_CSV_FILE} -t ${IMAGE_TITLE} -o ${OUTPUT_IMAGE_NAME} 26 | ``` 27 | -------------------------------------------------------------------------------- /client/pkg/fileutil/lock_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build !windows && !plan9 && !solaris && !linux 16 | // +build !windows,!plan9,!solaris,!linux 17 | 18 | package fileutil 19 | 20 | import ( 21 | "os" 22 | ) 23 | 24 | func TryLockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) { 25 | return flockTryLockFile(path, flag, perm) 26 | } 27 | 28 | func LockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) { 29 | return flockLockFile(path, flag, perm) 30 | } 31 | -------------------------------------------------------------------------------- /etcdutl/etcdutl/common.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package etcdutl 16 | 17 | import ( 18 | "go.etcd.io/etcd/pkg/v3/cobrautl" 19 | "go.uber.org/zap" 20 | "go.uber.org/zap/zapcore" 21 | ) 22 | 23 | func GetLogger() *zap.Logger { 24 | config := zap.NewProductionConfig() 25 | config.Encoding = "console" 26 | config.EncoderConfig.EncodeTime = zapcore.RFC3339TimeEncoder 27 | lg, err := config.Build() 28 | if err != nil { 29 | cobrautl.ExitWithError(cobrautl.ExitBadArgs, err) 30 | } 31 | return lg 32 | } 33 | -------------------------------------------------------------------------------- /tests/functional/tester/checker.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package tester 16 | 17 | import "go.etcd.io/etcd/tests/v3/functional/rpcpb" 18 | 19 | // Checker checks cluster consistency. 20 | type Checker interface { 21 | // Type returns the checker type. 22 | Type() rpcpb.Checker 23 | // EtcdClientEndpoints returns the client endpoints of 24 | // all checker target nodes.. 25 | EtcdClientEndpoints() []string 26 | // Check returns an error if the system fails a consistency check. 27 | Check() error 28 | } 29 | -------------------------------------------------------------------------------- /pkg/osutil/signal_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build linux && !cov 16 | // +build linux,!cov 17 | 18 | package osutil 19 | 20 | import ( 21 | "syscall" 22 | "unsafe" 23 | ) 24 | 25 | // dflSignal sets the given signal to SIG_DFL 26 | func dflSignal(sig syscall.Signal) { 27 | // clearing out the sigact sets the signal to SIG_DFL 28 | var sigactBuf [32]uint64 29 | ptr := unsafe.Pointer(&sigactBuf) 30 | syscall.Syscall6(uintptr(syscall.SYS_RT_SIGACTION), uintptr(sig), uintptr(ptr), 0, 8, 0, 0) 31 | } 32 | -------------------------------------------------------------------------------- /raft/confchange/testdata/simple_idempotency.txt: -------------------------------------------------------------------------------- 1 | simple 2 | v1 3 | ---- 4 | voters=(1) 5 | 1: StateProbe match=0 next=0 6 | 7 | simple 8 | v1 9 | ---- 10 | voters=(1) 11 | 1: StateProbe match=0 next=0 12 | 13 | simple 14 | v2 15 | ---- 16 | voters=(1 2) 17 | 1: StateProbe match=0 next=0 18 | 2: StateProbe match=0 next=2 19 | 20 | simple 21 | l1 22 | ---- 23 | voters=(2) learners=(1) 24 | 1: StateProbe match=0 next=0 learner 25 | 2: StateProbe match=0 next=2 26 | 27 | simple 28 | l1 29 | ---- 30 | voters=(2) learners=(1) 31 | 1: StateProbe match=0 next=0 learner 32 | 2: StateProbe match=0 next=2 33 | 34 | simple 35 | r1 36 | ---- 37 | voters=(2) 38 | 2: StateProbe match=0 next=2 39 | 40 | simple 41 | r1 42 | ---- 43 | voters=(2) 44 | 2: StateProbe match=0 next=2 45 | 46 | simple 47 | v3 48 | ---- 49 | voters=(2 3) 50 | 2: StateProbe match=0 next=2 51 | 3: StateProbe match=0 next=7 52 | 53 | simple 54 | r3 55 | ---- 56 | voters=(2) 57 | 2: StateProbe match=0 next=2 58 | 59 | simple 60 | r3 61 | ---- 62 | voters=(2) 63 | 2: StateProbe match=0 next=2 64 | 65 | simple 66 | r4 67 | ---- 68 | voters=(2) 69 | 2: StateProbe match=0 next=2 70 | -------------------------------------------------------------------------------- /raft/rafttest/interaction_env_handler_campaign.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package rafttest 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/cockroachdb/datadriven" 21 | ) 22 | 23 | func (env *InteractionEnv) handleCampaign(t *testing.T, d datadriven.TestData) error { 24 | idx := firstAsNodeIdx(t, d) 25 | return env.Campaign(t, idx) 26 | } 27 | 28 | // Campaign the node at the given index. 29 | func (env *InteractionEnv) Campaign(t *testing.T, idx int) error { 30 | return env.Nodes[idx].Campaign() 31 | } 32 | -------------------------------------------------------------------------------- /dummy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main_test 16 | 17 | // MainTest package makes sure these packages stay as dependencies of the root 18 | // module (e.g. for sake of 'bom' generation). 19 | // Thanks to this 'go mod tidy' is not removing that dependencies from go.mod. 20 | import ( 21 | _ "go.etcd.io/etcd/client/v2" // keep 22 | _ "go.etcd.io/etcd/etcdctl/v3/ctlv3/command" // keep 23 | _ "go.etcd.io/etcd/etcdutl/v3/etcdutl" // keep 24 | _ "go.etcd.io/etcd/tests/v3/integration" // keep 25 | ) 26 | -------------------------------------------------------------------------------- /pkg/netutil/routes_linux_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build linux 16 | // +build linux 17 | 18 | package netutil 19 | 20 | import "testing" 21 | 22 | func TestGetDefaultInterface(t *testing.T) { 23 | ifc, err := GetDefaultInterfaces() 24 | if err != nil { 25 | t.Fatal(err) 26 | } 27 | t.Logf("default network interfaces: %+v\n", ifc) 28 | } 29 | 30 | func TestGetDefaultHost(t *testing.T) { 31 | ip, err := GetDefaultHost() 32 | if err != nil { 33 | t.Fatal(err) 34 | } 35 | t.Logf("default ip: %v", ip) 36 | } 37 | -------------------------------------------------------------------------------- /pkg/osutil/interrupt_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | //go:build windows 16 | // +build windows 17 | 18 | package osutil 19 | 20 | import ( 21 | "os" 22 | 23 | "go.uber.org/zap" 24 | ) 25 | 26 | type InterruptHandler func() 27 | 28 | // RegisterInterruptHandler is a no-op on windows 29 | func RegisterInterruptHandler(h InterruptHandler) {} 30 | 31 | // HandleInterrupts is a no-op on windows 32 | func HandleInterrupts(*zap.Logger) {} 33 | 34 | // Exit calls os.Exit 35 | func Exit(code int) { 36 | os.Exit(code) 37 | } 38 | -------------------------------------------------------------------------------- /client/v2/cluster_error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package client 16 | 17 | import "fmt" 18 | 19 | type ClusterError struct { 20 | Errors []error 21 | } 22 | 23 | func (ce *ClusterError) Error() string { 24 | s := ErrClusterUnavailable.Error() 25 | for i, e := range ce.Errors { 26 | s += fmt.Sprintf("; error #%d: %s\n", i, e) 27 | } 28 | return s 29 | } 30 | 31 | func (ce *ClusterError) Detail() string { 32 | s := "" 33 | for i, e := range ce.Errors { 34 | s += fmt.Sprintf("error #%d: %s\n", i, e) 35 | } 36 | return s 37 | } 38 | -------------------------------------------------------------------------------- /MAINTAINERS: -------------------------------------------------------------------------------- 1 | # The official list of maintainers and reviewers for the project maintenance. 2 | # 3 | # Refer to the GOVERNANCE.md for description of the roles. 4 | # 5 | # Names should be added to this file like so: 6 | # Individual's name (@GITHUB_HANDLE) pkg:* 7 | # Individual's name (@GITHUB_HANDLE) pkg:* 8 | # 9 | # Please keep the list sorted. 10 | 11 | # MAINTAINERS 12 | Brandon Philips (@philips) pkg:* 13 | Gyuho Lee (@gyuho) pkg:* 14 | Hitoshi Mitake (@mitake) pkg:* 15 | Jingyi Hu (@jingyih) pkg:* 16 | Joe Betz (@jpbetz) pkg:* 17 | Piotr Tabor (@ptabor) pkg:* 18 | Sahdev Zala (@spzala) pkg:* 19 | Sam Batschelet (@hexfusion) pkg:* 20 | Wenjia Zhang (@wenjiaswe) pkg:* 21 | Xiang Li (@xiang90) pkg:* 22 | 23 | Ben Darnell (@bdarnell) pkg:go.etcd.io/etcd/raft 24 | Tobias Grieger (@tbg) pkg:go.etcd.io/etcd/raft 25 | -------------------------------------------------------------------------------- /scripts/fix.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Top level problems with modules can lead to test_lib being not functional 6 | go mod tidy 7 | 8 | source ./scripts/test_lib.sh 9 | source ./scripts/updatebom.sh 10 | 11 | # To fix according to newer version of go: 12 | # go get golang.org/dl/gotip 13 | # gotip download 14 | # GO_CMD="gotip" 15 | GO_CMD="go" 16 | 17 | function mod_tidy_fix { 18 | run rm ./go.sum 19 | run ${GO_CMD} mod tidy || return 2 20 | } 21 | 22 | function bash_ws_fix { 23 | TAB=$'\t' 24 | 25 | log_callout "Fixing whitespaces in the bash scripts" 26 | # Makes sure all bash scripts do use ' ' (double space) for indention. 27 | log_cmd "find ./ -name '*.sh' -print0 | xargs -0 sed -i.bak 's|${TAB}| |g'" 28 | find ./ -name '*.sh' -print0 | xargs -0 sed -i.bak "s|${TAB}| |g" 29 | find ./ -name '*.sh.bak' -print0 | xargs -0 rm 30 | } 31 | 32 | log_callout -e "\\nFixing etcd code for you...\\n" 33 | 34 | run_for_modules mod_tidy_fix || exit 2 35 | run_for_modules run ${GO_CMD} fmt || exit 2 36 | run_for_module tests bom_fix || exit 2 37 | bash_ws_fix || exit 2 38 | 39 | log_success -e "\\nSUCCESS: etcd code is fixed :)" 40 | --------------------------------------------------------------------------------