Commit Graph

99 Commits

Author SHA1 Message Date
7f9efcfe52 fix: use testify instead of t.Fatal or t.Error in contrib package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-12-01 21:36:39 +00:00
3ef69d2681 fix: enable gofumpt instead of gofmt linter in contrib, etcdctl and etcdutl
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-11-09 00:37:14 +01:00
e5a63483ff fix: enable errorlint linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-31 18:54:59 +01:00
63dad79245 fix: use require.NoError instead of t.Fatal(err) in contrib and tools packages
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-18 13:06:48 +02:00
33d7f2d53e fix: enable gofmt and whitespace linters
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-11 07:03:18 +02:00
68db7087e1 Handle ErrCompacted errors for Compact in raftexample
Signed-off-by: Chen Yang <809476530@qq.com>
Signed-off-by: chenyangyang.cy <chenyangyang.cy@alibaba-inc.com>
2023-08-18 20:05:05 +08:00
b798aae9c5 Update golangci-lint from 1.49.0 to 1.53.3
Signed-off-by: iuriatan <iuriatan@gmail.com>
2023-07-14 16:46:26 -03:00
0c919dc212 use the more efficient strings.Builder
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-05-19 10:44:58 +08:00
330f871ff9 contrib: fix raftexample README's raft library link.
Signed-off-by: tangwz <tangwz.com@gmail.com>
2023-03-31 20:02:49 +08:00
b17b9c1428 chore: Use http constants to replace numbers as parameters
Signed-off-by: xin.li <xin.li@daocloud.io>
2023-02-20 11:53:41 +08:00
0775d36e53 raftexample: update etcdserver to use the new raft module go.etcd.io/raft/v3
Just replaced all go.etcd.io/etcd/raft/v3 with go.etcd.io/raft/v3
under directory contrib/raftexample.

Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-12-02 14:25:50 +08:00
0f9d7a4f95 raft: make Message.Snapshot nullable, halve struct size
This commit makes the rarely used `raftpb.Message.Snapshot` field nullable.
In doing so, it reduces the memory size of a `raftpb.Message` message from
264 bytes to 128 bytes — a 52% reduction in size.

While this commit does not change the protobuf encoding, it does change
how that encoding is used. `(gogoproto.nullable) = false` instruct the
generated proto marshaling logic to always encode a value for the field,
even if that value is empty. `(gogoproto.nullable) = true` instructs the
generated proto marshaling logic to omit an encoded value for the field
if the field is nil.

This raises compatibility concerns in both directions. Messages encoded
by new binary versions without a `Snapshot` field will be decoded as an
empty field by old binary versions. In other words, old binary versions
can't tell the difference. However, messages encoded by old binary versions
with an empty Snapshot field will be decoded as a non-nil, empty field by
new binary versions. As a result, new binary versions need to be prepared
to handle such messages.

While Message.Snapshot is not intentionally part of the external interface
of this library, it was possible for users of the library to access it and
manipulate it. As such, this change may be considered a breaking change.

Signed-off-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
2022-11-09 17:35:52 +00:00
f67ec10779 etcd: format import order
golang CodeReviewComments:
https://github.com/golang/go/wiki/CodeReviewComments#imports

Signed-off-by: demoManito <1430482733@qq.com>
2022-09-20 18:41:39 +08:00
f8b65d53ba Add revive to the list of linters.
Part of "Enhance the static-analysis workflow" issue. #14164

Signed-off-by: Cenk Alti <cenkalti@gmail.com>
2022-08-27 13:41:14 -04:00
8ad87be7a6 fix the DATA RACE issue of TestCloseProposerInflight 2022-06-07 18:59:00 +08:00
534d7b4795 use go install instead of go get 2022-05-20 23:45:14 +08:00
3152dc8174 contrib/raftexample: Save snapshot and WAL before hard state
Update raftexample to save the snapshot file and WAL snapshot entry
before hardstate to ensure the snapshot exists during recovery.
Otherwise if there is a failure after storing the hard state there may
be reference to a non-existent snapshot.
This PR introduces the fix from #10219 to the raftexample.
2022-04-11 23:44:54 +00:00
5cf6ba48de added a unit test for the method processMessages 2022-03-08 09:38:23 +08:00
793218ed2b update the confstate before sending snapshot
When there is a `raftpb.EntryConfChange` after creating the snapshot,
then the confState included in the snapshot is out of date. so We need
to update the confState before sending a snapshot to a follower.
2022-03-07 12:18:29 +08:00
2a151c8982 *: move from io/ioutil to io and os packages
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-10-28 00:05:28 +08:00
44b8ae145b etcdserver: Move datadir and wal to storage package 2021-08-03 12:47:37 +02:00
36bb8d293c Use method const in package http instead of literal 2021-07-08 20:00:03 +08:00
3bb7acc8cf Migrate dependencies pkg/foo -> client/pkg/foo 2021-04-07 00:38:47 +02:00
fce0c192eb Regenerate protos. 2021-03-25 00:31:44 +01:00
3976d68ed3 raftExample: Allow closing raftexample node when snapshotting.
Fix race that made the raftExample test fail.
2021-02-26 08:56:12 +01:00
5ae3f879c9 raftexample: Return an appropriate applyDoneC 2021-02-24 21:28:18 +09:00
cb0d256a18 raftexample: Add test for adding new node to existing cluster 2021-02-22 13:44:33 +09:00
1b1be43d65 raftexample: New joined node have to start with RestartNode 2021-02-22 09:45:44 +09:00
cc2b039817 raftexample: Explicitly notify all committed entries are applied 2021-02-19 19:26:36 +09:00
2d25f7f3da raftexample: Implement ReportUnreachable and ReportSnapshot 2021-02-17 11:59:32 +09:00
1302e1edb2 raftexample: Save snapshot file before writing to wal 2021-02-16 13:30:15 +09:00
be2167ebab Wait until all committed entries are applied
To take a snapshot
2021-02-05 19:05:41 +09:00
cb14cdd774 raftexample: Fix recovery from snapshot
* If there is a snapshot, HTTP server won't start.
* Resotring form snapshot occurs after replaying WAL.
* When taking a snapshot, the last change is not applied to the state machine yet.
2021-02-05 09:34:34 +09:00
aaf423e962 server: Update imports.
find -name '*.go' | xargs sed -i --follow-symlinks 's|etcd/v3/|etcd/server/v3/|g'
2020-10-26 13:02:32 +01:00
e62417297d *: Rename of imports of raft (as its now a module)
% find -name '*.go' -o -name '*.md' -o -name '*.sh' | xargs sed -i --follow-symlinks 's|etcd/v3/raft|etcd/raft/v3|g'
2020-10-16 13:58:18 +02:00
de55bb6331 pkg: Rename imports after making 'pkg' a module
find -name '*.go' | xargs sed --follow-symlinks -i 's|go.etcd.io/etcd/v3/pkg/|go.etcd.io/etcd/pkg/v3/|g'
go fmt ./...
2020-10-13 00:09:27 +02:00
96cce208c2 go.mod: use go.etcd.io/etcd/v3 versioning
This change makes the etcd package compatible with the existing Go
ecosystem for module versioning.

