Skip to content

Commit

Permalink
Relax the cluster version check when updating the cluster
Browse files Browse the repository at this point in the history
Before this PR, we require the cluster shouldn't be modified when
updating, but users might modify the cluster information via the redis
client during this period. To allow this, we only check if the current
version is newer than the store.
  • Loading branch information
git-hulk committed Dec 23, 2024
1 parent 01c319b commit 28a33c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scripts/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

set -e -x

go test -v ./... -covermode=atomic -coverprofile=coverage.out -race -p 1
CGO_ENABLED=0 go test -v ./... -covermode=atomic -coverprofile=coverage.out -race -p 1
4 changes: 2 additions & 2 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (s *ClusterStore) UpdateCluster(ctx context.Context, ns string, clusterInfo
if err != nil {
return err
}
if oldCluster.Version.Load() != clusterInfo.Version.Load() {
if oldCluster.Version.Load() > clusterInfo.Version.Load() {
return fmt.Errorf("the cluster has been updated by others")
}

Expand Down Expand Up @@ -212,7 +212,7 @@ func (s *ClusterStore) SetCluster(ctx context.Context, ns string, clusterInfo *C
if err != nil {
return err
}
if oldCluster.Version.Load() != clusterInfo.Version.Load() {
if oldCluster.Version.Load() > clusterInfo.Version.Load() {
return fmt.Errorf("the cluster has been updated by others")
}

Expand Down

0 comments on commit 28a33c0

Please sign in to comment.