├── .devcontainer └── devcontainer.json ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.yml │ ├── config.yml │ ├── feature-request.yml │ └── test-flake.yml ├── OWNERS ├── PULL_REQUEST_TEMPLATE.md ├── SECURITY.md ├── dependabot.yml └── workflows │ ├── OWNERS │ ├── antithesis-test.yml │ ├── codeql-analysis.yml │ ├── gh-workflow-approve.yaml │ ├── measure-testgrid-flakiness.yaml │ ├── scorecards.yml │ ├── stale.yaml │ └── verify-released-assets.yaml ├── .gitignore ├── .go-version ├── .header ├── ADOPTERS.md ├── CHANGELOG ├── CHANGELOG-2.3.md ├── CHANGELOG-3.0.md ├── CHANGELOG-3.1.md ├── CHANGELOG-3.2.md ├── CHANGELOG-3.3.md ├── CHANGELOG-3.4.md ├── CHANGELOG-3.5.md ├── CHANGELOG-3.6.md ├── CHANGELOG-3.7.md ├── CHANGELOG-4.0.md └── README.md ├── CONTRIBUTING.md ├── DCO ├── Dockerfile ├── Documentation ├── OWNERS ├── README.md ├── contributor-guide │ ├── branch_management.md │ ├── bump_etcd_version_k8s.md │ ├── community-membership.md │ ├── dependency_management.md │ ├── features.md │ ├── local_cluster.md │ ├── logging.md │ ├── modules-future.svg │ ├── modules.md │ ├── modules.svg │ ├── release.md │ ├── reporting_bugs.md │ ├── roadmap.md │ ├── triage_issues.md │ └── triage_prs.md ├── dev-guide │ └── apispec │ │ └── swagger │ │ ├── rpc.swagger.json │ │ ├── v3election.swagger.json │ │ └── v3lock.swagger.json ├── etcd-internals │ └── diagrams │ │ ├── consistent_read_workflow.drawio │ │ ├── consistent_read_workflow.png │ │ ├── etcd_internal_parts.drawio │ │ ├── etcd_internal_parts.png │ │ ├── write_workflow_follower.drawio │ │ ├── write_workflow_follower.png │ │ ├── write_workflow_leader.drawio │ │ └── write_workflow_leader.png └── postmortems │ └── v3.5-data-inconsistency.md ├── GOVERNANCE.md ├── LICENSE ├── Makefile ├── OWNERS ├── Procfile ├── README.md ├── api ├── LICENSE ├── authpb │ ├── auth.pb.go │ └── auth.proto ├── etcdserverpb │ ├── etcdserver.pb.go │ ├── etcdserver.proto │ ├── gw │ │ └── rpc.pb.gw.go │ ├── raft_internal.pb.go │ ├── raft_internal.proto │ ├── raft_internal_stringer.go │ ├── raft_internal_stringer_test.go │ ├── rpc.pb.go │ └── rpc.proto ├── go.mod ├── go.sum ├── membershippb │ ├── membership.pb.go │ └── membership.proto ├── mvccpb │ ├── kv.pb.go │ └── kv.proto ├── v3rpc │ └── rpctypes │ │ ├── doc.go │ │ ├── error.go │ │ ├── error_test.go │ │ ├── md.go │ │ └── metadatafields.go ├── version │ ├── version.go │ └── version_test.go └── versionpb │ ├── version.pb.go │ └── version.proto ├── bill-of-materials.json ├── bill-of-materials.override.json ├── cache ├── LICENSE ├── OWNERS ├── README.md ├── cache.go └── go.mod ├── client ├── internal │ └── v2 │ │ ├── LICENSE │ │ ├── README.md │ │ ├── auth_role.go │ │ ├── auth_user.go │ │ ├── cancelreq.go │ │ ├── client.go │ │ ├── client_test.go │ │ ├── cluster_error.go │ │ ├── curl.go │ │ ├── discover.go │ │ ├── doc.go │ │ ├── fake_transport_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── keys.go │ │ ├── keys_bench_test.go │ │ ├── keys_test.go │ │ ├── main_test.go │ │ ├── members.go │ │ ├── members_test.go │ │ └── util.go ├── pkg │ ├── LICENSE │ ├── fileutil │ │ ├── dir_unix.go │ │ ├── dir_windows.go │ │ ├── doc.go │ │ ├── filereader.go │ │ ├── filereader_test.go │ │ ├── fileutil.go │ │ ├── fileutil_test.go │ │ ├── lock.go │ │ ├── lock_flock.go │ │ ├── lock_linux.go │ │ ├── lock_linux_test.go │ │ ├── lock_plan9.go │ │ ├── lock_solaris.go │ │ ├── lock_test.go │ │ ├── lock_unix.go │ │ ├── lock_windows.go │ │ ├── preallocate.go │ │ ├── preallocate_darwin.go │ │ ├── preallocate_test.go │ │ ├── preallocate_unix.go │ │ ├── preallocate_unsupported.go │ │ ├── purge.go │ │ ├── purge_test.go │ │ ├── read_dir.go │ │ ├── read_dir_test.go │ │ ├── sync.go │ │ ├── sync_darwin.go │ │ └── sync_linux.go │ ├── go.mod │ ├── go.sum │ ├── logutil │ │ ├── doc.go │ │ ├── log_format.go │ │ ├── log_format_test.go │ │ ├── log_level.go │ │ ├── zap.go │ │ ├── zap_journal.go │ │ ├── zap_journal_test.go │ │ └── zap_test.go │ ├── pathutil │ │ ├── path.go │ │ └── path_test.go │ ├── srv │ │ ├── srv.go │ │ └── srv_test.go │ ├── systemd │ │ ├── doc.go │ │ └── journal.go │ ├── testutil │ │ ├── assert.go │ │ ├── before.go │ │ ├── leak.go │ │ ├── leak_test.go │ │ ├── pauseable_handler.go │ │ ├── recorder.go │ │ ├── testingtb.go │ │ ├── testutil.go │ │ └── var.go │ ├── tlsutil │ │ ├── cipher_suites.go │ │ ├── cipher_suites_test.go │ │ ├── doc.go │ │ ├── tlsutil.go │ │ ├── versions.go │ │ └── versions_test.go │ ├── transport │ │ ├── doc.go │ │ ├── keepalive_listener.go │ │ ├── keepalive_listener_openbsd.go │ │ ├── keepalive_listener_test.go │ │ ├── keepalive_listener_unix.go │ │ ├── limit_listen.go │ │ ├── listener.go │ │ ├── listener_opts.go │ │ ├── listener_test.go │ │ ├── listener_tls.go │ │ ├── sockopt.go │ │ ├── sockopt_solaris.go │ │ ├── sockopt_unix.go │ │ ├── sockopt_wasm.go │ │ ├── sockopt_windows.go │ │ ├── timeout_conn.go │ │ ├── timeout_dialer.go │ │ ├── timeout_dialer_test.go │ │ ├── timeout_listener.go │ │ ├── timeout_listener_test.go │ │ ├── timeout_transport.go │ │ ├── timeout_transport_test.go │ │ ├── tls.go │ │ ├── tls_test.go │ │ ├── transport.go │ │ ├── transport_test.go │ │ └── unix_listener.go │ ├── types │ │ ├── doc.go │ │ ├── id.go │ │ ├── id_test.go │ │ ├── set.go │ │ ├── set_test.go │ │ ├── slice.go │ │ ├── slice_test.go │ │ ├── urls.go │ │ ├── urls_test.go │ │ ├── urlsmap.go │ │ └── urlsmap_test.go │ └── verify │ │ └── verify.go └── v3 │ ├── LICENSE │ ├── OWNERS │ ├── README.md │ ├── auth.go │ ├── client.go │ ├── client_test.go │ ├── clientv3util │ ├── example_key_test.go │ └── util.go │ ├── cluster.go │ ├── compact_op.go │ ├── compact_op_test.go │ ├── compare.go │ ├── concurrency │ ├── doc.go │ ├── election.go │ ├── example_election_test.go │ ├── example_mutex_test.go │ ├── example_stm_test.go │ ├── key.go │ ├── main_test.go │ ├── mutex.go │ ├── session.go │ ├── stm.go │ └── stm_test.go │ ├── config.go │ ├── config_test.go │ ├── credentials │ ├── credentials.go │ └── credentials_test.go │ ├── ctx.go │ ├── ctx_test.go │ ├── doc.go │ ├── example_auth_test.go │ ├── example_cluster_test.go │ ├── example_kv_test.go │ ├── example_lease_test.go │ ├── example_maintenance_test.go │ ├── example_metrics_test.go │ ├── example_test.go │ ├── example_watch_test.go │ ├── experimental │ └── recipes │ │ ├── barrier.go │ │ ├── client.go │ │ ├── doc.go │ │ ├── double_barrier.go │ │ ├── grpc_gateway │ │ └── user_add.sh │ │ ├── key.go │ │ ├── priority_queue.go │ │ ├── queue.go │ │ ├── rwmutex.go │ │ └── watch.go │ ├── go.mod │ ├── go.sum │ ├── internal │ ├── endpoint │ │ ├── endpoint.go │ │ └── endpoint_test.go │ └── resolver │ │ └── resolver.go │ ├── kubernetes │ ├── client.go │ └── interface.go │ ├── kv.go │ ├── lease.go │ ├── leasing │ ├── cache.go │ ├── doc.go │ ├── kv.go │ ├── txn.go │ └── util.go │ ├── logger.go │ ├── main_test.go │ ├── maintenance.go │ ├── mirror │ └── syncer.go │ ├── mock │ └── mockserver │ │ ├── doc.go │ │ └── mockserver.go │ ├── namespace │ ├── doc.go │ ├── kv.go │ ├── lease.go │ ├── util.go │ ├── util_test.go │ └── watch.go │ ├── naming │ ├── doc.go │ ├── endpoints │ │ ├── endpoints.go │ │ ├── endpoints_impl.go │ │ └── internal │ │ │ └── update.go │ └── resolver │ │ └── resolver.go │ ├── op.go │ ├── op_test.go │ ├── options.go │ ├── ordering │ ├── doc.go │ ├── kv.go │ ├── kv_test.go │ └── util.go │ ├── retry.go │ ├── retry_interceptor.go │ ├── retry_interceptor_test.go │ ├── snapshot │ ├── doc.go │ └── v3_snapshot.go │ ├── sort.go │ ├── txn.go │ ├── txn_test.go │ ├── utils.go │ ├── watch.go │ ├── watch_test.go │ └── yaml │ ├── config.go │ └── config_test.go ├── code-of-conduct.md ├── codecov.yml ├── contrib ├── OWNERS ├── README.md ├── lock │ ├── README.md │ ├── client │ │ ├── .gitignore │ │ └── client.go │ └── storage │ │ ├── .gitignore │ │ └── storage.go ├── mixin │ ├── .gitignore │ ├── .lint │ ├── Makefile │ ├── OWNERS │ ├── README.md │ ├── alerts │ │ └── alerts.libsonnet │ ├── config.libsonnet │ ├── dashboards │ │ ├── dashboards.libsonnet │ │ ├── etcd-grafana7x.libsonnet │ │ ├── etcd.libsonnet │ │ ├── g.libsonnet │ │ ├── panels.libsonnet │ │ ├── targets.libsonnet │ │ └── variables.libsonnet │ ├── jsonnetfile.json │ ├── jsonnetfile.lock.json │ ├── mixin.libsonnet │ └── test.yaml ├── raftexample │ ├── Procfile │ ├── README.md │ ├── doc.go │ ├── httpapi.go │ ├── kvstore.go │ ├── kvstore_test.go │ ├── listener.go │ ├── main.go │ ├── raft.go │ ├── raft_test.go │ └── raftexample_test.go └── systemd │ ├── etcd.service │ ├── etcd3-multinode │ └── README.md │ └── sysusers.d │ └── 20-etcd.conf ├── dummy.go ├── etcd.conf.yml.sample ├── etcdctl ├── LICENSE ├── OWNERS ├── README.md ├── READMEv2.md ├── ctlv3 │ ├── command │ │ ├── alarm_command.go │ │ ├── auth_command.go │ │ ├── check.go │ │ ├── compaction_command.go │ │ ├── completion_command.go │ │ ├── defrag_command.go │ │ ├── del_command.go │ │ ├── doc.go │ │ ├── downgrade_command.go │ │ ├── elect_command.go │ │ ├── ep_command.go │ │ ├── get_command.go │ │ ├── global.go │ │ ├── lease_command.go │ │ ├── lock_command.go │ │ ├── make_mirror_command.go │ │ ├── member_command.go │ │ ├── move_leader_command.go │ │ ├── printer.go │ │ ├── printer_fields.go │ │ ├── printer_json.go │ │ ├── printer_protobuf.go │ │ ├── printer_simple.go │ │ ├── printer_table.go │ │ ├── put_command.go │ │ ├── role_command.go │ │ ├── snapshot_command.go │ │ ├── txn_command.go │ │ ├── user_command.go │ │ ├── util.go │ │ ├── version_command.go │ │ ├── watch_command.go │ │ └── watch_command_test.go │ └── ctl.go ├── doc │ └── mirror_maker.md ├── go.mod ├── go.sum ├── main.go └── util │ ├── help.go │ └── normalizer.go ├── etcdutl ├── LICENSE ├── OWNERS ├── README.md ├── ctl.go ├── etcdutl │ ├── common.go │ ├── common_test.go │ ├── completion_commmand.go │ ├── defrag_command.go │ ├── hashkv_command.go │ ├── migrate_command.go │ ├── printer.go │ ├── printer_fields.go │ ├── printer_json.go │ ├── printer_protobuf.go │ ├── printer_simple.go │ ├── printer_table.go │ ├── snapshot_command.go │ └── version_command.go ├── go.mod ├── go.sum ├── main.go └── snapshot │ ├── doc.go │ ├── v3_snapshot.go │ └── v3_snapshot_test.go ├── go.mod ├── go.sum ├── hack ├── README.md ├── benchmark │ ├── README.md │ └── bench.sh ├── insta-discovery │ ├── Procfile │ ├── README.md │ └── discovery ├── kubernetes-deploy │ ├── README.md │ ├── etcd.yml │ └── vulcand.yml ├── patch │ ├── README.md │ └── cherrypick.sh └── tls-setup │ ├── Makefile │ ├── Procfile │ ├── README.md │ └── config │ ├── ca-config.json │ ├── ca-csr.json │ └── req-csr.json ├── logos ├── etcd-glyph-color.png ├── etcd-glyph-color.svg ├── etcd-horizontal-bw.png ├── etcd-horizontal-bw.svg ├── etcd-horizontal-color.png ├── etcd-horizontal-color.svg ├── etcd-offset-bw.png ├── etcd-offset-bw.svg ├── etcd-offset-color.png ├── etcd-offset-color.svg ├── etcd-stacked-bw.png ├── etcd-stacked-bw.svg ├── etcd-stacked-color.png ├── etcd-stacked-color.svg └── etcd-xkcd-2347.png ├── pkg ├── LICENSE ├── README.md ├── adt │ ├── README.md │ ├── adt.go │ ├── example_test.go │ ├── 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 │ ├── interval_tree.go │ └── interval_tree_test.go ├── cobrautl │ ├── error.go │ └── help.go ├── contention │ ├── contention.go │ └── doc.go ├── cpuutil │ ├── doc.go │ └── endian.go ├── crc │ ├── crc.go │ └── crc_test.go ├── debugutil │ ├── doc.go │ └── pprof.go ├── expect │ ├── expect.go │ └── expect_test.go ├── featuregate │ ├── feature_gate.go │ └── feature_gate_test.go ├── flags │ ├── flag.go │ ├── flag_test.go │ ├── ignored.go │ ├── selective_string.go │ ├── selective_string_test.go │ ├── strings.go │ ├── strings_test.go │ ├── uint32.go │ ├── uint32_test.go │ ├── unique_strings.go │ ├── unique_strings_test.go │ ├── unique_urls.go │ ├── unique_urls_test.go │ ├── urls.go │ └── urls_test.go ├── go.mod ├── go.sum ├── grpctesting │ ├── recorder.go │ └── stub_server.go ├── httputil │ ├── httputil.go │ └── httputil_test.go ├── idutil │ ├── id.go │ └── id_test.go ├── ioutil │ ├── pagewriter.go │ ├── pagewriter_test.go │ ├── readcloser.go │ ├── readcloser_test.go │ ├── reader.go │ ├── reader_test.go │ └── util.go ├── netutil │ ├── doc.go │ ├── netutil.go │ ├── netutil_test.go │ ├── routes.go │ ├── routes_linux.go │ └── routes_linux_test.go ├── notify │ └── notify.go ├── osutil │ ├── interrupt_unix.go │ ├── interrupt_windows.go │ ├── osutil.go │ ├── osutil_test.go │ ├── signal.go │ └── signal_linux.go ├── pbutil │ ├── pbutil.go │ └── pbutil_test.go ├── proxy │ ├── doc.go │ ├── fixtures │ │ ├── ca-csr.json │ │ ├── ca.crt │ │ ├── gencert.json │ │ ├── gencerts.sh │ │ ├── server-ca-csr.json │ │ ├── server.crt │ │ └── server.key.insecure │ ├── server.go │ └── server_test.go ├── report │ ├── doc.go │ ├── report.go │ ├── report_test.go │ ├── timeseries.go │ ├── timeseries_test.go │ └── weighted.go ├── runtime │ ├── fds_linux.go │ └── fds_other.go ├── schedule │ ├── doc.go │ ├── schedule.go │ └── schedule_test.go ├── stringutil │ ├── doc.go │ ├── rand.go │ └── rand_test.go ├── traceutil │ ├── trace.go │ └── trace_test.go └── wait │ ├── wait.go │ ├── wait_test.go │ ├── wait_time.go │ └── wait_time_test.go ├── scripts ├── OWNERS ├── README ├── build-binary.sh ├── build-docker.sh ├── build-release.sh ├── build.sh ├── build_lib.sh ├── build_tools.sh ├── codecov_upload.sh ├── etcd_version_annotations.txt ├── fix.sh ├── fuzzing.sh ├── genproto.sh ├── markdown_diff_lint.sh ├── measure-testgrid-flakiness.sh ├── release.sh ├── release_mod.sh ├── release_notes.tpl.txt ├── sync_go_toolchain_directive.sh ├── test.sh ├── test_images.sh ├── test_lib.sh ├── test_utils.sh ├── update_dep.sh ├── update_proto_annotations.sh ├── updatebom.sh ├── verify_genproto.sh ├── verify_go_versions.sh └── verify_proto_annotations.sh ├── security ├── FUZZING_AUDIT_2022.PDF ├── OWNERS ├── README.md ├── SECURITY_AUDIT.pdf ├── email-templates.md └── security-release-process.md ├── server ├── LICENSE ├── auth │ ├── doc.go │ ├── jwt.go │ ├── jwt_test.go │ ├── main_test.go │ ├── metrics.go │ ├── nop.go │ ├── options.go │ ├── range_perm_cache.go │ ├── range_perm_cache_test.go │ ├── simple_token.go │ ├── simple_token_test.go │ ├── store.go │ ├── store_mock_test.go │ └── store_test.go ├── config │ ├── config.go │ ├── config_test.go │ ├── v2_deprecation.go │ └── v2_deprecation_test.go ├── embed │ ├── auth_test.go │ ├── config.go │ ├── config_logging.go │ ├── config_logging_journal_unix.go │ ├── config_logging_journal_windows.go │ ├── config_test.go │ ├── config_tracing.go │ ├── config_tracing_test.go │ ├── doc.go │ ├── etcd.go │ ├── etcd_test.go │ ├── serve.go │ ├── serve_test.go │ └── util.go ├── etcdmain │ ├── config.go │ ├── config_test.go │ ├── doc.go │ ├── etcd.go │ ├── gateway.go │ ├── grpc_proxy.go │ ├── help.go │ ├── main.go │ └── util.go ├── etcdserver │ ├── adapters.go │ ├── api │ │ ├── capability.go │ │ ├── cluster.go │ │ ├── doc.go │ │ ├── etcdhttp │ │ │ ├── debug.go │ │ │ ├── doc.go │ │ │ ├── health.go │ │ │ ├── health_test.go │ │ │ ├── metrics.go │ │ │ ├── peer.go │ │ │ ├── peer_test.go │ │ │ ├── types │ │ │ │ ├── errors.go │ │ │ │ └── errors_test.go │ │ │ ├── utils.go │ │ │ ├── version.go │ │ │ └── version_test.go │ │ ├── membership │ │ │ ├── cluster.go │ │ │ ├── cluster_opts.go │ │ │ ├── cluster_test.go │ │ │ ├── doc.go │ │ │ ├── errors.go │ │ │ ├── member.go │ │ │ ├── member_test.go │ │ │ ├── membership_test.go │ │ │ ├── metrics.go │ │ │ ├── store.go │ │ │ ├── storev2.go │ │ │ └── storev2_test.go │ │ ├── rafthttp │ │ │ ├── coder.go │ │ │ ├── doc.go │ │ │ ├── fake_roundtripper_test.go │ │ │ ├── functional_test.go │ │ │ ├── http.go │ │ │ ├── http_test.go │ │ │ ├── metrics.go │ │ │ ├── msg_codec.go │ │ │ ├── msg_codec_test.go │ │ │ ├── msgappv2_codec.go │ │ │ ├── msgappv2_codec_test.go │ │ │ ├── peer.go │ │ │ ├── peer_status.go │ │ │ ├── peer_test.go │ │ │ ├── pipeline.go │ │ │ ├── pipeline_test.go │ │ │ ├── probing_status.go │ │ │ ├── remote.go │ │ │ ├── snapshot_sender.go │ │ │ ├── snapshot_test.go │ │ │ ├── stream.go │ │ │ ├── stream_test.go │ │ │ ├── transport.go │ │ │ ├── transport_bench_test.go │ │ │ ├── transport_test.go │ │ │ ├── urlpick.go │ │ │ ├── urlpick_test.go │ │ │ ├── util.go │ │ │ └── util_test.go │ │ ├── snap │ │ │ ├── db.go │ │ │ ├── doc.go │ │ │ ├── message.go │ │ │ ├── metrics.go │ │ │ ├── snappb │ │ │ │ ├── snap.pb.go │ │ │ │ └── snap.proto │ │ │ ├── snapshotter.go │ │ │ └── snapshotter_test.go │ │ ├── v2discovery │ │ │ ├── discovery.go │ │ │ └── discovery_test.go │ │ ├── v2error │ │ │ ├── error.go │ │ │ └── error_test.go │ │ ├── v2stats │ │ │ ├── leader.go │ │ │ ├── queue.go │ │ │ └── server.go │ │ ├── v2store │ │ │ ├── doc.go │ │ │ ├── event.go │ │ │ ├── event_history.go │ │ │ ├── event_queue.go │ │ │ ├── event_test.go │ │ │ ├── heap_test.go │ │ │ ├── metrics.go │ │ │ ├── node.go │ │ │ ├── node_extern.go │ │ │ ├── node_extern_test.go │ │ │ ├── node_test.go │ │ │ ├── stats.go │ │ │ ├── stats_test.go │ │ │ ├── store.go │ │ │ ├── store_bench_test.go │ │ │ ├── store_ttl_test.go │ │ │ ├── ttl_key_heap.go │ │ │ ├── watcher.go │ │ │ ├── watcher_hub.go │ │ │ ├── watcher_hub_test.go │ │ │ └── watcher_test.go │ │ ├── v3alarm │ │ │ └── alarms.go │ │ ├── v3client │ │ │ ├── doc.go │ │ │ └── v3client.go │ │ ├── v3compactor │ │ │ ├── compactor.go │ │ │ ├── compactor_test.go │ │ │ ├── doc.go │ │ │ ├── periodic.go │ │ │ ├── periodic_test.go │ │ │ ├── revision.go │ │ │ └── revision_test.go │ │ ├── v3discovery │ │ │ ├── discovery.go │ │ │ └── discovery_test.go │ │ ├── v3election │ │ │ ├── doc.go │ │ │ ├── election.go │ │ │ └── v3electionpb │ │ │ │ ├── gw │ │ │ │ └── v3election.pb.gw.go │ │ │ │ ├── v3election.pb.go │ │ │ │ └── v3election.proto │ │ ├── v3lock │ │ │ ├── doc.go │ │ │ ├── lock.go │ │ │ └── v3lockpb │ │ │ │ ├── gw │ │ │ │ └── v3lock.pb.gw.go │ │ │ │ ├── v3lock.pb.go │ │ │ │ └── v3lock.proto │ │ └── v3rpc │ │ │ ├── auth.go │ │ │ ├── codec.go │ │ │ ├── grpc.go │ │ │ ├── header.go │ │ │ ├── health.go │ │ │ ├── interceptor.go │ │ │ ├── key.go │ │ │ ├── key_test.go │ │ │ ├── lease.go │ │ │ ├── maintenance.go │ │ │ ├── member.go │ │ │ ├── metrics.go │ │ │ ├── quota.go │ │ │ ├── util.go │ │ │ ├── util_test.go │ │ │ ├── validationfuzz_test.go │ │ │ ├── watch.go │ │ │ └── watch_test.go │ ├── apply │ │ ├── apply.go │ │ ├── apply_auth.go │ │ ├── apply_auth_test.go │ │ ├── corrupt.go │ │ ├── metrics.go │ │ ├── uber_applier.go │ │ └── uber_applier_test.go │ ├── apply_v2.go │ ├── bootstrap.go │ ├── bootstrap_test.go │ ├── cindex │ │ ├── cindex.go │ │ ├── cindex_test.go │ │ └── doc.go │ ├── cluster_util.go │ ├── cluster_util_test.go │ ├── corrupt.go │ ├── corrupt_test.go │ ├── doc.go │ ├── errors │ │ └── errors.go │ ├── metrics.go │ ├── raft.go │ ├── raft_test.go │ ├── server.go │ ├── server_access_control.go │ ├── server_access_control_test.go │ ├── server_test.go │ ├── snapshot_merge.go │ ├── txn │ │ ├── delete.go │ │ ├── metrics.go │ │ ├── metrics_test.go │ │ ├── put.go │ │ ├── range.go │ │ ├── txn.go │ │ ├── txn_test.go │ │ ├── util.go │ │ ├── util_bench_test.go │ │ └── util_test.go │ ├── util.go │ ├── util_test.go │ ├── v2_server.go │ ├── v3_server.go │ ├── version │ │ ├── doc.go │ │ ├── downgrade.go │ │ ├── downgrade_test.go │ │ ├── errors.go │ │ ├── monitor.go │ │ ├── monitor_test.go │ │ ├── version.go │ │ └── version_test.go │ ├── zap_raft.go │ └── zap_raft_test.go ├── features │ └── etcd_features.go ├── go.mod ├── go.sum ├── lease │ ├── doc.go │ ├── lease.go │ ├── lease_queue.go │ ├── lease_queue_test.go │ ├── leasehttp │ │ ├── doc.go │ │ ├── http.go │ │ └── http_test.go │ ├── leasepb │ │ ├── lease.pb.go │ │ └── lease.proto │ ├── lessor.go │ ├── lessor_bench_test.go │ ├── lessor_test.go │ └── metrics.go ├── main.go ├── mock │ ├── mockstorage │ │ ├── doc.go │ │ └── storage_recorder.go │ ├── mockstore │ │ ├── doc.go │ │ └── store_recorder.go │ └── mockwait │ │ ├── doc.go │ │ └── wait_recorder.go ├── proxy │ ├── grpcproxy │ │ ├── adapter │ │ │ ├── auth_client_adapter.go │ │ │ ├── chan_stream.go │ │ │ ├── cluster_client_adapter.go │ │ │ ├── doc.go │ │ │ ├── election_client_adapter.go │ │ │ ├── kv_client_adapter.go │ │ │ ├── lease_client_adapter.go │ │ │ ├── lock_client_adapter.go │ │ │ ├── maintenance_client_adapter.go │ │ │ └── watch_client_adapter.go │ │ ├── auth.go │ │ ├── cache │ │ │ └── store.go │ │ ├── cluster.go │ │ ├── doc.go │ │ ├── election.go │ │ ├── health.go │ │ ├── kv.go │ │ ├── leader.go │ │ ├── lease.go │ │ ├── lock.go │ │ ├── maintenance.go │ │ ├── metrics.go │ │ ├── register.go │ │ ├── util.go │ │ ├── watch.go │ │ ├── watch_broadcast.go │ │ ├── watch_broadcasts.go │ │ ├── watch_ranges.go │ │ └── watcher.go │ └── tcpproxy │ │ ├── doc.go │ │ ├── userspace.go │ │ └── userspace_test.go ├── storage │ ├── backend.go │ ├── backend │ │ ├── backend.go │ │ ├── backend_bench_test.go │ │ ├── backend_test.go │ │ ├── batch_tx.go │ │ ├── batch_tx_test.go │ │ ├── config_default.go │ │ ├── config_linux.go │ │ ├── config_windows.go │ │ ├── doc.go │ │ ├── export_test.go │ │ ├── hooks.go │ │ ├── hooks_test.go │ │ ├── metrics.go │ │ ├── read_tx.go │ │ ├── testing │ │ │ └── betesting.go │ │ ├── tx_buffer.go │ │ ├── tx_buffer_test.go │ │ ├── verify.go │ │ └── verify_test.go │ ├── datadir │ │ ├── datadir.go │ │ ├── datadir_test.go │ │ └── doc.go │ ├── hooks.go │ ├── metrics.go │ ├── mvcc │ │ ├── doc.go │ │ ├── hash.go │ │ ├── hash_test.go │ │ ├── index.go │ │ ├── index_bench_test.go │ │ ├── index_test.go │ │ ├── key_index.go │ │ ├── key_index_test.go │ │ ├── kv.go │ │ ├── kv_test.go │ │ ├── kv_view.go │ │ ├── kvstore.go │ │ ├── kvstore_bench_test.go │ │ ├── kvstore_compaction.go │ │ ├── kvstore_compaction_test.go │ │ ├── kvstore_test.go │ │ ├── kvstore_txn.go │ │ ├── metrics.go │ │ ├── metrics_txn.go │ │ ├── revision.go │ │ ├── store.go │ │ ├── store_test.go │ │ ├── testutil │ │ │ └── hash.go │ │ ├── watchable_store.go │ │ ├── watchable_store_bench_test.go │ │ ├── watchable_store_test.go │ │ ├── watchable_store_txn.go │ │ ├── watcher.go │ │ ├── watcher_bench_test.go │ │ ├── watcher_group.go │ │ └── watcher_test.go │ ├── quota.go │ ├── schema │ │ ├── actions.go │ │ ├── actions_test.go │ │ ├── alarm.go │ │ ├── auth.go │ │ ├── auth_roles.go │ │ ├── auth_roles_test.go │ │ ├── auth_test.go │ │ ├── auth_users.go │ │ ├── auth_users_test.go │ │ ├── bucket.go │ │ ├── changes.go │ │ ├── changes_test.go │ │ ├── cindex.go │ │ ├── confstate.go │ │ ├── confstate_test.go │ │ ├── lease.go │ │ ├── lease_test.go │ │ ├── membership.go │ │ ├── migration.go │ │ ├── migration_test.go │ │ ├── schema.go │ │ ├── schema_test.go │ │ ├── version.go │ │ └── version_test.go │ ├── storage.go │ ├── util.go │ └── wal │ │ ├── decoder.go │ │ ├── doc.go │ │ ├── encoder.go │ │ ├── file_pipeline.go │ │ ├── file_pipeline_test.go │ │ ├── metrics.go │ │ ├── record_test.go │ │ ├── repair.go │ │ ├── repair_test.go │ │ ├── testing │ │ └── waltesting.go │ │ ├── util.go │ │ ├── version.go │ │ ├── version_test.go │ │ ├── wal.go │ │ ├── wal_bench_test.go │ │ ├── wal_test.go │ │ └── walpb │ │ ├── record.go │ │ ├── record.pb.go │ │ ├── record.proto │ │ └── record_test.go └── verify │ ├── doc.go │ └── verify.go ├── tests ├── LICENSE ├── OWNERS ├── antithesis │ ├── Dockerfile.config │ ├── Makefile │ ├── README.md │ ├── docker-compose.yml │ ├── server │ │ └── Dockerfile │ └── test-template │ │ ├── Dockerfile │ │ ├── entrypoint │ │ └── main.go │ │ └── robustness │ │ ├── common │ │ └── path.go │ │ ├── finally │ │ └── main.go │ │ └── traffic │ │ └── main.go ├── common │ ├── alarm_test.go │ ├── auth_test.go │ ├── auth_util.go │ ├── compact_test.go │ ├── defrag_test.go │ ├── e2e_test.go │ ├── endpoint_test.go │ ├── integration_test.go │ ├── kv_test.go │ ├── lease_test.go │ ├── main_test.go │ ├── maintenance_auth_test.go │ ├── member_test.go │ ├── role_test.go │ ├── status_test.go │ ├── txn_test.go │ ├── unit_test.go │ ├── user_test.go │ ├── wait_leader_test.go │ └── watch_test.go ├── e2e │ ├── cluster_downgrade_test.go │ ├── cmux_test.go │ ├── corrupt_test.go │ ├── ctl_v3_auth_cluster_test.go │ ├── ctl_v3_auth_no_proxy_test.go │ ├── ctl_v3_auth_security_test.go │ ├── ctl_v3_auth_test.go │ ├── ctl_v3_completion_test.go │ ├── ctl_v3_defrag_test.go │ ├── ctl_v3_elect_test.go │ ├── ctl_v3_grpc_test.go │ ├── ctl_v3_kv_test.go │ ├── ctl_v3_lease_test.go │ ├── ctl_v3_lock_test.go │ ├── ctl_v3_make_mirror_test.go │ ├── ctl_v3_member_no_proxy_test.go │ ├── ctl_v3_member_test.go │ ├── ctl_v3_move_leader_test.go │ ├── ctl_v3_role_test.go │ ├── ctl_v3_snapshot_test.go │ ├── ctl_v3_test.go │ ├── ctl_v3_watch_no_cov_test.go │ ├── ctl_v3_watch_test.go │ ├── defrag_no_space_test.go │ ├── discovery_v3_test.go │ ├── doc.go │ ├── etcd_config_test.go │ ├── etcd_grpcproxy_test.go │ ├── etcd_mix_versions_test.go │ ├── etcd_release_upgrade_test.go │ ├── failover_test.go │ ├── force_new_cluster_test.go │ ├── gateway_test.go │ ├── graceful_shutdown_test.go │ ├── hashkv_test.go │ ├── http_health_check_test.go │ ├── leader_snapshot_no_proxy_test.go │ ├── logging_test.go │ ├── main_test.go │ ├── metrics_test.go │ ├── promote_experimental_flag_test.go │ ├── reproduce_17780_test.go │ ├── reproduce_19406_test.go │ ├── runtime_reconfiguration_test.go │ ├── utils.go │ ├── utl_migrate_test.go │ ├── v2store_deprecation_test.go │ ├── v3_cipher_suite_test.go │ ├── v3_curl_auth_test.go │ ├── v3_curl_cluster_test.go │ ├── v3_curl_election_test.go │ ├── v3_curl_kv_test.go │ ├── v3_curl_lease_test.go │ ├── v3_curl_lock_test.go │ ├── v3_curl_maintenance_test.go │ ├── v3_curl_maxstream_test.go │ ├── v3_curl_watch_test.go │ ├── v3_lease_no_proxy_test.go │ ├── watch_test.go │ └── zap_logging_test.go ├── fixtures │ ├── CommonName-root.crt │ ├── CommonName-root.key │ ├── ca-csr.json │ ├── ca.crt │ ├── client-ca-csr-nocn.json │ ├── client-clientusage.crt │ ├── client-clientusage.key.insecure │ ├── client-nocn.crt │ ├── client-nocn.key.insecure │ ├── ed25519-private-key.pem │ ├── ed25519-public-key.pem │ ├── gencert.json │ ├── gencerts.sh │ ├── revoke.crl │ ├── server-ca-csr-ecdsa.json │ ├── server-ca-csr-ip.json │ ├── server-ca-csr-ipv6.json │ ├── server-ca-csr-wildcard.json │ ├── server-ca-csr.json │ ├── server-ca-csr2.json │ ├── server-ca-csr3.json │ ├── server-ecdsa.crt │ ├── server-ecdsa.key.insecure │ ├── server-ip.crt │ ├── server-ip.key.insecure │ ├── server-ipv6.crt │ ├── server-ipv6.key.insecure │ ├── server-revoked.crt │ ├── server-revoked.key.insecure │ ├── server-serverusage.crt │ ├── server-serverusage.key.insecure │ ├── server-wildcard.crt │ ├── server-wildcard.key.insecure │ ├── server.crt │ ├── server.key.insecure │ ├── server2.crt │ ├── server2.key.insecure │ ├── server3.crt │ └── server3.key.insecure ├── framework │ ├── config │ │ ├── client.go │ │ └── cluster.go │ ├── e2e │ │ ├── cluster.go │ │ ├── cluster_direct.go │ │ ├── cluster_proxy.go │ │ ├── cluster_test.go │ │ ├── config.go │ │ ├── curl.go │ │ ├── downgrade.go │ │ ├── e2e.go │ │ ├── e2e_test.go │ │ ├── etcd_process.go │ │ ├── etcd_spawn.go │ │ ├── etcdctl.go │ │ ├── flags.go │ │ ├── lazyfs.go │ │ ├── metrics.go │ │ ├── testing.go │ │ └── util.go │ ├── integration │ │ ├── bridge.go │ │ ├── cluster.go │ │ ├── cluster_direct.go │ │ ├── cluster_proxy.go │ │ ├── integration.go │ │ └── testing.go │ ├── interfaces │ │ └── interface.go │ ├── testrunner.go │ ├── testutils │ │ ├── execute.go │ │ ├── helpters.go │ │ ├── log_observer.go │ │ ├── log_observer_test.go │ │ └── path.go │ └── unit │ │ └── unit.go ├── go.mod ├── go.sum ├── integration │ ├── clientv3 │ │ ├── cluster_test.go │ │ ├── concurrency │ │ │ ├── election_test.go │ │ │ ├── example_election_test.go │ │ │ ├── example_mutex_test.go │ │ │ ├── example_stm_test.go │ │ │ ├── main_test.go │ │ │ ├── mutex_test.go │ │ │ └── session_test.go │ │ ├── connectivity │ │ │ ├── black_hole_test.go │ │ │ ├── dial_test.go │ │ │ ├── doc.go │ │ │ ├── main_test.go │ │ │ ├── network_partition_test.go │ │ │ └── server_shutdown_test.go │ │ ├── doc.go │ │ ├── examples │ │ │ ├── example_auth_test.go │ │ │ ├── example_cluster_test.go │ │ │ ├── example_kv_test.go │ │ │ ├── example_lease_test.go │ │ │ ├── example_maintenance_test.go │ │ │ ├── example_metrics_test.go │ │ │ ├── example_test.go │ │ │ ├── example_watch_test.go │ │ │ └── main_test.go │ │ ├── experimental │ │ │ └── recipes │ │ │ │ ├── v3_barrier_test.go │ │ │ │ ├── v3_double_barrier_test.go │ │ │ │ ├── v3_lock_test.go │ │ │ │ └── v3_queue_test.go │ │ ├── kv_test.go │ │ ├── lease │ │ │ ├── doc.go │ │ │ ├── lease_test.go │ │ │ ├── leasing_test.go │ │ │ └── main_test.go │ │ ├── main_test.go │ │ ├── maintenance_test.go │ │ ├── metrics_test.go │ │ ├── mirror_auth_test.go │ │ ├── mirror_test.go │ │ ├── namespace_test.go │ │ ├── naming │ │ │ ├── endpoints_test.go │ │ │ ├── main_test.go │ │ │ └── resolver_test.go │ │ ├── ordering_kv_test.go │ │ ├── ordering_util_test.go │ │ ├── snapshot │ │ │ └── v3_snapshot_test.go │ │ ├── txn_test.go │ │ ├── user_test.go │ │ ├── util.go │ │ ├── watch_fragment_test.go │ │ └── watch_test.go │ ├── cluster_test.go │ ├── corrupt_test.go │ ├── doc.go │ ├── embed │ │ ├── embed_proxy_test.go │ │ └── embed_test.go │ ├── fixtures-expired │ │ ├── README │ │ ├── ca-csr.json │ │ ├── ca.crt │ │ ├── gencert.json │ │ ├── gencerts.sh │ │ ├── server-ca-csr-ip.json │ │ ├── server-ca-csr.json │ │ ├── server-ip.crt │ │ ├── server-ip.key.insecure │ │ ├── server.crt │ │ └── server.key.insecure │ ├── grpc_test.go │ ├── hashkv_test.go │ ├── lazy_cluster.go │ ├── main_test.go │ ├── member_test.go │ ├── metrics_test.go │ ├── network_partition_test.go │ ├── proxy │ │ └── grpcproxy │ │ │ ├── cluster_test.go │ │ │ ├── kv_test.go │ │ │ └── register_test.go │ ├── revision_test.go │ ├── snapshot │ │ ├── member_test.go │ │ ├── testdata │ │ │ └── corrupted_backup.db │ │ └── v3_snapshot_test.go │ ├── testing_test.go │ ├── tracing_test.go │ ├── util_test.go │ ├── utl_wal_version_test.go │ ├── v2store │ │ ├── main_test.go │ │ ├── store_tag_test.go │ │ └── store_test.go │ ├── v3_alarm_test.go │ ├── v3_auth_test.go │ ├── v3_election_test.go │ ├── v3_failover_test.go │ ├── v3_grpc_inflight_test.go │ ├── v3_grpc_test.go │ ├── v3_kv_test.go │ ├── v3_leadership_test.go │ ├── v3_lease_test.go │ ├── v3_stm_test.go │ ├── v3_tls_test.go │ ├── v3_watch_restore_test.go │ ├── v3_watch_test.go │ ├── v3election_grpc_test.go │ └── v3lock_grpc_test.go ├── robustness │ ├── Makefile │ ├── OWNERS │ ├── README.md │ ├── client │ │ ├── client.go │ │ ├── kvhash.go │ │ └── watch.go │ ├── failpoint │ │ ├── cluster.go │ │ ├── failpoint.go │ │ ├── gofail.go │ │ ├── kill.go │ │ ├── network.go │ │ └── trigger.go │ ├── identity │ │ ├── id.go │ │ └── lease_ids.go │ ├── main_test.go │ ├── model │ │ ├── describe.go │ │ ├── describe_test.go │ │ ├── deterministic.go │ │ ├── deterministic_test.go │ │ ├── history.go │ │ ├── history_test.go │ │ ├── non_deterministic.go │ │ ├── non_deterministic_test.go │ │ ├── replay.go │ │ └── watch.go │ ├── options │ │ ├── cluster_options.go │ │ ├── cluster_options_test.go │ │ └── server_config_options.go │ ├── patches │ │ ├── beforeSendWatchResponse │ │ │ ├── build.patch │ │ │ └── watch.patch │ │ └── compactBeforeSetFinishedCompact │ │ │ └── kvstore_compaction.patch │ ├── random │ │ └── random.go │ ├── readme-images │ │ ├── artifact_archive.png │ │ ├── issue14370.png │ │ ├── prow_job.png │ │ ├── prow_job_artifacts_dir_page.png │ │ └── prow_job_artifacts_page.png │ ├── report │ │ ├── client.go │ │ ├── client_test.go │ │ ├── failpoint.go │ │ ├── report.go │ │ ├── wal.go │ │ └── wal_test.go │ ├── scenarios │ │ └── scenarios.go │ ├── testdata │ │ └── .gitignore │ ├── traffic │ │ ├── etcd.go │ │ ├── key_store.go │ │ ├── kubernetes.go │ │ ├── limiter.go │ │ ├── limiter_test.go │ │ └── traffic.go │ └── validate │ │ ├── operations.go │ │ ├── operations_test.go │ │ ├── patch_history.go │ │ ├── patch_history_test.go │ │ ├── validate.go │ │ ├── validate_test.go │ │ └── watch.go └── semaphore.test.bash └── tools ├── .golangci.yaml ├── .markdownlint.jsonc ├── .yamlfmt ├── .yamllint ├── OWNERS ├── benchmark ├── OWNERS ├── README.md ├── cmd │ ├── doc.go │ ├── lease.go │ ├── mvcc-put.go │ ├── mvcc.go │ ├── put.go │ ├── range.go │ ├── root.go │ ├── stm.go │ ├── txn_mixed.go │ ├── txn_put.go │ ├── util.go │ ├── watch.go │ ├── watch_get.go │ └── watch_latency.go ├── doc.go └── main.go ├── etcd-dump-db ├── OWNERS ├── README.md ├── backend.go ├── doc.go ├── main.go ├── meta.go ├── page.go ├── scan.go └── utils.go ├── etcd-dump-logs ├── OWNERS ├── README.md ├── doc.go ├── etcd-dump-log_test.go ├── expectedoutput │ ├── decoder_correctoutputformat.output │ ├── decoder_wrongoutputformat.output │ ├── listAll.output │ ├── listConfigChange.output │ ├── listConfigChangeIRRCompaction.output │ ├── listIRRCompaction.output │ ├── listIRRDeleteRange.output │ ├── listIRRLeaseGrant.output │ ├── listIRRLeaseRevoke.output │ ├── listIRRPut.output │ ├── listIRRRange.output │ ├── listIRRTxn.output │ ├── listInternalRaftRequest.output │ ├── listNormal.output │ └── listRequest.output ├── main.go ├── raw.go ├── raw_test.go └── testdecoder │ ├── decoder_correctoutputformat.sh │ └── decoder_wrongoutputformat.sh ├── etcd-dump-metrics ├── OWNERS ├── README.md ├── etcd.go ├── install_darwin.go ├── install_linux.go ├── install_windows.go ├── main.go ├── metrics.go └── utils.go ├── local-tester ├── OWNERS ├── Procfile ├── README.md ├── bridge.sh ├── bridge │ ├── bridge.go │ └── dispatch.go └── faults.sh ├── mod ├── doc.go ├── go.mod ├── go.sum ├── install_all.sh ├── libs.go └── tools.go ├── proto-annotations ├── cmd │ ├── etcd_version.go │ └── root.go └── main.go ├── rw-heatmaps ├── .gitignore ├── OWNERS ├── README.md ├── cmd │ └── root.go ├── go.mod ├── go.sum ├── main.go ├── pkg │ ├── chart │ │ ├── heatmap_grid.go │ │ ├── heatmaps.go │ │ └── line_chart.go │ └── dataset │ │ └── dataset.go └── rw-benchmark.sh └── testgrid-analysis ├── OWNERS ├── cmd ├── data.go ├── flaky.go ├── github.go └── root.go ├── go.mod ├── go.sum └── main.go /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the 2 | // README at: https://github.com/devcontainers/templates/tree/main/src/go 3 | { 4 | "name": "Go", 5 | // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile 6 | "image": "mcr.microsoft.com/devcontainers/go:1.24-bookworm", 7 | // Features to add to the dev container. More info: https://containers.dev/features. 8 | "features": { 9 | "ghcr.io/devcontainers/features/docker-in-docker:2": {}, 10 | "ghcr.io/devcontainers/features/github-cli:1": {}, 11 | "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {} 12 | }, 13 | // Use 'forwardPorts' to make a list of ports inside the container available locally. 14 | "forwardPorts": [ 15 | 2379, 16 | 2380 17 | ], 18 | // Use 'postCreateCommand' to run commands after the container is created. 19 | "postCreateCommand": "make build" 20 | // Configure tool-specific properties. 21 | // "customizations": {}, 22 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | blank_issues_enabled: false 3 | contact_links: 4 | - name: Question 5 | url: https://github.com/etcd-io/etcd/discussions 6 | about: Question relating to Etcd 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | description: Provide idea for a new feature 4 | labels: 5 | - type/feature 6 | body: 7 | - type: textarea 8 | id: feature 9 | attributes: 10 | label: What would you like to be added? 11 | validations: 12 | required: true 13 | 14 | - type: textarea 15 | id: rationale 16 | attributes: 17 | label: Why is this needed? 18 | validations: 19 | required: true 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/test-flake.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Flaking Test 3 | description: Report flaky tests 4 | labels: 5 | - type/flake 6 | - area/testing 7 | body: 8 | - type: textarea 9 | id: workflows 10 | attributes: 11 | label: Which Github Action / Prow Jobs are flaking? 12 | validations: 13 | required: true 14 | 15 | - type: textarea 16 | id: tests 17 | attributes: 18 | label: Which tests are flaking? 19 | validations: 20 | required: true 21 | 22 | - type: input 23 | id: link 24 | attributes: 25 | label: Github Action / Prow Job link 26 | 27 | - type: textarea 28 | id: reason 29 | attributes: 30 | label: Reason for failure (if possible) 31 | 32 | - type: textarea 33 | id: additional 34 | attributes: 35 | label: Anything else we need to know? 36 | -------------------------------------------------------------------------------- /.github/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | approvers: 4 | - ivanvc # Ivan Valdes 5 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow. 3 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | Please read https://github.com/etcd-io/etcd/blob/main/security/README.md. 3 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 2 3 | updates: 4 | - package-ecosystem: github-actions 5 | directory: / 6 | schedule: 7 | interval: weekly 8 | 9 | - package-ecosystem: gomod 10 | directory: / 11 | schedule: 12 | interval: weekly 13 | allow: 14 | - dependency-type: all 15 | 16 | - package-ecosystem: gomod 17 | directory: /tools/mod # Not linked from /go.mod 18 | schedule: 19 | interval: weekly 20 | allow: 21 | - dependency-type: direct 22 | 23 | - package-ecosystem: docker 24 | directory: / 25 | schedule: 26 | interval: weekly 27 | 28 | - package-ecosystem: docker 29 | directory: / 30 | target-branch: "release-3.4" 31 | schedule: 32 | interval: monthly 33 | 34 | - package-ecosystem: docker 35 | directory: / 36 | target-branch: "release-3.5" 37 | schedule: 38 | interval: monthly 39 | -------------------------------------------------------------------------------- /.github/workflows/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - github_actions 5 | -------------------------------------------------------------------------------- /.github/workflows/measure-testgrid-flakiness.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Measure TestGrid Flakiness 3 | 4 | on: 5 | schedule: 6 | - cron: "0 0 * * *" # run every day at midnight 7 | 8 | permissions: read-all 9 | 10 | jobs: 11 | measure-testgrid-flakiness: 12 | name: Measure TestGrid Flakiness 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 16 | - id: goversion 17 | run: echo "goversion=$(cat .go-version)" >> "$GITHUB_OUTPUT" 18 | - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 19 | with: 20 | go-version: ${{ steps.goversion.outputs.goversion }} 21 | - env: 22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 23 | run: | 24 | set -euo pipefail 25 | 26 | ./scripts/measure-testgrid-flakiness.sh 27 | -------------------------------------------------------------------------------- /.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 | *.iml 18 | /contrib/mixin/manifests 19 | /contrib/raftexample/raftexample 20 | /contrib/raftexample/raftexample-* 21 | /vendor 22 | /tests/e2e/default.proxy 23 | *.tmp 24 | *.bak 25 | .gobincache/ 26 | .DS_Store 27 | /Documentation/dev-guide/api_reference_v3.md 28 | /Documentation/dev-guide/api_concurrency_reference_v3.md 29 | 30 | /tools/etcd-dump-db/etcd-dump-db 31 | /tools/etcd-dump-logs/etcd-dump-logs 32 | /tools/etcd-dump-metrics/etcd-dump-metrics 33 | /tools/local-tester/bridge/bridge 34 | /tools/proto-annotations/proto-annotations 35 | /tools/benchmark/benchmark 36 | /out 37 | /etcd-dump-logs 38 | -------------------------------------------------------------------------------- /.go-version: -------------------------------------------------------------------------------- 1 | 1.24.3 2 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /CHANGELOG/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 | -------------------------------------------------------------------------------- /CHANGELOG/CHANGELOG-3.7.md: -------------------------------------------------------------------------------- 1 | 2 | Previous change logs can be found at [CHANGELOG-3.6](https://github.com/etcd-io/etcd/blob/main/CHANGELOG/CHANGELOG-3.6.md). 3 | 4 | --- 5 | 6 | ## v3.7.0 (TBD) 7 | 8 | ### Breaking Changes 9 | 10 | - [Removed all deprecated experimental flags](https://github.com/etcd-io/etcd/pull/19959) 11 | 12 | ### etcd server 13 | 14 | - [Update go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc to v0.61.0 and replaced the deprecated `UnaryServerInterceptor` and `StreamServerInterceptor` with `NewServerHandler`](https://github.com/etcd-io/etcd/pull/20017) 15 | - [Add Support for Unix Socket endpoints](https://github.com/etcd-io/etcd/pull/19760) 16 | 17 | ### Package `pkg` 18 | 19 | - [Optimize find performance by splitting intervals with the same left endpoint by their right endpoints](https://github.com/etcd-io/etcd/pull/19768) 20 | 21 | ### Dependencies 22 | 23 | - Compile binaries using [go 1.24.3](https://github.com/etcd-io/etcd/pull/19908) 24 | 25 | ### Deprecations 26 | 27 | - Deprecated [UsageFunc in pkg/cobrautl](https://github.com/etcd-io/etcd/pull/18356). 28 | -------------------------------------------------------------------------------- /CHANGELOG/README.md: -------------------------------------------------------------------------------- 1 | # Change logs 2 | 3 | ## Production recommendation 4 | 5 | The minimum recommended etcd versions to run in **production** are v3.4.22+ and v3.5.6+. Refer to the [versioning policy](https://etcd.io/docs/v3.5/op-guide/versioning/) for more details. 6 | 7 | ### v3.5 data corruption issue 8 | 9 | Running etcd v3.5.2, v3.5.1 and v3.5.0 under high load can cause a data corruption issue. 10 | If etcd process is killed, occasionally some committed transactions are not reflected on all the members. 11 | Recommendation is to upgrade to v3.5.4+. 12 | 13 | If you have encountered data corruption, please follow instructions on https://etcd.io/docs/v3.5/op-guide/data_corruption/. 14 | 15 | ## Change log rules 16 | 1. Each patch release only includes changes against previous patch release. 17 | For example, the change log of v3.5.5 should only include items which are new to v3.5.4. 18 | 2. For the first release (e.g. 3.4.0, 3.5.0, 3.6.0, 4.0.0 etc.) for each minor or major 19 | version, it only includes changes which are new to the first release of previous minor 20 | or major version. For example, v3.5.0 should only include items which are new to v3.4.0, 21 | and v3.6.0 should only include items which are new to v3.5.0. 22 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG ARCH=amd64 2 | FROM --platform=linux/${ARCH} gcr.io/distroless/static-debian12@sha256:d9f9472a8f4541368192d714a995eb1a99bab1f7071fc8bde261d7eda3b667d8 3 | 4 | ADD etcd /usr/local/bin/ 5 | ADD etcdctl /usr/local/bin/ 6 | ADD etcdutl /usr/local/bin/ 7 | 8 | WORKDIR /var/etcd/ 9 | WORKDIR /var/lib/etcd/ 10 | 11 | EXPOSE 2379 2380 12 | 13 | # Define default command. 14 | CMD ["/usr/local/bin/etcd"] 15 | -------------------------------------------------------------------------------- /Documentation/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/documentation 5 | -------------------------------------------------------------------------------- /Documentation/README.md: -------------------------------------------------------------------------------- 1 | This directory includes etcd project internal documentation for new and existing contributors. 2 | 3 | For user and developer documentation please go to [etcd.io](https://etcd.io/), 4 | which is developed in [website](https://github.com/etcd-io/website/) repo. 5 | -------------------------------------------------------------------------------- /Documentation/etcd-internals/diagrams/consistent_read_workflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/Documentation/etcd-internals/diagrams/consistent_read_workflow.png -------------------------------------------------------------------------------- /Documentation/etcd-internals/diagrams/etcd_internal_parts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/Documentation/etcd-internals/diagrams/etcd_internal_parts.png -------------------------------------------------------------------------------- /Documentation/etcd-internals/diagrams/write_workflow_follower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/Documentation/etcd-internals/diagrams/write_workflow_follower.png -------------------------------------------------------------------------------- /Documentation/etcd-internals/diagrams/write_workflow_leader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/Documentation/etcd-internals/diagrams/write_workflow_leader.png -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | approvers: 4 | - ahrtr # Benjamin Wang 5 | - fuweid # Wei Fu 6 | - jmhbnz # James Blair 7 | - serathius # Marek Siarkowicz 8 | - spzala # Sahdev Zala 9 | - wenjiaswe # Wenjia Zhang 10 | reviewers: 11 | - ivanvc # Ivan Valdes 12 | - siyuanfoundation # Siyuan Zhang 13 | -------------------------------------------------------------------------------- /api/authpb/auth.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package authpb; 3 | 4 | import "gogoproto/gogo.proto"; 5 | 6 | option go_package = "go.etcd.io/etcd/api/v3/authpb"; 7 | 8 | option (gogoproto.marshaler_all) = true; 9 | option (gogoproto.sizer_all) = true; 10 | option (gogoproto.unmarshaler_all) = true; 11 | option (gogoproto.goproto_getters_all) = false; 12 | option (gogoproto.goproto_enum_prefix_all) = false; 13 | 14 | message UserAddOptions { 15 | bool no_password = 1; 16 | }; 17 | 18 | // User is a single entry in the bucket authUsers 19 | message User { 20 | bytes name = 1; 21 | bytes password = 2; 22 | repeated string roles = 3; 23 | UserAddOptions options = 4; 24 | } 25 | 26 | // Permission is a single entity 27 | message Permission { 28 | enum Type { 29 | READ = 0; 30 | WRITE = 1; 31 | READWRITE = 2; 32 | } 33 | Type permType = 1; 34 | 35 | bytes key = 2; 36 | bytes range_end = 3; 37 | } 38 | 39 | // Role is a single entry in the bucket authRoles 40 | message Role { 41 | bytes name = 1; 42 | 43 | repeated Permission keyPermission = 2; 44 | } 45 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 22 | // TokenFieldNameGRPCKey is used as a key of context to store token. 23 | type TokenFieldNameGRPCKey struct{} 24 | -------------------------------------------------------------------------------- /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/grpc-ecosystem/go-grpc-middleware/v2/interceptors", 12 | "licenses": [ 13 | { 14 | "type": "Apache License 2.0", 15 | "confidence": 1 16 | } 17 | ] 18 | }, 19 | { 20 | "project": "github.com/inconshreveable/mousetrap", 21 | "licenses": [ 22 | { 23 | "type": "Apache License 2.0" 24 | } 25 | ] 26 | } 27 | ] 28 | -------------------------------------------------------------------------------- /cache/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/cache 5 | -------------------------------------------------------------------------------- /cache/README.md: -------------------------------------------------------------------------------- 1 | # etcd cache 2 | 3 | Experimental etcd client cache library. 4 | -------------------------------------------------------------------------------- /cache/cache.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 cache 16 | -------------------------------------------------------------------------------- /cache/go.mod: -------------------------------------------------------------------------------- 1 | module go.etcd.io/etcd/cache 2 | 3 | go 1.24 4 | 5 | toolchain go1.24.3 6 | -------------------------------------------------------------------------------- /client/internal/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(req *http.Request) func() { 12 | ch := make(chan struct{}) 13 | req.Cancel = ch 14 | 15 | return func() { 16 | close(ch) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /client/internal/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 | -------------------------------------------------------------------------------- /client/internal/v2/go.mod: -------------------------------------------------------------------------------- 1 | module go.etcd.io/etcd/client/v2 2 | 3 | go 1.24 4 | 5 | toolchain go1.24.3 6 | 7 | require ( 8 | github.com/stretchr/testify v1.10.0 9 | go.etcd.io/etcd/api/v3 v3.6.0-alpha.0 10 | go.etcd.io/etcd/client/pkg/v3 v3.6.0-alpha.0 11 | sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 12 | ) 13 | 14 | require ( 15 | github.com/coreos/go-semver v0.3.1 // indirect 16 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect 17 | github.com/kr/text v0.2.0 // indirect 18 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect 19 | gopkg.in/yaml.v3 v3.0.1 // indirect 20 | ) 21 | 22 | replace ( 23 | go.etcd.io/etcd/api/v3 => ./../../../api 24 | go.etcd.io/etcd/client/pkg/v3 => ./../../pkg 25 | ) 26 | 27 | // Bad imports are sometimes causing attempts to pull that code. 28 | // This makes the error more explicit. 29 | replace ( 30 | go.etcd.io/etcd => ./FORBIDDEN_DEPENDENCY 31 | go.etcd.io/etcd/pkg/v3 => ./FORBIDDED_DEPENDENCY 32 | go.etcd.io/etcd/tests/v3 => ./FORBIDDEN_DEPENDENCY 33 | go.etcd.io/etcd/v3 => ./FORBIDDEN_DEPENDENCY 34 | ) 35 | -------------------------------------------------------------------------------- /client/internal/v2/main_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 | package client_test 16 | 17 | import ( 18 | "testing" 19 | 20 | "go.etcd.io/etcd/client/pkg/v3/testutil" 21 | ) 22 | 23 | func TestMain(m *testing.M) { 24 | testutil.MustTestMainWithLeakDetection(m) 25 | } 26 | -------------------------------------------------------------------------------- /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 | 17 | package fileutil 18 | 19 | import "os" 20 | 21 | const ( 22 | // PrivateDirMode grants owner to make/remove files inside the directory. 23 | PrivateDirMode = 0o700 24 | ) 25 | 26 | // OpenDir opens a directory for syncing. 27 | func OpenDir(path string) (*os.File, error) { return os.Open(path) } 28 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 ErrLocked = errors.New("fileutil: file already locked") 23 | 24 | type LockedFile struct{ *os.File } 25 | -------------------------------------------------------------------------------- /client/pkg/fileutil/lock_linux_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 linux 16 | 17 | package fileutil 18 | 19 | import "testing" 20 | 21 | // TestLockAndUnlockSyscallFlock tests the fallback flock using the flock syscall. 22 | func TestLockAndUnlockSyscallFlock(t *testing.T) { 23 | oldTryLock, oldLock := linuxTryLockFile, linuxLockFile 24 | defer func() { 25 | linuxTryLockFile, linuxLockFile = oldTryLock, oldLock 26 | }() 27 | linuxTryLockFile, linuxLockFile = flockTryLockFile, flockLockFile 28 | TestLockAndUnlock(t) 29 | } 30 | -------------------------------------------------------------------------------- /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 | 17 | package fileutil 18 | 19 | import ( 20 | "os" 21 | ) 22 | 23 | func TryLockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) { 24 | return flockTryLockFile(path, flag, perm) 25 | } 26 | 27 | func LockFile(path string, flag int, perm os.FileMode) (*LockedFile, error) { 28 | return flockLockFile(path, flag, perm) 29 | } 30 | -------------------------------------------------------------------------------- /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 | 17 | package fileutil 18 | 19 | import "os" 20 | 21 | func preallocExtend(f *os.File, sizeInBytes int64) error { 22 | return preallocExtendTrunc(f, sizeInBytes) 23 | } 24 | 25 | func preallocFixed(f *os.File, sizeInBytes int64) error { return nil } 26 | -------------------------------------------------------------------------------- /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 | 17 | package fileutil 18 | 19 | import "os" 20 | 21 | // Fsync is a wrapper around file.Sync(). Special handling is needed on darwin platform. 22 | func Fsync(f *os.File) error { 23 | return f.Sync() 24 | } 25 | 26 | // Fdatasync is a wrapper around file.Sync(). Special handling is needed on linux platform. 27 | func Fdatasync(f *os.File) error { 28 | return f.Sync() 29 | } 30 | -------------------------------------------------------------------------------- /client/pkg/fileutil/sync_linux.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 | 17 | package fileutil 18 | 19 | import ( 20 | "os" 21 | "syscall" 22 | ) 23 | 24 | // Fsync is a wrapper around file.Sync(). Special handling is needed on darwin platform. 25 | func Fsync(f *os.File) error { 26 | return f.Sync() 27 | } 28 | 29 | // Fdatasync is similar to fsync(), but does not flush modified metadata 30 | // unless that metadata is needed in order to allow a subsequent data retrieval 31 | // to be correctly handled. 32 | func Fdatasync(f *os.File) error { 33 | return syscall.Fdatasync(int(f.Fd())) 34 | } 35 | -------------------------------------------------------------------------------- /client/pkg/go.mod: -------------------------------------------------------------------------------- 1 | module go.etcd.io/etcd/client/pkg/v3 2 | 3 | go 1.24 4 | 5 | toolchain go1.24.3 6 | 7 | require ( 8 | github.com/coreos/go-systemd/v22 v22.5.0 9 | github.com/stretchr/testify v1.10.0 10 | go.uber.org/zap v1.27.0 11 | golang.org/x/sys v0.33.0 12 | ) 13 | 14 | require ( 15 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect 16 | github.com/kr/pretty v0.3.1 // indirect 17 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect 18 | github.com/rogpeppe/go-internal v1.14.1 // indirect 19 | go.uber.org/multierr v1.11.0 // indirect 20 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect 21 | gopkg.in/yaml.v3 v3.0.1 // indirect 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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /client/pkg/pathutil/path_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 pathutil 16 | 17 | import "testing" 18 | 19 | func TestCanonicalURLPath(t *testing.T) { 20 | tests := []struct { 21 | p string 22 | wp string 23 | }{ 24 | {"/a", "/a"}, 25 | {"", "/"}, 26 | {"a", "/a"}, 27 | {"//a", "/a"}, 28 | {"/a/.", "/a"}, 29 | {"/a/..", "/"}, 30 | {"/a/", "/a/"}, 31 | {"/a//", "/a/"}, 32 | } 33 | for i, tt := range tests { 34 | if g := CanonicalURLPath(tt.p); g != tt.wp { 35 | t.Errorf("#%d: canonical path = %s, want %s", i, g, tt.wp) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /client/pkg/systemd/journal.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 16 | 17 | import "net" 18 | 19 | // DialJournal returns no error if the process can dial journal socket. 20 | // Returns an error if dial failed, which indicates journald is not available 21 | // (e.g. run embedded etcd as docker daemon). 22 | // Reference: https://github.com/coreos/go-systemd/blob/master/journal/journal.go. 23 | func DialJournal() error { 24 | conn, err := net.Dial("unixgram", "/run/systemd/journal/socket") 25 | if conn != nil { 26 | defer conn.Close() 27 | } 28 | return err 29 | } 30 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /client/pkg/transport/keepalive_listener_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 openbsd 16 | 17 | package transport 18 | 19 | import "time" 20 | 21 | // SetKeepAlivePeriod sets keepalive period 22 | func (l *keepAliveConn) SetKeepAlivePeriod(d time.Duration) error { 23 | // OpenBSD has no user-settable per-socket TCP keepalive options. 24 | // Refer to https://github.com/etcd-io/etcd/issues/15811. 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /client/pkg/transport/keepalive_listener_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 !openbsd 16 | 17 | package transport 18 | 19 | import "time" 20 | 21 | // SetKeepAlivePeriod sets keepalive period 22 | func (l *keepAliveConn) SetKeepAlivePeriod(d time.Duration) error { 23 | return l.TCPConn.SetKeepAlivePeriod(d) 24 | } 25 | -------------------------------------------------------------------------------- /client/pkg/transport/sockopt_solaris.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 | //go:build solaris 16 | 17 | package transport 18 | 19 | import ( 20 | "errors" 21 | "syscall" 22 | 23 | "golang.org/x/sys/unix" 24 | ) 25 | 26 | func setReusePort(network, address string, c syscall.RawConn) error { 27 | return errors.New("port reuse is not supported on Solaris") 28 | } 29 | 30 | func setReuseAddress(network, address string, conn syscall.RawConn) error { 31 | return conn.Control(func(fd uintptr) { 32 | syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEADDR, 1) 33 | }) 34 | } 35 | -------------------------------------------------------------------------------- /client/pkg/transport/sockopt_wasm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 wasm || js 16 | 17 | package transport 18 | 19 | import ( 20 | "errors" 21 | "syscall" 22 | ) 23 | 24 | func setReusePort(network, address string, c syscall.RawConn) error { 25 | return errors.New("port reuse is not supported on WASM") 26 | } 27 | 28 | func setReuseAddress(network, addr string, conn syscall.RawConn) error { 29 | return errors.New("address reuse is not supported on WASM") 30 | } 31 | -------------------------------------------------------------------------------- /client/pkg/transport/sockopt_windows.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 | //go:build windows 16 | 17 | package transport 18 | 19 | import ( 20 | "errors" 21 | "syscall" 22 | ) 23 | 24 | func setReusePort(network, address string, c syscall.RawConn) error { 25 | return errors.New("port reuse is not supported on Windows") 26 | } 27 | 28 | // Windows supports SO_REUSEADDR, but it may cause undefined behavior, as 29 | // there is no protection against port hijacking. 30 | func setReuseAddress(network, addr string, conn syscall.RawConn) error { 31 | return errors.New("address reuse is not supported on Windows") 32 | } 33 | -------------------------------------------------------------------------------- /client/pkg/transport/timeout_dialer.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 16 | 17 | import ( 18 | "net" 19 | "time" 20 | ) 21 | 22 | type rwTimeoutDialer struct { 23 | wtimeoutd time.Duration 24 | rdtimeoutd time.Duration 25 | net.Dialer 26 | } 27 | 28 | func (d *rwTimeoutDialer) Dial(network, address string) (net.Conn, error) { 29 | conn, err := d.Dialer.Dial(network, address) 30 | tconn := &timeoutConn{ 31 | readTimeout: d.rdtimeoutd, 32 | writeTimeout: d.wtimeoutd, 33 | Conn: conn, 34 | } 35 | return tconn, err 36 | } 37 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /client/v3/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/clientv3 5 | -------------------------------------------------------------------------------- /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 | "github.com/stretchr/testify/require" 22 | 23 | "go.etcd.io/etcd/api/v3/etcdserverpb" 24 | ) 25 | 26 | func TestCompactOp(t *testing.T) { 27 | req1 := OpCompact(100, WithCompactPhysical()).toRequest() 28 | req2 := &etcdserverpb.CompactionRequest{Revision: 100, Physical: true} 29 | require.Truef(t, reflect.DeepEqual(req1, req2), "expected %+v, got %+v", req2, req1) 30 | } 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /client/v3/concurrency/example_election_test.go: -------------------------------------------------------------------------------- 1 | ../../../tests/integration/clientv3/concurrency/example_election_test.go -------------------------------------------------------------------------------- /client/v3/concurrency/example_mutex_test.go: -------------------------------------------------------------------------------- 1 | ../../../tests/integration/clientv3/concurrency/example_mutex_test.go -------------------------------------------------------------------------------- /client/v3/concurrency/example_stm_test.go: -------------------------------------------------------------------------------- 1 | ../../../tests/integration/clientv3/concurrency/example_stm_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_kv_test.go: -------------------------------------------------------------------------------- 1 | ../../tests/integration/clientv3/examples/example_kv_test.go -------------------------------------------------------------------------------- /client/v3/example_lease_test.go: -------------------------------------------------------------------------------- 1 | ../../tests/integration/clientv3/examples/example_lease_test.go -------------------------------------------------------------------------------- /client/v3/example_maintenance_test.go: -------------------------------------------------------------------------------- 1 | ../../tests/integration/clientv3/examples/example_maintenance_test.go -------------------------------------------------------------------------------- /client/v3/example_metrics_test.go: -------------------------------------------------------------------------------- 1 | ../../tests/integration/clientv3/examples/example_metrics_test.go -------------------------------------------------------------------------------- /client/v3/example_test.go: -------------------------------------------------------------------------------- 1 | ../../tests/integration/clientv3/examples/example_test.go -------------------------------------------------------------------------------- /client/v3/example_watch_test.go: -------------------------------------------------------------------------------- 1 | ../../tests/integration/clientv3/examples/example_watch_test.go -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 ( 18 | SortTarget int 19 | SortOrder int 20 | ) 21 | 22 | const ( 23 | SortNone SortOrder = iota 24 | SortAscend 25 | SortDescend 26 | ) 27 | 28 | const ( 29 | SortByKey SortTarget = iota 30 | SortByVersion 31 | SortByCreateRevision 32 | SortByModRevision 33 | SortByValue 34 | ) 35 | 36 | type SortOption struct { 37 | Target SortTarget 38 | Order SortOrder 39 | } 40 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /contrib/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/contrib 5 | -------------------------------------------------------------------------------- /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 | * [lock](lock) - example addressing the expired lease problem of distributed locking with etcd 6 | * [mixin](mixin) - customisable set of Grafana dashboard and Prometheus alerts for etcd 7 | * [raftexample](raftexample) - an example distributed key-value store using raft 8 | * [systemd](systemd) - an example unit file for deploying etcd on systemd-based distributions 9 | * [systemd/etcd3-multinode](systemd/etcd3-multinode) - multi-node cluster setup with systemd 10 | -------------------------------------------------------------------------------- /contrib/lock/client/.gitignore: -------------------------------------------------------------------------------- 1 | client -------------------------------------------------------------------------------- /contrib/lock/storage/.gitignore: -------------------------------------------------------------------------------- 1 | storage -------------------------------------------------------------------------------- /contrib/mixin/.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | -------------------------------------------------------------------------------- /contrib/mixin/.lint: -------------------------------------------------------------------------------- 1 | --- 2 | exclusions: 3 | template-instance-rule: 4 | reason: The mixin only uses `instance` for alerts, and `cluster` for dashboard queries 5 | template-job-rule: 6 | reason: The dashboards use 'cluster' label as selector, rather than 'job' 7 | target-job-rule: 8 | reason: The mixin uses 'cluster' instead of 'job' 9 | target-instance-rule: 10 | reason: The mixin only uses `instance` for alerts, and `cluster` for dashboard queries 11 | alert-name-camelcase: 12 | reason: etcd is spelled all lowercase, meaning all alert name start with a lowercase 13 | alert-summary-style: 14 | reason: etcd is spelled all lowercase, meaning summaries starting with 'etcd' are still valid 15 | panel-units-rule: 16 | reason: Stat panels have no unit, and some panels use custom unit or text 17 | panel-title-description-rule: 18 | reason: Suppress noisy linting rule until we can address minor tech debt like this 19 | -------------------------------------------------------------------------------- /contrib/mixin/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: tools manifests test clean jb_install 2 | 3 | OS := linux 4 | ARCH ?= amd64 5 | PROMETHEUS_VERSION := 2.33.1 6 | 7 | tools: 8 | go install github.com/google/go-jsonnet/cmd/jsonnet@latest 9 | go install github.com/brancz/gojsontoyaml@latest 10 | go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest 11 | wget -qO- "https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.${OS}-${ARCH}.tar.gz" |\ 12 | tar xvz --strip-components=1 -C "$$(go env GOPATH)/bin" prometheus-${PROMETHEUS_VERSION}.${OS}-${ARCH}/promtool 13 | 14 | manifests: manifests/etcd-prometheusRules.yaml 15 | 16 | manifests/etcd-prometheusRules.yaml: 17 | mkdir -p manifests 18 | jsonnet -e '(import "mixin.libsonnet").prometheusAlerts' | gojsontoyaml > manifests/etcd-prometheusRules.yaml 19 | 20 | test: manifests/etcd-prometheusRules.yaml 21 | promtool test rules test.yaml 22 | 23 | jb_install: 24 | jb install 25 | 26 | clean: 27 | rm -rf manifests/*.yaml 28 | -------------------------------------------------------------------------------- /contrib/mixin/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/observability 5 | -------------------------------------------------------------------------------- /contrib/mixin/dashboards/dashboards.libsonnet: -------------------------------------------------------------------------------- 1 | (import "etcd.libsonnet") + 2 | (import "etcd-grafana7x.libsonnet") 3 | -------------------------------------------------------------------------------- /contrib/mixin/dashboards/g.libsonnet: -------------------------------------------------------------------------------- 1 | import 'github.com/grafana/grafonnet/gen/grafonnet-v10.0.0/main.libsonnet' 2 | -------------------------------------------------------------------------------- /contrib/mixin/dashboards/variables.libsonnet: -------------------------------------------------------------------------------- 1 | // variables.libsonnet 2 | local g = import './g.libsonnet'; 3 | local var = g.dashboard.variable; 4 | 5 | 6 | function(config) { 7 | datasource: 8 | var.datasource.new('datasource', 'prometheus') 9 | + var.datasource.generalOptions.withLabel('Data Source'), 10 | 11 | cluster: 12 | var.query.new('cluster') 13 | + var.query.generalOptions.withLabel('cluster') 14 | + var.query.withDatasourceFromVariable(self.datasource) 15 | + { refresh: config.dashboard_var_refresh } 16 | + var.query.queryTypes.withLabelValues( 17 | config.clusterLabel, 18 | 'etcd_server_has_leader{%s}' % [config.etcd_selector] 19 | ), 20 | 21 | } 22 | -------------------------------------------------------------------------------- /contrib/mixin/jsonnetfile.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "dependencies": [ 4 | { 5 | "source": { 6 | "git": { 7 | "remote": "https://github.com/grafana/grafonnet.git", 8 | "subdir": "gen/grafonnet-v10.0.0" 9 | } 10 | }, 11 | "version": "main" 12 | } 13 | ], 14 | "legacyImports": true 15 | } -------------------------------------------------------------------------------- /contrib/mixin/jsonnetfile.lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "dependencies": [ 4 | { 5 | "source": { 6 | "git": { 7 | "remote": "https://github.com/grafana/grafonnet.git", 8 | "subdir": "gen/grafonnet-v10.0.0" 9 | } 10 | }, 11 | "version": "e85299323fd8808187d30865cc5c7a38a347399a", 12 | "sum": "uJCTMGtY/7c5HSLQ7UQD38TOPmuSYrIKLIKmdSF/Htk=" 13 | }, 14 | { 15 | "source": { 16 | "git": { 17 | "remote": "https://github.com/jsonnet-libs/docsonnet.git", 18 | "subdir": "doc-util" 19 | } 20 | }, 21 | "version": "fd8de9039b3c06da77d635a3a8289809a5bfb542", 22 | "sum": "mFebrE9fhyAKW4zbnidcjVFupziN5LPA/Z7ii94uCzs=" 23 | }, 24 | { 25 | "source": { 26 | "git": { 27 | "remote": "https://github.com/jsonnet-libs/xtd.git", 28 | "subdir": "" 29 | } 30 | }, 31 | "version": "0256a910ac71f0f842696d7bca0bf01ea77eb654", 32 | "sum": "zBOpb1oTNvXdq9RF6yzTHill5r1YTJLBBoqyx4JYtAg=" 33 | } 34 | ], 35 | "legacyImports": false 36 | } 37 | -------------------------------------------------------------------------------- /contrib/mixin/mixin.libsonnet: -------------------------------------------------------------------------------- 1 | (import './config.libsonnet') + 2 | (import './dashboards/dashboards.libsonnet') + 3 | (import './alerts/alerts.libsonnet') 4 | -------------------------------------------------------------------------------- /contrib/raftexample/Procfile: -------------------------------------------------------------------------------- 1 | # Use goreman to run `go install github.com/mattn/goreman@latest` 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /etcdctl/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/etcdctl 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /etcdctl/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 | // etcdctl is a command line application that controls etcd. 16 | package main 17 | 18 | import ( 19 | "go.etcd.io/etcd/etcdctl/v3/ctlv3" 20 | ) 21 | 22 | func main() { 23 | ctlv3.MustStart() 24 | } 25 | -------------------------------------------------------------------------------- /etcdutl/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/etcdutl 5 | -------------------------------------------------------------------------------- /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 | func (s *simplePrinter) DBStatus(ds snapshot.Status) { 27 | _, rows := makeDBStatusTable(ds) 28 | for _, row := range rows { 29 | fmt.Println(strings.Join(row, ", ")) 30 | } 31 | } 32 | 33 | func (s *simplePrinter) DBHashKV(ds HashKV) { 34 | _, rows := makeDBHashKVTable(ds) 35 | for _, row := range rows { 36 | fmt.Println(strings.Join(row, ", ")) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /hack/README.md: -------------------------------------------------------------------------------- 1 | Various hacks that are used by developers. 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /hack/insta-discovery/README.md: -------------------------------------------------------------------------------- 1 | Starts a cluster via the discovery service locally. Useful for testing. 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /hack/kubernetes-deploy/vulcand.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | labels: 6 | app: vulcand 7 | name: vulcand 8 | spec: 9 | containers: 10 | - command: 11 | - /go/bin/vulcand 12 | - -apiInterface=0.0.0.0 13 | - --etcd=http://etcd-client:2379 14 | image: mailgun/vulcand:v0.8.0-beta.2 15 | name: vulcand 16 | ports: 17 | - containerPort: 8081 18 | name: api 19 | protocol: TCP 20 | - containerPort: 8082 21 | name: server 22 | protocol: TCP 23 | restartPolicy: Always 24 | -------------------------------------------------------------------------------- /hack/patch/README.md: -------------------------------------------------------------------------------- 1 | # ./hack/patch/cherrypick.sh 2 | 3 | Handles cherry-picks of PR(s) from etcd main to a stable etcd release branch automatically. 4 | 5 | ## Setup 6 | 7 | Set the `UPSTREAM_REMOTE` and `FORK_REMOTE` environment variables. 8 | `UPSTREAM_REMOTE` should be set to git remote name of `github.com/etcd-io/etcd`, 9 | and `FORK_REMOTE` should be set to the git remote name of the forked etcd 10 | repo (`github.com/${github-username}/etcd`). Use `git remote -v` to 11 | look up the git remote names. If etcd has not been forked, create 12 | one on github.com and register it locally with `git remote add ...`. 13 | 14 | 15 | ``` 16 | export UPSTREAM_REMOTE=upstream 17 | export FORK_REMOTE=origin 18 | export GITHUB_USER=${github-username} 19 | ``` 20 | 21 | Next, install hub from https://github.com/github/hub 22 | 23 | ## Usage 24 | 25 | To cherry pick PR 12345 onto release-3.2 and propose is as a PR, run: 26 | 27 | ```sh 28 | ./hack/patch/cherrypick.sh ${UPSTREAM_REMOTE}/release-3.2 12345 29 | ``` 30 | 31 | To cherry pick 12345 then 56789 and propose them togther as a single PR, run: 32 | 33 | ``` 34 | ./hack/patch/cherrypick.sh ${UPSTREAM_REMOTE}/release-3.2 12345 56789 35 | ``` 36 | 37 | 38 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /logos/etcd-glyph-color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/logos/etcd-glyph-color.png -------------------------------------------------------------------------------- /logos/etcd-horizontal-bw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/logos/etcd-horizontal-bw.png -------------------------------------------------------------------------------- /logos/etcd-horizontal-color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/logos/etcd-horizontal-color.png -------------------------------------------------------------------------------- /logos/etcd-offset-bw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/logos/etcd-offset-bw.png -------------------------------------------------------------------------------- /logos/etcd-offset-color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/logos/etcd-offset-color.png -------------------------------------------------------------------------------- /logos/etcd-stacked-bw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/logos/etcd-stacked-bw.png -------------------------------------------------------------------------------- /logos/etcd-stacked-color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/logos/etcd-stacked-color.png -------------------------------------------------------------------------------- /logos/etcd-xkcd-2347.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/logos/etcd-xkcd-2347.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-01-insertion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/pkg/adt/img/red-black-tree-01-insertion.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-02-delete-514.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/pkg/adt/img/red-black-tree-02-delete-514.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-03-delete-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/pkg/adt/img/red-black-tree-03-delete-11.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-04-delete-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/pkg/adt/img/red-black-tree-04-delete-11.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-05-delete-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/pkg/adt/img/red-black-tree-05-delete-11.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-06-delete-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/pkg/adt/img/red-black-tree-06-delete-11.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-07-delete-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/pkg/adt/img/red-black-tree-07-delete-11.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-08-delete-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/pkg/adt/img/red-black-tree-08-delete-11.png -------------------------------------------------------------------------------- /pkg/adt/img/red-black-tree-09-delete-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/pkg/adt/img/red-black-tree-09-delete-11.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /pkg/cpuutil/endian.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 16 | 17 | import ( 18 | "encoding/binary" 19 | "unsafe" 20 | ) 21 | 22 | const intWidth = int(unsafe.Sizeof(0)) 23 | 24 | var byteOrder binary.ByteOrder 25 | 26 | // ByteOrder returns the byte order for the CPU's native endianness. 27 | func ByteOrder() binary.ByteOrder { return byteOrder } 28 | 29 | func init() { 30 | i := 0x1 31 | if v := (*[intWidth]byte)(unsafe.Pointer(&i)); v[0] == 0 { 32 | byteOrder = binary.BigEndian 33 | } else { 34 | byteOrder = binary.LittleEndian 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /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/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 | "github.com/stretchr/testify/assert" 22 | "github.com/stretchr/testify/require" 23 | ) 24 | 25 | func TestLimitedBufferReaderRead(t *testing.T) { 26 | buf := bytes.NewBuffer(make([]byte, 10)) 27 | ln := 1 28 | lr := NewLimitedBufferReader(buf, ln) 29 | n, err := lr.Read(make([]byte, 10)) 30 | require.NoErrorf(t, err, "unexpected read error: %v", err) 31 | assert.Equalf(t, n, ln, "len(data read) = %d, want %d", n, ln) 32 | } 33 | -------------------------------------------------------------------------------- /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/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 | 17 | package netutil 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/stretchr/testify/require" 23 | ) 24 | 25 | func TestGetDefaultInterface(t *testing.T) { 26 | ifc, err := GetDefaultInterfaces() 27 | require.NoError(t, err) 28 | t.Logf("default network interfaces: %+v\n", ifc) 29 | } 30 | 31 | func TestGetDefaultHost(t *testing.T) { 32 | ip, err := GetDefaultHost() 33 | require.NoError(t, err) 34 | t.Logf("default ip: %v", ip) 35 | } 36 | -------------------------------------------------------------------------------- /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 | 17 | package osutil 18 | 19 | import ( 20 | "os" 21 | 22 | "go.uber.org/zap" 23 | ) 24 | 25 | type InterruptHandler func() 26 | 27 | // RegisterInterruptHandler is a no-op on windows 28 | func RegisterInterruptHandler(h InterruptHandler) {} 29 | 30 | // HandleInterrupts is a no-op on windows 31 | func HandleInterrupts(*zap.Logger) {} 32 | 33 | // Exit calls os.Exit 34 | func Exit(code int) { 35 | os.Exit(code) 36 | } 37 | -------------------------------------------------------------------------------- /pkg/osutil/osutil.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 osutil implements operating system-related utility functions. 16 | package osutil 17 | 18 | // support to override setting SIG_DFL so tests don't terminate early 19 | var setDflSignal = dflSignal 20 | -------------------------------------------------------------------------------- /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 16 | 17 | package osutil 18 | 19 | import "syscall" 20 | 21 | func dflSignal(sig syscall.Signal) { /* nop */ } 22 | -------------------------------------------------------------------------------- /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 16 | 17 | package osutil 18 | 19 | import ( 20 | "syscall" 21 | "unsafe" 22 | ) 23 | 24 | // dflSignal sets the given signal to SIG_DFL 25 | func dflSignal(sig syscall.Signal) { 26 | // clearing out the sigact sets the signal to SIG_DFL 27 | var sigactBuf [32]uint64 28 | ptr := unsafe.Pointer(&sigactBuf) 29 | syscall.Syscall6(uintptr(syscall.SYS_RT_SIGACTION), uintptr(sig), uintptr(ptr), 0, 8, 0, 0) 30 | } 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /pkg/proxy/fixtures/gencerts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -euo pipefail 4 | 5 | if ! [[ "$0" =~ "./gencerts.sh" ]]; then 6 | echo "must be run from 'fixtures'" 7 | exit 255 8 | fi 9 | 10 | if ! command -v cfssl; then 11 | echo "cfssl is not installed" 12 | echo 'use: bash -c "cd ../../../tools/mod; go install github.com/cloudflare/cfssl/cmd/cfssl"' 13 | exit 255 14 | fi 15 | 16 | if ! command -v cfssljson; then 17 | echo "cfssljson is not installed" 18 | echo 'use: bash -c "cd ../../../tools/mod; go install github.com/cloudflare/cfssl/cmd/cfssljson"' 19 | exit 255 20 | fi 21 | 22 | cfssl gencert --initca=true ./ca-csr.json | cfssljson --bare ./ca 23 | mv ca.pem ca.crt 24 | openssl x509 -in ca.crt -noout -text 25 | 26 | # generate DNS: localhost, IP: 127.0.0.1, CN: example.com certificates 27 | cfssl gencert \ 28 | --ca ./ca.crt \ 29 | --ca-key ./ca-key.pem \ 30 | --config ./gencert.json \ 31 | ./server-ca-csr.json | cfssljson --bare ./server 32 | mv server.pem server.crt 33 | mv server-key.pem server.key.insecure 34 | 35 | rm -f *.csr *.pem *.stderr *.txt 36 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | 17 | package runtime 18 | 19 | import ( 20 | "fmt" 21 | "runtime" 22 | ) 23 | 24 | func FDLimit() (uint64, error) { 25 | return 0, fmt.Errorf("cannot get FDLimit on %s", runtime.GOOS) 26 | } 27 | 28 | func FDUsage() (uint64, error) { 29 | return 0, fmt.Errorf("cannot get FDUsage on %s", runtime.GOOS) 30 | } 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | "sort" 19 | "testing" 20 | 21 | "github.com/stretchr/testify/require" 22 | ) 23 | 24 | func TestUniqueStrings(t *testing.T) { 25 | ss := UniqueStrings(10, 50) 26 | sort.Strings(ss) 27 | for i := 1; i < len(ss); i++ { 28 | require.NotEqualf(t, ss[i-1], ss[i], "ss[i-1] %q == ss[i] %q", ss[i-1], ss[i]) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /scripts/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | approvers: 4 | - ivanvc # Ivan Valdes 5 | -------------------------------------------------------------------------------- /scripts/README: -------------------------------------------------------------------------------- 1 | scripts for etcd development -------------------------------------------------------------------------------- /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 -euo pipefail 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.sh "${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.sh "${VERSION}" 30 | done 31 | popd >/dev/null 32 | -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This scripts build the etcd binaries 4 | # To build the tools, run `build_tools.sh` 5 | 6 | set -euo pipefail 7 | 8 | source ./scripts/test_lib.sh 9 | source ./scripts/build_lib.sh 10 | 11 | # only build when called directly, not sourced 12 | if echo "$0" | grep -E "build(.sh)?$" >/dev/null; then 13 | run_build etcd_build 14 | fi 15 | -------------------------------------------------------------------------------- /scripts/build_tools.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | source ./scripts/test_lib.sh 6 | source ./scripts/build_lib.sh 7 | 8 | run_build tools_build 9 | -------------------------------------------------------------------------------- /scripts/codecov_upload.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Script used to collect and upload test coverage. 4 | 5 | set -o pipefail 6 | 7 | # We try to upload whatever we have: 8 | mkdir -p bin 9 | curl -sf -o ./bin/codecov.sh https://codecov.io/bash 10 | 11 | bash ./bin/codecov.sh -f "${COVERDIR}/all.coverprofile" \ 12 | -cF all \ 13 | -C "${PULL_PULL_SHA:-${PULL_BASE_SHA}}" \ 14 | -r "${REPO_OWNER}/${REPO_NAME}" \ 15 | -P "${PULL_NUMBER}" \ 16 | -b "${BUILD_ID}" \ 17 | -B "${PULL_BASE_REF}" \ 18 | -N "${PULL_BASE_SHA}" 19 | -------------------------------------------------------------------------------- /scripts/fix.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 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 | bash_ws_fix || exit 2 37 | 38 | log_success -e "\\nSUCCESS: etcd code is fixed :)" 39 | -------------------------------------------------------------------------------- /scripts/fuzzing.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | source ./scripts/test_lib.sh 6 | 7 | GO_CMD="go" 8 | fuzz_time=${FUZZ_TIME:-"300s"} 9 | target_path=${TARGET_PATH:-"./server/etcdserver/api/v3rpc"} 10 | TARGETS="FuzzTxnRangeRequest FuzzTxnPutRequest FuzzTxnDeleteRangeRequest" 11 | 12 | 13 | for target in ${TARGETS}; do 14 | log_callout -e "\\nExecuting fuzzing with target ${target} in $target_path with a timeout of $fuzz_time\\n" 15 | run pushd "${target_path}" 16 | $GO_CMD test -fuzz "${target}" -fuzztime "${fuzz_time}" 17 | run popd 18 | log_success -e "\\COMPLETED: fuzzing with target $target in $target_path \\n" 19 | done 20 | 21 | -------------------------------------------------------------------------------- /scripts/measure-testgrid-flakiness.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Measures test flakiness and create issues for flaky tests 3 | 4 | set -euo pipefail 5 | 6 | if [[ -z ${GITHUB_TOKEN:-} ]] 7 | then 8 | echo "Please set the \$GITHUB_TOKEN environment variable for the script to work" 9 | exit 1 10 | fi 11 | 12 | pushd ./tools/testgrid-analysis 13 | # ci-etcd-e2e-amd64 and ci-etcd-unit-test-amd64 runs 6 times a day. Keeping a rolling window of 14 days. 14 | go run main.go flaky --create-issue --dashboard=sig-etcd-periodics --tab=ci-etcd-e2e-amd64 --max-days=14 15 | go run main.go flaky --create-issue --dashboard=sig-etcd-periodics --tab=ci-etcd-unit-test-amd64 --max-days=14 16 | 17 | # do not create issues for presubmit tests 18 | go run main.go flaky --dashboard=sig-etcd-presubmits --tab=pull-etcd-e2e-amd64 19 | go run main.go flaky --dashboard=sig-etcd-presubmits --tab=pull-etcd-unit-test 20 | 21 | popd 22 | -------------------------------------------------------------------------------- /scripts/sync_go_toolchain_directive.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This script looks at the version present in the .go-version file and treats 4 | # that to be the value of the toolchain directive that go should use. It then 5 | # updates the toolchain directives of all go.mod files to reflect this version. 6 | # 7 | # We do this to ensure that .go-version acts as the source of truth for go versions. 8 | 9 | set -euo pipefail 10 | 11 | source ./scripts/test_lib.sh 12 | 13 | TARGET_GO_VERSION="${TARGET_GO_VERSION:-"$(cat "${ETCD_ROOT_DIR}/.go-version")"}" 14 | find . -name 'go.mod' -exec go mod edit -toolchain=go"${TARGET_GO_VERSION}" {} \; 15 | -------------------------------------------------------------------------------- /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 | set -euo pipefail 13 | 14 | source ./scripts/test_lib.sh 15 | 16 | mod="$1" 17 | ver="$2" 18 | 19 | function maybe_update_module { 20 | run go mod tidy 21 | 22 | deps=$(go list -f '{{if not .Indirect}}{{if .Version}}{{.Path}},{{.Version}}{{end}}{{end}}' -m all) 23 | if [[ "$deps" == *"${mod}"* ]]; then 24 | if [ -z "${ver}" ]; then 25 | run go get "${mod}" 26 | else 27 | run go get "${mod}@${ver}" 28 | fi 29 | fi 30 | } 31 | 32 | go mod tidy 33 | run_for_modules maybe_update_module 34 | -------------------------------------------------------------------------------- /scripts/update_proto_annotations.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Updates etcd_version_annotations.txt based on state of annotations in proto files. 3 | # Developers can run this script to avoid manually updating etcd_version_annotations.txt. 4 | # Before running this script please ensure that fields/messages that you added are annotated with next etcd version. 5 | 6 | set -o errexit 7 | set -o nounset 8 | set -o pipefail 9 | 10 | tmpfile=$(mktemp) 11 | go run ./tools/proto-annotations/main.go --annotation etcd_version > "${tmpfile}" 12 | mv "${tmpfile}" ./scripts/etcd_version_annotations.txt 13 | -------------------------------------------------------------------------------- /scripts/verify_genproto.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # This scripts is automatically run by CI to prevent pull requests missing running genproto.sh 3 | # after changing *.proto file. 4 | 5 | set -o errexit 6 | set -o nounset 7 | set -o pipefail 8 | 9 | tmpWorkDir=$(mktemp -d -t 'twd.XXXXXX') 10 | mkdir "$tmpWorkDir/etcd" 11 | tmpWorkDir="$tmpWorkDir/etcd" 12 | cp -r . "$tmpWorkDir" 13 | pushd "$tmpWorkDir" 14 | git add -A 15 | git commit -m init || true # maybe fail because nothing to commit 16 | ./scripts/genproto.sh 17 | diff=$(git diff --numstat | awk '{print $3}') 18 | popd 19 | if [ -z "$diff" ]; then 20 | echo "PASSED genproto-verification!" 21 | exit 0 22 | fi 23 | echo "Failed genproto-verification!" >&2 24 | printf "* Found changed files:\n%s\n" "$diff" >&2 25 | echo "* Please rerun genproto.sh after changing *.proto file" >&2 26 | echo "* Run ./scripts/genproto.sh" >&2 27 | exit 1 28 | -------------------------------------------------------------------------------- /scripts/verify_proto_annotations.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Verifies proto annotations to ensure all new proto fields and messages are annotated by comparing it with etcd_version_annotations.txt file. 3 | # This scripts is automatically run by CI to prevent pull requests missing adding a proto annotation. 4 | 5 | set -o errexit 6 | set -o nounset 7 | set -o pipefail 8 | 9 | tmpfile=$(mktemp) 10 | go run ./tools/proto-annotations/main.go --annotation=etcd_version > "${tmpfile}" 11 | if diff -u ./scripts/etcd_version_annotations.txt "${tmpfile}"; then 12 | echo "PASSED proto-annotations verification!" 13 | exit 0 14 | fi 15 | echo "Failed proto-annotations-verification!" >&2 16 | echo "If you are adding new proto fields/messages that will be included in raft log:" >&2 17 | echo "* Please add etcd_version annotation in *.proto file with next etcd version" >&2 18 | echo "* Run ./scripts/genproto.sh" >&2 19 | echo "* Run ./scripts/update_proto_annotations.sh" >&2 20 | exit 1 21 | -------------------------------------------------------------------------------- /security/FUZZING_AUDIT_2022.PDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/security/FUZZING_AUDIT_2022.PDF -------------------------------------------------------------------------------- /security/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/security 5 | -------------------------------------------------------------------------------- /security/SECURITY_AUDIT.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/security/SECURITY_AUDIT.pdf -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /server/embed/config_logging_journal_unix.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 | 17 | package embed 18 | 19 | import ( 20 | "fmt" 21 | "os" 22 | 23 | "go.uber.org/zap/zapcore" 24 | 25 | "go.etcd.io/etcd/client/pkg/v3/logutil" 26 | ) 27 | 28 | // use stderr as fallback 29 | func getJournalWriteSyncer() (zapcore.WriteSyncer, error) { 30 | jw, err := logutil.NewJournalWriter(os.Stderr) 31 | if err != nil { 32 | return nil, fmt.Errorf("can't find journal (%w)", err) 33 | } 34 | return zapcore.AddSync(jw), nil 35 | } 36 | -------------------------------------------------------------------------------- /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 | 17 | package embed 18 | 19 | import ( 20 | "os" 21 | 22 | "go.uber.org/zap/zapcore" 23 | ) 24 | 25 | func getJournalWriteSyncer() (zapcore.WriteSyncer, error) { 26 | return zapcore.AddSync(os.Stderr), nil 27 | } 28 | -------------------------------------------------------------------------------- /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/storage/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/etcdhttp/metrics.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 16 | 17 | import ( 18 | "net/http" 19 | 20 | "github.com/prometheus/client_golang/prometheus/promhttp" 21 | ) 22 | 23 | const ( 24 | PathMetrics = "/metrics" 25 | PathProxyMetrics = "/proxy/metrics" 26 | ) 27 | 28 | // HandleMetrics registers prometheus handler on '/metrics'. 29 | func HandleMetrics(mux *http.ServeMux) { 30 | mux.Handle(PathMetrics, promhttp.Handler()) 31 | } 32 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 raft pkg. 16 | package rafthttp 17 | -------------------------------------------------------------------------------- /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/etcdserver/api/snap/snappb/snap.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package snappb; 3 | 4 | import "gogoproto/gogo.proto"; 5 | 6 | option go_package = "go.etcd.io/etcd/server/v3/etcdserver/api/snap/snappb"; 7 | 8 | option (gogoproto.marshaler_all) = true; 9 | option (gogoproto.sizer_all) = true; 10 | option (gogoproto.unmarshaler_all) = true; 11 | option (gogoproto.goproto_getters_all) = false; 12 | 13 | message snapshot { 14 | optional uint32 crc = 1 [(gogoproto.nullable) = false]; 15 | optional bytes data = 2; 16 | } 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/etcdserver/api/v3rpc/codec.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 v3rpc 16 | 17 | import "github.com/golang/protobuf/proto" 18 | 19 | type codec struct{} 20 | 21 | func (c *codec) Marshal(v any) ([]byte, error) { 22 | b, err := proto.Marshal(v.(proto.Message)) 23 | sentBytes.Add(float64(len(b))) 24 | return b, err 25 | } 26 | 27 | func (c *codec) Unmarshal(data []byte, v any) error { 28 | receivedBytes.Add(float64(len(data))) 29 | return proto.Unmarshal(data, v.(proto.Message)) 30 | } 31 | 32 | func (c *codec) String() string { 33 | return "proto" 34 | } 35 | -------------------------------------------------------------------------------- /server/etcdserver/apply/metrics.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 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 apply 16 | 17 | import "github.com/prometheus/client_golang/prometheus" 18 | 19 | var alarms = prometheus.NewGaugeVec( 20 | prometheus.GaugeOpts{ 21 | Namespace: "etcd_debugging", 22 | Subsystem: "server", 23 | Name: "alarms", 24 | Help: "Alarms for every member in cluster. 1 for 'server_id' label with current ID. 2 for 'alarm_type' label with type of this alarm", 25 | }, 26 | []string{"server_id", "alarm_type"}, 27 | ) 28 | 29 | func init() { 30 | prometheus.MustRegister(alarms) 31 | } 32 | -------------------------------------------------------------------------------- /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/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/etcdserver/v2_server.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 etcdserver 16 | 17 | import ( 18 | pb "go.etcd.io/etcd/api/v3/etcdserverpb" 19 | ) 20 | 21 | type RequestV2 pb.Request 22 | 23 | func (r *RequestV2) String() string { 24 | rpb := pb.Request(*r) 25 | return rpb.String() 26 | } 27 | -------------------------------------------------------------------------------- /server/etcdserver/version/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 version provides functions for getting/saving storage version. 16 | package version 17 | -------------------------------------------------------------------------------- /server/etcdserver/version/errors.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 version 16 | 17 | import "errors" 18 | 19 | var ( 20 | ErrInvalidDowngradeTargetVersion = errors.New("etcdserver: invalid downgrade target version") 21 | ErrDowngradeInProcess = errors.New("etcdserver: cluster has a downgrade job in progress") 22 | ErrNoInflightDowngrade = errors.New("etcdserver: no inflight downgrade job") 23 | ) 24 | -------------------------------------------------------------------------------- /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/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/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 go_package = "go.etcd.io/etcd/server/v3/lease/leasepb;leasepb"; 8 | 9 | option (gogoproto.marshaler_all) = true; 10 | option (gogoproto.sizer_all) = true; 11 | option (gogoproto.unmarshaler_all) = true; 12 | option (gogoproto.goproto_getters_all) = false; 13 | option (gogoproto.goproto_enum_prefix_all) = false; 14 | 15 | message Lease { 16 | int64 ID = 1; 17 | int64 TTL = 2; 18 | int64 RemainingTTL = 3; 19 | } 20 | 21 | message LeaseInternalRequest { 22 | etcdserverpb.LeaseTimeToLiveRequest LeaseTimeToLiveRequest = 1; 23 | } 24 | 25 | message LeaseInternalResponse { 26 | etcdserverpb.LeaseTimeToLiveResponse LeaseTimeToLiveResponse = 1; 27 | } 28 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /server/storage/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 | 17 | package backend 18 | 19 | import bolt "go.etcd.io/bbolt" 20 | 21 | var boltOpenOptions *bolt.Options 22 | 23 | func (bcfg *BackendConfig) mmapSize() int { return int(bcfg.MmapSize) } 24 | -------------------------------------------------------------------------------- /server/storage/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 | 17 | package backend 18 | 19 | import bolt "go.etcd.io/bbolt" 20 | 21 | var boltOpenOptions *bolt.Options = nil 22 | 23 | // setting mmap size != 0 on windows will allocate the entire 24 | // mmap size for the file, instead of growing it. So, force 0. 25 | 26 | func (bcfg *BackendConfig) mmapSize() int { return 0 } 27 | -------------------------------------------------------------------------------- /server/storage/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 | -------------------------------------------------------------------------------- /server/storage/backend/export_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 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 16 | 17 | import bolt "go.etcd.io/bbolt" 18 | 19 | func DbFromBackendForTest(b Backend) *bolt.DB { 20 | return b.(*backend).db 21 | } 22 | 23 | func DefragLimitForTest() int { 24 | return defragLimit 25 | } 26 | 27 | func CommitsForTest(b Backend) int64 { 28 | return b.(*backend).Commits() 29 | } 30 | -------------------------------------------------------------------------------- /server/storage/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/storage/metrics.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 storage 16 | 17 | import ( 18 | "github.com/prometheus/client_golang/prometheus" 19 | ) 20 | 21 | var quotaBackendBytes = prometheus.NewGauge(prometheus.GaugeOpts{ 22 | Namespace: "etcd", 23 | Subsystem: "server", 24 | Name: "quota_backend_bytes", 25 | Help: "Current backend storage quota size in bytes.", 26 | }) 27 | 28 | func init() { 29 | prometheus.MustRegister(quotaBackendBytes) 30 | } 31 | -------------------------------------------------------------------------------- /server/storage/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 | -------------------------------------------------------------------------------- /server/storage/wal/walpb/record.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package walpb; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "raftpb/raft.proto"; 6 | 7 | option go_package = "go.etcd.io/etcd/server/v3/storage/wal/walpb"; 8 | 9 | option (gogoproto.marshaler_all) = true; 10 | option (gogoproto.sizer_all) = true; 11 | option (gogoproto.unmarshaler_all) = true; 12 | option (gogoproto.goproto_getters_all) = false; 13 | 14 | message Record { 15 | optional int64 type = 1 [(gogoproto.nullable) = false]; 16 | optional uint32 crc = 2 [(gogoproto.nullable) = false]; 17 | optional bytes data = 3; 18 | } 19 | 20 | // Keep in sync with raftpb.SnapshotMetadata. 21 | message Snapshot { 22 | optional uint64 index = 1 [(gogoproto.nullable) = false]; 23 | optional uint64 term = 2 [(gogoproto.nullable) = false]; 24 | // Field populated since >=etcd-3.5.0. 25 | optional raftpb.ConfState conf_state = 3; 26 | } 27 | -------------------------------------------------------------------------------- /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/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/testing 5 | -------------------------------------------------------------------------------- /tests/antithesis/Dockerfile.config: -------------------------------------------------------------------------------- 1 | ARG GO_VERSION=1.24.3 2 | 3 | FROM golang:$GO_VERSION AS build 4 | RUN go install github.com/a8m/envsubst/cmd/envsubst@v1.4.3 5 | 6 | ARG REF 7 | COPY docker-compose.yml /docker-compose.yml.template 8 | RUN REF=${REF} cat /docker-compose.yml.template | envsubst > /docker-compose.yml 9 | 10 | FROM scratch 11 | COPY --from=build /docker-compose.yml /docker-compose.yml 12 | -------------------------------------------------------------------------------- /tests/antithesis/server/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG GO_VERSION=1.24.3 2 | ARG ARCH=amd64 3 | 4 | FROM golang:$GO_VERSION 5 | 6 | # cloning etcd 7 | ARG REF=main 8 | RUN git clone --depth=1 https://github.com/etcd-io/etcd.git --branch=${REF} /etcd 9 | WORKDIR /etcd 10 | 11 | # setup go mod 12 | RUN go mod download 13 | 14 | # install instrumentor 15 | RUN go get github.com/antithesishq/antithesis-sdk-go@a802e8810442e01d16b3e9df77d7ce3875e36e55 # v0.4.3 16 | RUN go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@a802e8810442e01d16b3e9df77d7ce3875e36e55 # v0.4.3 17 | RUN go mod tidy 18 | 19 | # compile etcd server with instrumentor 20 | RUN mkdir /etcd_instrumented 21 | RUN `go env GOPATH`/bin/antithesis-go-instrumentor /etcd /etcd_instrumented 22 | RUN rm -rf /etcd 23 | RUN mkdir -p /symbols 24 | RUN cp -r /etcd_instrumented/symbols/* /symbols 25 | 26 | EXPOSE 2379 2380 27 | 28 | # start etcd server 29 | WORKDIR /etcd_instrumented/customer/server 30 | RUN go mod tidy 31 | RUN CGO_ENABLED=1 go build -race 32 | CMD ["./server"] 33 | -------------------------------------------------------------------------------- /tests/antithesis/test-template/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG GO_VERSION=1.24.3 2 | ARG ARCH=amd64 3 | 4 | FROM golang:$GO_VERSION 5 | WORKDIR /build 6 | COPY . . 7 | 8 | WORKDIR /build/tests 9 | RUN go build -o /opt/antithesis/entrypoint/entrypoint -race ./antithesis/test-template/entrypoint/main.go 10 | RUN go build -o /opt/antithesis/test/v1/robustness/singleton_driver_traffic -race ./antithesis/test-template/robustness/traffic/main.go 11 | RUN go build -o /opt/antithesis/test/v1/robustness/finally_validation -race ./antithesis/test-template/robustness/finally/main.go 12 | -------------------------------------------------------------------------------- /tests/common/main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 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 common 16 | 17 | import ( 18 | "testing" 19 | 20 | "go.etcd.io/etcd/tests/v3/framework/config" 21 | intf "go.etcd.io/etcd/tests/v3/framework/interfaces" 22 | ) 23 | 24 | var ( 25 | testRunner intf.TestRunner 26 | clusterTestCases func() []testCase 27 | ) 28 | 29 | func TestMain(m *testing.M) { 30 | testRunner.TestMain(m) 31 | } 32 | 33 | type testCase struct { 34 | name string 35 | config config.ClusterConfig 36 | } 37 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/e2e/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 e2e 6 | 7 | import ( 8 | "os" 9 | "testing" 10 | 11 | "go.etcd.io/etcd/client/pkg/v3/testutil" 12 | "go.etcd.io/etcd/tests/v3/framework/e2e" 13 | ) 14 | 15 | func TestMain(m *testing.M) { 16 | e2e.InitFlags() 17 | v := m.Run() 18 | if v == 0 && testutil.CheckLeakedGoroutine() { 19 | os.Exit(1) 20 | } 21 | os.Exit(v) 22 | } 23 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/fixtures/ed25519-private-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MC4CAQAwBQYDK2VwBCIEIAtiwQ7KeS1I0otY9gw1Ox4av/zQ+wvs/8AIaTkawQ73 3 | -----END PRIVATE KEY----- 4 | -------------------------------------------------------------------------------- /tests/fixtures/ed25519-public-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MCowBQYDK2VwAyEAuOUxC8Bbn1KqYctlim/MHaP5JrtmeK5xcs+9w506btA= 3 | -----END PUBLIC KEY----- 4 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/fixtures/revoke.crl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/tests/fixtures/revoke.crl -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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-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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/framework/e2e/cluster_direct.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 | 17 | package e2e 18 | 19 | import "testing" 20 | 21 | func NewEtcdProcess(tb testing.TB, cfg *EtcdServerProcessConfig) (EtcdProcess, error) { 22 | return NewEtcdServerProcess(tb, cfg) 23 | } 24 | -------------------------------------------------------------------------------- /tests/framework/e2e/testing.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 e2e 16 | 17 | import ( 18 | "testing" 19 | 20 | "go.etcd.io/etcd/client/pkg/v3/testutil" 21 | ) 22 | 23 | func BeforeTest(tb testing.TB) { 24 | SkipInShortMode(tb) 25 | testutil.BeforeTest(tb) 26 | } 27 | -------------------------------------------------------------------------------- /tests/framework/testutils/path.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 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 testutils 16 | 17 | import "path/filepath" 18 | 19 | func MustAbsPath(path string) string { 20 | abs, err := filepath.Abs(path) 21 | if err != nil { 22 | panic(err) 23 | } 24 | return abs 25 | } 26 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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/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 | 17 | // Package embed_test is an empty package that exists to keep the following test working: 18 | // # go test -tags=cluster_proxy ./integration/embed 19 | package embed_test 20 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/snapshot/testdata/corrupted_backup.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/tests/integration/snapshot/testdata/corrupted_backup.db -------------------------------------------------------------------------------- /tests/integration/testing_test.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 integration_test 16 | 17 | import ( 18 | "testing" 19 | 20 | integration2 "go.etcd.io/etcd/tests/v3/framework/integration" 21 | ) 22 | 23 | func TestBeforeTestWithoutLeakDetection(t *testing.T) { 24 | integration2.BeforeTest(t, integration2.WithoutGoLeakDetection(), integration2.WithoutSkipInShort()) 25 | // Intentional leak that should get ignored 26 | go func() { 27 | }() 28 | } 29 | -------------------------------------------------------------------------------- /tests/robustness/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/robustness-testing 5 | -------------------------------------------------------------------------------- /tests/robustness/model/watch.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 model 16 | 17 | import "time" 18 | 19 | type WatchOperation struct { 20 | Request WatchRequest `json:",omitempty"` 21 | Responses []WatchResponse `json:",omitempty"` 22 | } 23 | 24 | type WatchResponse struct { 25 | Events []WatchEvent `json:",omitempty"` 26 | IsProgressNotify bool `json:",omitempty"` 27 | Revision int64 `json:",omitempty"` 28 | Time time.Duration `json:",omitempty"` 29 | Error string `json:",omitempty"` 30 | } 31 | -------------------------------------------------------------------------------- /tests/robustness/patches/beforeSendWatchResponse/build.patch: -------------------------------------------------------------------------------- 1 | @@ -25,7 +26,7 @@ GOFAIL_VERSION=$(cd tools/mod && go list -m -f {{.Version}} go.etcd.io/gofail) 2 | toggle_failpoints() { 3 | mode="$1" 4 | if command -v gofail >/dev/null 2>&1; then 5 | - run gofail "$mode" server/etcdserver/ server/mvcc/ server/wal/ server/mvcc/backend/ 6 | + run gofail "$mode" server/etcdserver/ server/mvcc/ server/wal/ server/mvcc/backend/ server/etcdserver/api/v3rpc/ 7 | if [[ "$mode" == "enable" ]]; then 8 | go get go.etcd.io/gofail@${GOFAIL_VERSION} 9 | cd ./server && go get go.etcd.io/gofail@${GOFAIL_VERSION} 10 | -------------------------------------------------------------------------------- /tests/robustness/patches/beforeSendWatchResponse/watch.patch: -------------------------------------------------------------------------------- 1 | diff --git a/server/etcdserver/api/v3rpc/watch.go b/server/etcdserver/api/v3rpc/watch.go 2 | index cd834aa..e6aaf2b 100644 3 | --- a/server/etcdserver/api/v3rpc/watch.go 4 | +++ b/server/etcdserver/api/v3rpc/watch.go 5 | @@ -460,6 +460,7 @@ func (sws *serverWatchStream) sendLoop() { 6 | sws.mu.RUnlock() 7 | 8 | var serr error 9 | + // gofail: var beforeSendWatchResponse struct{} 10 | if !fragmented && !ok { 11 | serr = sws.gRPCStream.Send(wr) 12 | } else { 13 | -------------------------------------------------------------------------------- /tests/robustness/patches/compactBeforeSetFinishedCompact/kvstore_compaction.patch: -------------------------------------------------------------------------------- 1 | From 6b034466aa0ac2b46fe01fb5bd2233946f46d453 Mon Sep 17 00:00:00 2001 2 | From: Wei Fu 3 | Date: Wed, 24 Apr 2024 12:14:27 +0800 4 | Subject: [PATCH] server/mvcc: introduce compactBeforeSetFinishedCompact 5 | failpoint 6 | 7 | Signed-off-by: Wei Fu 8 | --- 9 | server/mvcc/kvstore_compaction.go | 1 + 10 | 1 file changed, 1 insertion(+) 11 | 12 | diff --git a/server/mvcc/kvstore_compaction.go b/server/mvcc/kvstore_compaction.go 13 | index c7d343d5c..89defbd9e 100644 14 | --- a/server/mvcc/kvstore_compaction.go 15 | +++ b/server/mvcc/kvstore_compaction.go 16 | @@ -59,6 +59,7 @@ func (s *store) scheduleCompaction(compactMainRev, prevCompactRev int64) (KeyVal 17 | } 18 | 19 | if len(keys) < s.cfg.CompactionBatchLimit { 20 | + // gofail: var compactBeforeSetFinishedCompact struct{} 21 | rbytes := make([]byte, 8+1+8) 22 | revToBytes(revision{main: compactMainRev}, rbytes) 23 | tx.UnsafePut(buckets.Meta, finishedCompactKeyName, rbytes) 24 | -- 25 | 2.34.1 26 | 27 | -------------------------------------------------------------------------------- /tests/robustness/readme-images/artifact_archive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/tests/robustness/readme-images/artifact_archive.png -------------------------------------------------------------------------------- /tests/robustness/readme-images/issue14370.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/tests/robustness/readme-images/issue14370.png -------------------------------------------------------------------------------- /tests/robustness/readme-images/prow_job.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/tests/robustness/readme-images/prow_job.png -------------------------------------------------------------------------------- /tests/robustness/readme-images/prow_job_artifacts_dir_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/tests/robustness/readme-images/prow_job_artifacts_dir_page.png -------------------------------------------------------------------------------- /tests/robustness/readme-images/prow_job_artifacts_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/etcd-io/etcd/22f8d56ca72b650514acb0e1d7cc24d83f3f52c3/tests/robustness/readme-images/prow_job_artifacts_page.png -------------------------------------------------------------------------------- /tests/robustness/report/failpoint.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 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 16 | 17 | import ( 18 | "time" 19 | ) 20 | 21 | type FailpointReport struct { 22 | FailpointInjection 23 | Client []ClientReport 24 | } 25 | 26 | type FailpointInjection struct { 27 | Start, End time.Duration 28 | Name string 29 | } 30 | -------------------------------------------------------------------------------- /tests/robustness/testdata/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /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/.yamlfmt: -------------------------------------------------------------------------------- 1 | formatter: 2 | type: basic 3 | include_document_start: true 4 | retain_line_breaks: true 5 | -------------------------------------------------------------------------------- /tools/.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | extends: default 4 | rules: 5 | line-length: disable 6 | truthy: disable 7 | comments: disable 8 | -------------------------------------------------------------------------------- /tools/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/tooling 5 | -------------------------------------------------------------------------------- /tools/benchmark/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/performance 5 | -------------------------------------------------------------------------------- /tools/benchmark/README.md: -------------------------------------------------------------------------------- 1 | # etcd/tools/benchmark 2 | 3 | `etcd/tools/benchmark` is the official benchmarking tool for etcd clusters. 4 | 5 | ## Installation 6 | 7 | Install the tool by running the following command from the etcd source directory. 8 | 9 | ``` 10 | $ go install -v ./tools/benchmark 11 | ``` 12 | 13 | The installation will place executables in the $GOPATH/bin. If $GOPATH environment variable is not set, the tool will be installed into the $HOME/go/bin. You can also find out the installed location by running the following command from the etcd source directory. Make sure that $PATH is set accordingly in your environment. 14 | 15 | ``` 16 | $ go list -f "{{.Target}}" ./tools/benchmark 17 | ``` 18 | 19 | Alternatively, instead of installing the tool, you can use it by simply running the following command from the etcd source directory. 20 | 21 | ``` 22 | $ go run ./tools/benchmark 23 | ``` 24 | 25 | ## Usage 26 | 27 | The following command should output the usage per the latest development. 28 | 29 | ``` 30 | $ benchmark --help 31 | ``` 32 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tools/etcd-dump-db/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/debugging 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tools/etcd-dump-logs/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/debugging 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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: 34 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 | -------------------------------------------------------------------------------- /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: 34 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 | -------------------------------------------------------------------------------- /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: 34 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/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: 34 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 | -------------------------------------------------------------------------------- /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: 34 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 | -------------------------------------------------------------------------------- /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: 34 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 | -------------------------------------------------------------------------------- /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: 34 7 | lastIndex=34 8 | term index type data 9 | 5 11 norm ID:6 put: 10 | 11 | Entry types (IRRPut) count is : 1 12 | -------------------------------------------------------------------------------- /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: 34 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: 34 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 | -------------------------------------------------------------------------------- /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: 34 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tools/etcd-dump-metrics/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/observability 5 | -------------------------------------------------------------------------------- /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 | 17 | package main 18 | 19 | import "errors" 20 | 21 | func install(ver, dir string) (string, error) { 22 | return "", errors.New("windows install is not supported yet") 23 | } 24 | -------------------------------------------------------------------------------- /tools/etcd-dump-metrics/utils.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 main 16 | 17 | import ( 18 | "maps" 19 | "slices" 20 | ) 21 | 22 | func aggSort(ss []string) (sorted []string) { 23 | dup := slices.Clone(ss) 24 | slices.Sort(dup) 25 | return slices.Compact(dup) 26 | } 27 | 28 | func sortMap(set map[string]struct{}) (sorted []string) { 29 | return slices.Sorted(maps.Keys(set)) 30 | } 31 | -------------------------------------------------------------------------------- /tools/local-tester/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/testing 5 | -------------------------------------------------------------------------------- /tools/local-tester/bridge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Warning: etcd-local-tester is now deprecated in favor of our robustness testing suite and will be removed in a future release." 4 | 5 | exec tools/local-tester/bridge/bridge \ 6 | -delay-accept \ 7 | -reset-listen \ 8 | -conn-fault-rate=0.25 \ 9 | -immediate-close \ 10 | -blackhole \ 11 | -time-close \ 12 | -write-remote-only \ 13 | -read-remote-only \ 14 | -random-blackhole \ 15 | -corrupt-receive \ 16 | -corrupt-send \ 17 | -reorder \ 18 | $@ 19 | -------------------------------------------------------------------------------- /tools/mod/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 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 | // As this directory implements the pattern for tracking tool dependencies as documented here: 16 | // https://go.dev/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module, it doesn't 17 | // contain any valid go source code in the directory directly. This would break scripts for 18 | // unit testing, golangci-lint, and coverage calculation. 19 | // 20 | // Thus, to ensure tools to run normally, we've added this empty file. 21 | 22 | package mod 23 | -------------------------------------------------------------------------------- /tools/mod/install_all.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | cd ./tools/mod || exit 2 6 | go list --tags tools -f '{{ join .Imports "\n" }}' | xargs go install 7 | -------------------------------------------------------------------------------- /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 | //go:build libs 16 | 17 | // This file implements that pattern: 18 | // https://go.dev/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 | -------------------------------------------------------------------------------- /tools/proto-annotations/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 | package main 16 | 17 | import ( 18 | "fmt" 19 | "os" 20 | 21 | "go.etcd.io/etcd/v3/tools/proto-annotations/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 | -------------------------------------------------------------------------------- /tools/rw-heatmaps/.gitignore: -------------------------------------------------------------------------------- 1 | results-*.csv 2 | rw-heatmaps 3 | *.jpg 4 | *.jpeg 5 | *.png 6 | *.tiff 7 | -------------------------------------------------------------------------------- /tools/rw-heatmaps/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | approvers: 4 | - ivanvc # Ivan Valdes 5 | 6 | labels: 7 | - area/performance 8 | -------------------------------------------------------------------------------- /tools/rw-heatmaps/go.mod: -------------------------------------------------------------------------------- 1 | module go.etcd.io/etcd/tools/rw-heatmaps/v3 2 | 3 | go 1.24 4 | 5 | toolchain go1.24.3 6 | 7 | require ( 8 | github.com/spf13/cobra v1.9.1 9 | github.com/spf13/pflag v1.0.6 10 | gonum.org/v1/plot v0.14.0 11 | ) 12 | 13 | require ( 14 | git.sr.ht/~sbinet/gg v0.5.0 // indirect 15 | github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b // indirect 16 | github.com/campoy/embedmd v1.0.0 // indirect 17 | github.com/go-fonts/liberation v0.3.1 // indirect 18 | github.com/go-latex/latex v0.0.0-20230307184459-12ec69307ad9 // indirect 19 | github.com/go-pdf/fpdf v0.8.0 // indirect 20 | github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect 21 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 22 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect 23 | golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect 24 | golang.org/x/image v0.18.0 // indirect 25 | golang.org/x/text v0.25.0 // indirect 26 | ) 27 | -------------------------------------------------------------------------------- /tools/rw-heatmaps/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 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/tools/rw-heatmaps/v3/cmd" 22 | ) 23 | 24 | func main() { 25 | if err := cmd.NewRootCommand().Execute(); err != nil { 26 | fmt.Fprintf(os.Stderr, "error: %v\n", err.Error()) 27 | os.Exit(1) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tools/testgrid-analysis/OWNERS: -------------------------------------------------------------------------------- 1 | # See the OWNERS docs at https://go.k8s.io/owners 2 | 3 | labels: 4 | - area/testing 5 | -------------------------------------------------------------------------------- /tools/testgrid-analysis/go.mod: -------------------------------------------------------------------------------- 1 | module go.etcd.io/etcd/tools/testgrid-analysis/v3 2 | 3 | go 1.24 4 | 5 | toolchain go1.24.3 6 | 7 | require ( 8 | github.com/GoogleCloudPlatform/testgrid v0.0.173 9 | github.com/google/go-github/v60 v60.0.0 10 | github.com/spf13/cobra v1.9.1 11 | google.golang.org/protobuf v1.36.6 12 | ) 13 | 14 | require ( 15 | github.com/google/go-cmp v0.7.0 // indirect 16 | github.com/google/go-querystring v1.1.0 // indirect 17 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 18 | github.com/spf13/pflag v1.0.6 // indirect 19 | go.opentelemetry.io/otel v1.36.0 // indirect 20 | go.opentelemetry.io/otel/sdk v1.36.0 // indirect 21 | golang.org/x/net v0.40.0 // indirect 22 | golang.org/x/sys v0.33.0 // indirect 23 | golang.org/x/text v0.25.0 // indirect 24 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 // indirect 25 | google.golang.org/grpc v1.72.2 // indirect 26 | ) 27 | -------------------------------------------------------------------------------- /tools/testgrid-analysis/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 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 "go.etcd.io/etcd/tools/testgrid-analysis/v3/cmd" 18 | 19 | func main() { 20 | cmd.Execute() 21 | } 22 | --------------------------------------------------------------------------------