Used this tool to update package imports:
  https://github.com/KSubedi/gomove
2020-04-28 00:57:35 +00:00
61f279454e etcdserver/api: remove capnslog (#11606)
* etcdserver/api/rafthttp: remove capnslog

* etcdserver/api/membership: remove capnslog

* etcdserver/api/v2auth: remove capnslog

* etcdserver/api/v2discovery: remove capnslog

* etdserver/api/v2stats: remove capnslog

* etcdserver/api/v2http: remove capnslog

* etcdserver/api/v3rpc: remove capnslog

* etcdserver/api: remove capnslog

Remove capnslog from etcdserver/api. Note that capnslog was
already removed in some packages under etcdserver/api in
previous commits.
2020-02-11 13:51:25 -08:00
1caaa9ed4a test: test update for Go 1.12.5 and related changes
Update to Go 1.12.5 testing. Remove deprecated unused and gosimple
pacakges, and mask staticcheck 1006. Also, fix unconvert errors related
to unnecessary type conversions and following staticcheck errors:
- remove redundant return statements
- use for range instead of for select
- use time.Since instead of time.Now().Sub
- omit comparison to bool constant
- replace T.Fatal and T.Fatalf in tests with T.Error and T.Fatalf respectively because the goroutine calls T.Fatal must be called in the same goroutine as the test
- fix error strings that should not be capitalized
- use sort.Strings(...) instead of sort.Sort(sort.StringSlice(...))
- use he status code of Canceled instead of grpc.ErrClientConnClosing which is deprecated
- use use status.Errorf instead of grpc.Errorf which is deprecated

Related #10528 #10438
2019-06-05 17:02:05 -04:00
34bd797e67 *: revert module import paths
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
2019-05-28 15:39:35 -07:00
9150bf52d6 go modules: Fix module path version to include version number 2019-04-26 15:29:50 -07:00
d5e94b1c0d Merge pull request #10557 from johncming/add_test
contrib/raftexample: add test for httpKVAPI.
2019-03-28 11:39:45 -07:00
4452d4be22 contrib/raftexample: fix naked return. 2019-03-20 09:52:12 +08:00
51cdbb6d1a contrib/raftexample: add test for struct httpKVAPI. 2019-03-19 11:12:47 +08:00
e46af034df bugfix: adjust or add close request body.
affected modules:
- lease/leasehttp
- contrib/raftexample
2019-03-12 22:41:55 +08:00
5b4ff6c6d5 raftexample: update readme 2019-02-21 16:56:52 -05:00
74d6df2bd6 raftexample: added build instruction and minor refactoring 2019-02-21 15:00:38 -05:00
dac8c6fcc0 Merge pull request #10167 from nvanbenschoten/nvanbenschoten/limitUncommitted
raft: provide protection against unbounded Raft log growth
2018-10-13 23:52:28 -07:00
f89b06dc6d raft: provide protection against unbounded Raft log growth
The suggested pattern for Raft proposals is that they be retried
periodically until they succeed. This turns out to be an issue
when a leader cannot commit entries because the leader will continue
to append re-proposed entries to its log without committing anything.
This can result in the uncommitted tail of a leader's log growing
without bound until it is able to commit entries.

This change add a safeguard to protect against this case where a
leader's log can grow without bound during loss of quorum scenarios.
It does so by introducing a new, optional ``MaxUncommittedEntriesSize
configuration. This config limits the max aggregate size of uncommitted
entries that may be appended to a leader's log. Once this limit
is exceeded, proposals will begin to return ErrProposalDropped
errors.

See cockroachdb/cockroach#27772
2018-10-13 23:25:05 -04:00
1cab49ef78 Merge pull request #9718 from kchristidis/fix-snap-pub-error
raftexample: Fix publish snapshot error message
2018-10-11 16:45:55 -07:00