Repository: tikv/pd
Pull request #5780 (2022-12-14 06:51:31)

*: move id and version to pkg
Signed-off-by: Ryan Leung <rleungx@gmail.com>

<!--
Thank you for working on PD! Please read PD's [CONTRIBUTING](https://github.com/tikv/pd/blob/master/CONTRIBUTING.md) document **BEFORE** filing this PR.
PR Title Format:
1. pkg [, pkg2, pkg3]: what's changed
2. *: what's changed
-->

### What problem does this PR solve?

<!--

Please create an issue first to describe the problem.
There MUST be one line starting with "Issue Number:  " and 
linking the relevant issues via the "close" or "ref".
For more info, check https://github.com/tikv/pd/blob/master/CONTRIBUTING.md#linking-issues.

-->
Issue Number: Ref #5766.

### What is changed and how does it work?
Considering that scheduling will be split into individual services, we should reduce its dependency on the server. Also, this PR removes the server/storage dependencies.

<!--

You could use the "commit message" code block to add more description to the final commit message.
For more info, check https://github.com/tikv/pd/blob/master/CONTRIBUTING.md#format-of-the-commit-message.

-->

```commit-message
```

### Check List

<!-- Remove the items that are not applicable. -->

Tests

<!-- At least one of these tests must be included. -->

- Unit test

### Release note

<!-- A bugfix or a new feature needs a release note. If there is no need release note, just uncomment the below line. -->

```release-note
None
```


ti-chi-bot: [REVIEW NOTIFICATION]

This pull request has not been approved.


To complete the [pull request process](https://book.prow.tidb.net/#/en/workflows/pr), please ask the reviewers in the [list](https://prow.tidb.net/tichi/repos/tikv/pd/pulls/5780/owners) to review by filling `/cc @reviewer` in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the [list](https://prow.tidb.net/tichi/repos/tikv/pd/pulls/5780/owners) by filling  `/assign @committer` in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found [here](https://prow.tidb.net/command-help?repo=tikv%2Fpd).

<details>

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.
</details>

<!--Review Notification Identifier-->
codecov[bot]: # [Codecov](https://codecov.io/gh/tikv/pd/pull/5780?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv) Report
Base: **75.56**% // Head: **75.69**% // Increases project coverage by **`+0.13%`** :tada:
> Coverage data is based on head [(`82d4bb4`)](https://codecov.io/gh/tikv/pd/pull/5780?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv) compared to base [(`ad1cc2d`)](https://codecov.io/gh/tikv/pd/commit/ad1cc2d9797499b371d44669859c4c10d7515c89?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv).
> Patch has no changes to coverable lines.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #5780      +/-   ##
==========================================
+ Coverage   75.56%   75.69%   +0.13%     
==========================================
  Files         329      329              
  Lines       32961    32961              
==========================================
+ Hits        24907    24950      +43     
+ Misses       5900     5869      -31     
+ Partials     2154     2142      -12     
```

| Flag | Coverage Δ | |
|---|---|---|
| unittests | `75.69% <ø> (+0.13%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/tikv/pd/pull/5780?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv) | Coverage Δ | |
|---|---|---|
| [pkg/id/id.go](https://codecov.io/gh/tikv/pd/pull/5780/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv#diff-cGtnL2lkL2lkLmdv) | `83.05% <ø> (ø)` | |
| [pkg/id/metrics.go](https://codecov.io/gh/tikv/pd/pull/5780/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv#diff-cGtnL2lkL21ldHJpY3MuZ28=) | `100.00% <ø> (ø)` | |
| [pkg/mock/mockcluster/mockcluster.go](https://codecov.io/gh/tikv/pd/pull/5780/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv#diff-cGtnL21vY2svbW9ja2NsdXN0ZXIvbW9ja2NsdXN0ZXIuZ28=) | `93.94% <ø> (ø)` | |
| [pkg/versioninfo/feature.go](https://codecov.io/gh/tikv/pd/pull/5780/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv#diff-cGtnL3ZlcnNpb25pbmZvL2ZlYXR1cmUuZ28=) | `60.00% <ø> (ø)` | |
| [pkg/versioninfo/versioninfo.go](https://codecov.io/gh/tikv/pd/pull/5780/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv#diff-cGtnL3ZlcnNpb25pbmZvL3ZlcnNpb25pbmZvLmdv) | `78.94% <ø> (ø)` | |
| [server/api/pprof.go](https://codecov.io/gh/tikv/pd/pull/5780/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv#diff-c2VydmVyL2FwaS9wcHJvZi5nbw==) | `48.10% <ø> (ø)` | |
| [server/api/status.go](https://codecov.io/gh/tikv/pd/pull/5780/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv#diff-c2VydmVyL2FwaS9zdGF0dXMuZ28=) | `100.00% <ø> (ø)` | |
| [server/api/version.go](https://codecov.io/gh/tikv/pd/pull/5780/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv#diff-c2VydmVyL2FwaS92ZXJzaW9uLmdv) | `100.00% <ø> (ø)` | |
| [server/cluster/cluster.go](https://codecov.io/gh/tikv/pd/pull/5780/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv#diff-c2VydmVyL2NsdXN0ZXIvY2x1c3Rlci5nbw==) | `81.97% <ø> (+0.17%)` | :arrow_up: |
| [server/cluster/cluster\_worker.go](https://codecov.io/gh/tikv/pd/pull/5780/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv#diff-c2VydmVyL2NsdXN0ZXIvY2x1c3Rlcl93b3JrZXIuZ28=) | `70.00% <ø> (ø)` | |
| ... and [33 more](https://codecov.io/gh/tikv/pd/pull/5780/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv) | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv)

</details>

[:umbrella: View full report at Codecov](https://codecov.io/gh/tikv/pd/pull/5780?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tikv).

ti-chi-bot: @nolouch: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests


<details>

Instructions for interacting with me using PR comments are available [here](https://prow.tidb.net/command-help).  If you have questions or suggestions related to my behavior, please file an issue against the [ti-community-infra/tichi](https://github.com/ti-community-infra/tichi/issues/new?title=Prow%20issue:) repository.
</details>
ti-chi-bot: This pull request has been accepted and is ready to merge. <details>Commit hash: 9c616ac9188d750b49524ae3bf79553ace462783</details>

Patch:
diff --git a/server/id/id.go b/pkg/id/id.go
similarity index 100%
rename from server/id/id.go
rename to pkg/id/id.go
diff --git a/server/id/id_test.go b/pkg/id/id_test.go
similarity index 100%
rename from server/id/id_test.go
rename to pkg/id/id_test.go
diff --git a/server/id/metrics.go b/pkg/id/metrics.go
similarity index 100%
rename from server/id/metrics.go
rename to pkg/id/metrics.go
diff --git a/pkg/mock/mockcluster/mockcluster.go b/pkg/mock/mockcluster/mockcluster.go
index c41a28aa0..bd0c63f63 100644
--- a/pkg/mock/mockcluster/mockcluster.go
+++ b/pkg/mock/mockcluster/mockcluster.go
@@ -25,18 +25,18 @@ import (
 	"github.com/pingcap/kvproto/pkg/pdpb"
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/id"
 	"github.com/tikv/pd/pkg/mock/mockid"
 	"github.com/tikv/pd/pkg/utils/typeutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/core/storelimit"
-	"github.com/tikv/pd/server/id"
 	"github.com/tikv/pd/server/schedule/labeler"
 	"github.com/tikv/pd/server/schedule/placement"
 	"github.com/tikv/pd/server/statistics"
 	"github.com/tikv/pd/server/statistics/buckets"
 	"github.com/tikv/pd/server/storage"
-	"github.com/tikv/pd/server/versioninfo"
 )
 
 const (
diff --git a/server/storage/endpoint/config.go b/pkg/storage/endpoint/config.go
similarity index 100%
rename from server/storage/endpoint/config.go
rename to pkg/storage/endpoint/config.go
diff --git a/server/storage/endpoint/endpoint.go b/pkg/storage/endpoint/endpoint.go
similarity index 100%
rename from server/storage/endpoint/endpoint.go
rename to pkg/storage/endpoint/endpoint.go
diff --git a/server/storage/endpoint/external_timestamp.go b/pkg/storage/endpoint/external_timestamp.go
similarity index 100%
rename from server/storage/endpoint/external_timestamp.go
rename to pkg/storage/endpoint/external_timestamp.go
diff --git a/server/storage/endpoint/gc_key_space.go b/pkg/storage/endpoint/gc_key_space.go
similarity index 100%
rename from server/storage/endpoint/gc_key_space.go
rename to pkg/storage/endpoint/gc_key_space.go
diff --git a/server/storage/endpoint/gc_safe_point.go b/pkg/storage/endpoint/gc_safe_point.go
similarity index 100%
rename from server/storage/endpoint/gc_safe_point.go
rename to pkg/storage/endpoint/gc_safe_point.go
diff --git a/server/storage/endpoint/key_path.go b/pkg/storage/endpoint/key_path.go
similarity index 100%
rename from server/storage/endpoint/key_path.go
rename to pkg/storage/endpoint/key_path.go
diff --git a/server/storage/endpoint/key_path_test.go b/pkg/storage/endpoint/key_path_test.go
similarity index 100%
rename from server/storage/endpoint/key_path_test.go
rename to pkg/storage/endpoint/key_path_test.go
diff --git a/server/storage/endpoint/keyspace.go b/pkg/storage/endpoint/keyspace.go
similarity index 100%
rename from server/storage/endpoint/keyspace.go
rename to pkg/storage/endpoint/keyspace.go
diff --git a/server/storage/endpoint/meta.go b/pkg/storage/endpoint/meta.go
similarity index 100%
rename from server/storage/endpoint/meta.go
rename to pkg/storage/endpoint/meta.go
diff --git a/server/storage/endpoint/min_resolved_ts.go b/pkg/storage/endpoint/min_resolved_ts.go
similarity index 100%
rename from server/storage/endpoint/min_resolved_ts.go
rename to pkg/storage/endpoint/min_resolved_ts.go
diff --git a/server/storage/endpoint/replication_status.go b/pkg/storage/endpoint/replication_status.go
similarity index 100%
rename from server/storage/endpoint/replication_status.go
rename to pkg/storage/endpoint/replication_status.go
diff --git a/server/storage/endpoint/rule.go b/pkg/storage/endpoint/rule.go
similarity index 100%
rename from server/storage/endpoint/rule.go
rename to pkg/storage/endpoint/rule.go
diff --git a/server/storage/endpoint/service_middleware.go b/pkg/storage/endpoint/service_middleware.go
similarity index 100%
rename from server/storage/endpoint/service_middleware.go
rename to pkg/storage/endpoint/service_middleware.go
diff --git a/server/storage/endpoint/util.go b/pkg/storage/endpoint/util.go
similarity index 100%
rename from server/storage/endpoint/util.go
rename to pkg/storage/endpoint/util.go
diff --git a/server/versioninfo/feature.go b/pkg/versioninfo/feature.go
similarity index 100%
rename from server/versioninfo/feature.go
rename to pkg/versioninfo/feature.go
diff --git a/server/versioninfo/versioninfo.go b/pkg/versioninfo/versioninfo.go
similarity index 100%
rename from server/versioninfo/versioninfo.go
rename to pkg/versioninfo/versioninfo.go
diff --git a/plugin/scheduler_example/evict_leader.go b/plugin/scheduler_example/evict_leader.go
index 3284ed7fa..2c0f4a847 100644
--- a/plugin/scheduler_example/evict_leader.go
+++ b/plugin/scheduler_example/evict_leader.go
@@ -23,6 +23,7 @@ import (
 	"github.com/pingcap/errors"
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/apiutil"
 	"github.com/tikv/pd/pkg/utils/syncutil"
 	"github.com/tikv/pd/server/core"
@@ -31,7 +32,6 @@ import (
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
 	"github.com/tikv/pd/server/schedulers"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"github.com/unrolled/render"
 )
 
diff --git a/server/api/pprof.go b/server/api/pprof.go
index 0c180dda2..b64278a21 100644
--- a/server/api/pprof.go
+++ b/server/api/pprof.go
@@ -27,8 +27,8 @@ import (
 	"time"
 
 	"github.com/pingcap/log"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server"
-	"github.com/tikv/pd/server/versioninfo"
 	"github.com/unrolled/render"
 	"go.uber.org/zap"
 )
diff --git a/server/api/service_gc_safepoint.go b/server/api/service_gc_safepoint.go
index 9df3700a3..b26edaba0 100644
--- a/server/api/service_gc_safepoint.go
+++ b/server/api/service_gc_safepoint.go
@@ -18,8 +18,8 @@ import (
 	"net/http"
 
 	"github.com/gorilla/mux"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/server"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"github.com/unrolled/render"
 )
 
diff --git a/server/api/status.go b/server/api/status.go
index 12a25554f..8f837ec01 100644
--- a/server/api/status.go
+++ b/server/api/status.go
@@ -17,8 +17,8 @@ package api
 import (
 	"net/http"
 
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server"
-	"github.com/tikv/pd/server/versioninfo"
 	"github.com/unrolled/render"
 )
 
diff --git a/server/api/version.go b/server/api/version.go
index 38e5a12d8..5bf3aeb27 100644
--- a/server/api/version.go
+++ b/server/api/version.go
@@ -17,7 +17,7 @@ package api
 import (
 	"net/http"
 
-	"github.com/tikv/pd/server/versioninfo"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/unrolled/render"
 )
 
diff --git a/server/cluster/cluster.go b/server/cluster/cluster.go
index 41ff2fe3a..ae615dc35 100644
--- a/server/cluster/cluster.go
+++ b/server/cluster/cluster.go
@@ -32,17 +32,19 @@ import (
 	"github.com/pingcap/kvproto/pkg/pdpb"
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/id"
 	"github.com/tikv/pd/pkg/progress"
 	"github.com/tikv/pd/pkg/slice"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/etcdutil"
 	"github.com/tikv/pd/pkg/utils/logutil"
 	"github.com/tikv/pd/pkg/utils/netutil"
 	"github.com/tikv/pd/pkg/utils/syncutil"
 	"github.com/tikv/pd/pkg/utils/typeutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/core/storelimit"
-	"github.com/tikv/pd/server/id"
 	syncer "github.com/tikv/pd/server/region_syncer"
 	"github.com/tikv/pd/server/replication"
 	"github.com/tikv/pd/server/schedule"
@@ -54,8 +56,6 @@ import (
 	"github.com/tikv/pd/server/statistics"
 	"github.com/tikv/pd/server/statistics/buckets"
 	"github.com/tikv/pd/server/storage"
-	"github.com/tikv/pd/server/storage/endpoint"
-	"github.com/tikv/pd/server/versioninfo"
 	"go.etcd.io/etcd/clientv3"
 	"go.uber.org/zap"
 )
diff --git a/server/cluster/cluster_worker.go b/server/cluster/cluster_worker.go
index 4a3e1249c..d1d2a3ced 100644
--- a/server/cluster/cluster_worker.go
+++ b/server/cluster/cluster_worker.go
@@ -24,10 +24,10 @@ import (
 	"github.com/tikv/pd/pkg/errs"
 	"github.com/tikv/pd/pkg/utils/logutil"
 	"github.com/tikv/pd/pkg/utils/typeutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/statistics/buckets"
-	"github.com/tikv/pd/server/versioninfo"
 	"go.uber.org/zap"
 )
 
diff --git a/server/config/config.go b/server/config/config.go
index eaa6644c5..872ddda1f 100644
--- a/server/config/config.go
+++ b/server/config/config.go
@@ -34,8 +34,8 @@ import (
 	"github.com/tikv/pd/pkg/utils/metricutil"
 	"github.com/tikv/pd/pkg/utils/syncutil"
 	"github.com/tikv/pd/pkg/utils/typeutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/core/storelimit"
-	"github.com/tikv/pd/server/versioninfo"
 
 	"github.com/BurntSushi/toml"
 	"github.com/coreos/go-semver/semver"
diff --git a/server/config/persist_options.go b/server/config/persist_options.go
index 726ff9ab9..c4f98969f 100644
--- a/server/config/persist_options.go
+++ b/server/config/persist_options.go
@@ -31,11 +31,11 @@ import (
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/cache"
 	"github.com/tikv/pd/pkg/slice"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/etcdutil"
 	"github.com/tikv/pd/pkg/utils/typeutil"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/core/storelimit"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"go.etcd.io/etcd/clientv3"
 )
 
diff --git a/server/config/service_middleware_persist_options.go b/server/config/service_middleware_persist_options.go
index 20f8c110a..2dd9d245f 100644
--- a/server/config/service_middleware_persist_options.go
+++ b/server/config/service_middleware_persist_options.go
@@ -19,7 +19,7 @@ import (
 	"sync/atomic"
 
 	"github.com/pingcap/failpoint"
-	"github.com/tikv/pd/server/storage/endpoint"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 )
 
 // ServiceMiddlewarePersistOptions wraps all service middleware configurations that need to persist to storage and
diff --git a/server/gc/safepoint.go b/server/gc/safepoint.go
index 164282dc3..167f0319d 100644
--- a/server/gc/safepoint.go
+++ b/server/gc/safepoint.go
@@ -18,8 +18,8 @@ import (
 	"math"
 	"time"
 
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/syncutil"
-	"github.com/tikv/pd/server/storage/endpoint"
 )
 
 // SafePointManager is the manager for safePoint of GC and services.
diff --git a/server/grpc_service.go b/server/grpc_service.go
index 7939c1e0d..8a5685c7b 100644
--- a/server/grpc_service.go
+++ b/server/grpc_service.go
@@ -28,15 +28,15 @@ import (
 	"github.com/pingcap/kvproto/pkg/pdpb"
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/storage/kv"
 	"github.com/tikv/pd/pkg/utils/grpcutil"
 	"github.com/tikv/pd/pkg/utils/logutil"
 	"github.com/tikv/pd/pkg/utils/tsoutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/cluster"
 	"github.com/tikv/pd/server/core"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"github.com/tikv/pd/server/tso"
-	"github.com/tikv/pd/server/versioninfo"
 	"go.etcd.io/etcd/clientv3"
 	"go.uber.org/zap"
 	"google.golang.org/grpc"
diff --git a/server/keyspace/keyspace.go b/server/keyspace/keyspace.go
index 0daa933c5..2841e5c56 100644
--- a/server/keyspace/keyspace.go
+++ b/server/keyspace/keyspace.go
@@ -19,9 +19,9 @@ import (
 
 	"github.com/pingcap/errors"
 	"github.com/pingcap/kvproto/pkg/keyspacepb"
+	"github.com/tikv/pd/pkg/id"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/syncutil"
-	"github.com/tikv/pd/server/id"
-	"github.com/tikv/pd/server/storage/endpoint"
 )
 
 const (
diff --git a/server/keyspace_service.go b/server/keyspace_service.go
index 40c3d8145..fefc2315a 100644
--- a/server/keyspace_service.go
+++ b/server/keyspace_service.go
@@ -21,8 +21,8 @@ import (
 	"github.com/gogo/protobuf/proto"
 	"github.com/pingcap/kvproto/pkg/keyspacepb"
 	"github.com/pingcap/kvproto/pkg/pdpb"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/server/keyspace"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"go.etcd.io/etcd/clientv3"
 )
 
diff --git a/server/replication/replication_mode.go b/server/replication/replication_mode.go
index 8a2639cf8..b9c465dc5 100644
--- a/server/replication/replication_mode.go
+++ b/server/replication/replication_mode.go
@@ -29,12 +29,12 @@ import (
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
 	"github.com/tikv/pd/pkg/slice"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/logutil"
 	"github.com/tikv/pd/pkg/utils/syncutil"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"go.uber.org/zap"
 )
 
diff --git a/server/schedule/checker/rule_checker.go b/server/schedule/checker/rule_checker.go
index 48f213e40..e3b02b969 100644
--- a/server/schedule/checker/rule_checker.go
+++ b/server/schedule/checker/rule_checker.go
@@ -26,12 +26,12 @@ import (
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/cache"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/schedule/filter"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/placement"
-	"github.com/tikv/pd/server/versioninfo"
 	"go.uber.org/zap"
 )
 
diff --git a/server/schedule/labeler/labeler.go b/server/schedule/labeler/labeler.go
index 5fe8ddc5a..d617f9c69 100644
--- a/server/schedule/labeler/labeler.go
+++ b/server/schedule/labeler/labeler.go
@@ -22,10 +22,10 @@ import (
 
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/syncutil"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule/rangelist"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"go.uber.org/zap"
 )
 
diff --git a/server/schedule/operator/builder.go b/server/schedule/operator/builder.go
index 919bc3b2d..0123ae85a 100644
--- a/server/schedule/operator/builder.go
+++ b/server/schedule/operator/builder.go
@@ -20,13 +20,13 @@ import (
 
 	"github.com/pingcap/errors"
 	"github.com/pingcap/kvproto/pkg/metapb"
+	"github.com/tikv/pd/pkg/id"
 	"github.com/tikv/pd/pkg/utils/typeutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
-	"github.com/tikv/pd/server/id"
 	"github.com/tikv/pd/server/schedule/filter"
 	"github.com/tikv/pd/server/schedule/placement"
-	"github.com/tikv/pd/server/versioninfo"
 )
 
 // ClusterInformer provides the necessary information for building operator.
diff --git a/server/schedule/operator_controller.go b/server/schedule/operator_controller.go
index 9fde1a11b..662fdb988 100644
--- a/server/schedule/operator_controller.go
+++ b/server/schedule/operator_controller.go
@@ -27,12 +27,12 @@ import (
 	"github.com/tikv/pd/pkg/cache"
 	"github.com/tikv/pd/pkg/errs"
 	"github.com/tikv/pd/pkg/utils/syncutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/core/storelimit"
 	"github.com/tikv/pd/server/schedule/hbstream"
 	"github.com/tikv/pd/server/schedule/labeler"
 	"github.com/tikv/pd/server/schedule/operator"
-	"github.com/tikv/pd/server/versioninfo"
 	"go.uber.org/zap"
 )
 
diff --git a/server/schedule/placement/rule_manager.go b/server/schedule/placement/rule_manager.go
index 9ce518650..ff13f155a 100644
--- a/server/schedule/placement/rule_manager.go
+++ b/server/schedule/placement/rule_manager.go
@@ -28,10 +28,10 @@ import (
 	"github.com/tikv/pd/pkg/codec"
 	"github.com/tikv/pd/pkg/errs"
 	"github.com/tikv/pd/pkg/slice"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/syncutil"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"go.uber.org/zap"
 	"golang.org/x/exp/slices"
 )
diff --git a/server/schedule/scheduler.go b/server/schedule/scheduler.go
index 61c3d15fe..e974041fa 100644
--- a/server/schedule/scheduler.go
+++ b/server/schedule/scheduler.go
@@ -23,10 +23,10 @@ import (
 	"github.com/pingcap/errors"
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"go.uber.org/zap"
 )
 
diff --git a/server/schedulers/balance_leader.go b/server/schedulers/balance_leader.go
index 1306fb16e..cc2b2090d 100644
--- a/server/schedulers/balance_leader.go
+++ b/server/schedulers/balance_leader.go
@@ -26,6 +26,7 @@ import (
 	"github.com/pingcap/log"
 	"github.com/prometheus/client_golang/prometheus"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/reflectutil"
 	"github.com/tikv/pd/pkg/utils/syncutil"
 	"github.com/tikv/pd/pkg/utils/typeutil"
@@ -34,7 +35,6 @@ import (
 	"github.com/tikv/pd/server/schedule/filter"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"github.com/unrolled/render"
 	"go.uber.org/zap"
 )
diff --git a/server/schedulers/balance_region.go b/server/schedulers/balance_region.go
index b71ccc082..4a78fc3e1 100644
--- a/server/schedulers/balance_region.go
+++ b/server/schedulers/balance_region.go
@@ -22,12 +22,12 @@ import (
 	"github.com/pingcap/log"
 	"github.com/prometheus/client_golang/prometheus"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/schedule/filter"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"go.uber.org/zap"
 )
 
diff --git a/server/schedulers/evict_leader.go b/server/schedulers/evict_leader.go
index c81c13e62..8249cb8bb 100644
--- a/server/schedulers/evict_leader.go
+++ b/server/schedulers/evict_leader.go
@@ -23,6 +23,7 @@ import (
 	"github.com/pingcap/failpoint"
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/apiutil"
 	"github.com/tikv/pd/pkg/utils/syncutil"
 	"github.com/tikv/pd/server/core"
@@ -30,7 +31,6 @@ import (
 	"github.com/tikv/pd/server/schedule/filter"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"github.com/unrolled/render"
 )
 
diff --git a/server/schedulers/evict_slow_store.go b/server/schedulers/evict_slow_store.go
index 606da127f..e2fc44174 100644
--- a/server/schedulers/evict_slow_store.go
+++ b/server/schedulers/evict_slow_store.go
@@ -18,11 +18,11 @@ import (
 	"github.com/pingcap/errors"
 	"github.com/pingcap/failpoint"
 	"github.com/pingcap/log"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"go.uber.org/zap"
 )
 
diff --git a/server/schedulers/grant_hot_region.go b/server/schedulers/grant_hot_region.go
index eeb7b3a77..39fde37eb 100644
--- a/server/schedulers/grant_hot_region.go
+++ b/server/schedulers/grant_hot_region.go
@@ -25,6 +25,7 @@ import (
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
 	"github.com/tikv/pd/pkg/slice"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/apiutil"
 	"github.com/tikv/pd/pkg/utils/syncutil"
 	"github.com/tikv/pd/server/core"
@@ -33,7 +34,6 @@ import (
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
 	"github.com/tikv/pd/server/statistics"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"github.com/unrolled/render"
 	"go.uber.org/zap"
 )
diff --git a/server/schedulers/grant_leader.go b/server/schedulers/grant_leader.go
index 9c4f1a540..95fc4061c 100644
--- a/server/schedulers/grant_leader.go
+++ b/server/schedulers/grant_leader.go
@@ -22,6 +22,7 @@ import (
 	"github.com/pingcap/errors"
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/apiutil"
 	"github.com/tikv/pd/pkg/utils/syncutil"
 	"github.com/tikv/pd/server/core"
@@ -29,7 +30,6 @@ import (
 	"github.com/tikv/pd/server/schedule/filter"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"github.com/unrolled/render"
 )
 
diff --git a/server/schedulers/hot_region.go b/server/schedulers/hot_region.go
index 041b3145d..fddaa61b2 100644
--- a/server/schedulers/hot_region.go
+++ b/server/schedulers/hot_region.go
@@ -27,6 +27,7 @@ import (
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
 	"github.com/tikv/pd/pkg/slice"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/syncutil"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
@@ -34,7 +35,6 @@ import (
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
 	"github.com/tikv/pd/server/statistics"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"go.uber.org/zap"
 )
 
diff --git a/server/schedulers/hot_region_config.go b/server/schedulers/hot_region_config.go
index 6a6179439..b4fa526c7 100644
--- a/server/schedulers/hot_region_config.go
+++ b/server/schedulers/hot_region_config.go
@@ -25,12 +25,12 @@ import (
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
 	"github.com/tikv/pd/pkg/slice"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/reflectutil"
 	"github.com/tikv/pd/pkg/utils/syncutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/statistics"
-	"github.com/tikv/pd/server/storage/endpoint"
-	"github.com/tikv/pd/server/versioninfo"
 	"github.com/unrolled/render"
 	"go.uber.org/zap"
 )
diff --git a/server/schedulers/label.go b/server/schedulers/label.go
index e566b317d..7a772f1e8 100644
--- a/server/schedulers/label.go
+++ b/server/schedulers/label.go
@@ -17,13 +17,13 @@ package schedulers
 import (
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/schedule/filter"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"go.uber.org/zap"
 )
 
diff --git a/server/schedulers/random_merge.go b/server/schedulers/random_merge.go
index c1b0be3ba..cfa8909f5 100644
--- a/server/schedulers/random_merge.go
+++ b/server/schedulers/random_merge.go
@@ -19,13 +19,13 @@ import (
 
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/schedule/checker"
 	"github.com/tikv/pd/server/schedule/filter"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
-	"github.com/tikv/pd/server/storage/endpoint"
 )
 
 const (
diff --git a/server/schedulers/scatter_range.go b/server/schedulers/scatter_range.go
index f35192e42..8579c2d14 100644
--- a/server/schedulers/scatter_range.go
+++ b/server/schedulers/scatter_range.go
@@ -21,13 +21,13 @@ import (
 	"github.com/gorilla/mux"
 	"github.com/pingcap/errors"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/apiutil"
 	"github.com/tikv/pd/pkg/utils/syncutil"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"github.com/unrolled/render"
 )
 
diff --git a/server/schedulers/shuffle_hot_region.go b/server/schedulers/shuffle_hot_region.go
index e6074a825..79ec205bf 100644
--- a/server/schedulers/shuffle_hot_region.go
+++ b/server/schedulers/shuffle_hot_region.go
@@ -20,13 +20,13 @@ import (
 	"github.com/pingcap/kvproto/pkg/metapb"
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/schedule/filter"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
 	"github.com/tikv/pd/server/statistics"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"go.uber.org/zap"
 )
 
diff --git a/server/schedulers/shuffle_leader.go b/server/schedulers/shuffle_leader.go
index c07f1abb3..038a6b0b3 100644
--- a/server/schedulers/shuffle_leader.go
+++ b/server/schedulers/shuffle_leader.go
@@ -17,12 +17,12 @@ package schedulers
 import (
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/schedule/filter"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
-	"github.com/tikv/pd/server/storage/endpoint"
 )
 
 const (
diff --git a/server/schedulers/shuffle_region.go b/server/schedulers/shuffle_region.go
index 02064038d..919ce3662 100644
--- a/server/schedulers/shuffle_region.go
+++ b/server/schedulers/shuffle_region.go
@@ -19,12 +19,12 @@ import (
 
 	"github.com/pingcap/kvproto/pkg/metapb"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/schedule/filter"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
-	"github.com/tikv/pd/server/storage/endpoint"
 )
 
 const (
diff --git a/server/schedulers/shuffle_region_config.go b/server/schedulers/shuffle_region_config.go
index 9c6c8274f..5f429a071 100644
--- a/server/schedulers/shuffle_region_config.go
+++ b/server/schedulers/shuffle_region_config.go
@@ -19,12 +19,12 @@ import (
 
 	"github.com/gorilla/mux"
 	"github.com/tikv/pd/pkg/slice"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/apiutil"
 	"github.com/tikv/pd/pkg/utils/syncutil"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/schedule/placement"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"github.com/unrolled/render"
 )
 
diff --git a/server/schedulers/split_bucket.go b/server/schedulers/split_bucket.go
index 4185cedf0..be69fda23 100644
--- a/server/schedulers/split_bucket.go
+++ b/server/schedulers/split_bucket.go
@@ -23,13 +23,13 @@ import (
 
 	"github.com/gorilla/mux"
 	"github.com/pingcap/kvproto/pkg/pdpb"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/syncutil"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
 	"github.com/tikv/pd/server/statistics/buckets"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"github.com/unrolled/render"
 )
 
diff --git a/server/schedulers/transfer_witness_leader.go b/server/schedulers/transfer_witness_leader.go
index 2770de9c3..5d2980fc0 100644
--- a/server/schedulers/transfer_witness_leader.go
+++ b/server/schedulers/transfer_witness_leader.go
@@ -18,12 +18,12 @@ import (
 	"github.com/pingcap/errors"
 	"github.com/pingcap/log"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/schedule/filter"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
-	"github.com/tikv/pd/server/storage/endpoint"
 )
 
 const (
diff --git a/server/server.go b/server/server.go
index 525b4b235..b2483ecd3 100644
--- a/server/server.go
+++ b/server/server.go
@@ -42,8 +42,10 @@ import (
 	"github.com/tikv/pd/pkg/audit"
 	"github.com/tikv/pd/pkg/encryption"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/id"
 	"github.com/tikv/pd/pkg/member"
 	"github.com/tikv/pd/pkg/ratelimit"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/storage/kv"
 	"github.com/tikv/pd/pkg/systimemon"
 	"github.com/tikv/pd/pkg/utils/apiutil"
@@ -53,20 +55,18 @@ import (
 	"github.com/tikv/pd/pkg/utils/logutil"
 	"github.com/tikv/pd/pkg/utils/tsoutil"
 	"github.com/tikv/pd/pkg/utils/typeutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/cluster"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/gc"
-	"github.com/tikv/pd/server/id"
 	"github.com/tikv/pd/server/keyspace"
 	syncer "github.com/tikv/pd/server/region_syncer"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/schedule/hbstream"
 	"github.com/tikv/pd/server/schedule/placement"
 	"github.com/tikv/pd/server/storage"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"github.com/tikv/pd/server/tso"
-	"github.com/tikv/pd/server/versioninfo"
 	"github.com/urfave/negroni"
 	"go.etcd.io/etcd/clientv3"
 	"go.etcd.io/etcd/embed"
diff --git a/server/storage/etcd_backend.go b/server/storage/etcd_backend.go
index 18f18f8f9..f354c1bb0 100644
--- a/server/storage/etcd_backend.go
+++ b/server/storage/etcd_backend.go
@@ -15,8 +15,8 @@
 package storage
 
 import (
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/storage/kv"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"go.etcd.io/etcd/clientv3"
 )
 
diff --git a/server/storage/leveldb_backend.go b/server/storage/leveldb_backend.go
index 6bea0b701..25044008f 100644
--- a/server/storage/leveldb_backend.go
+++ b/server/storage/leveldb_backend.go
@@ -25,9 +25,9 @@ import (
 	"github.com/syndtr/goleveldb/leveldb"
 	"github.com/tikv/pd/pkg/encryption"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/storage/kv"
 	"github.com/tikv/pd/pkg/utils/syncutil"
-	"github.com/tikv/pd/server/storage/endpoint"
 )
 
 const (
diff --git a/server/storage/memory_backend.go b/server/storage/memory_backend.go
index 07b5279aa..2d1db8d8b 100644
--- a/server/storage/memory_backend.go
+++ b/server/storage/memory_backend.go
@@ -15,8 +15,8 @@
 package storage
 
 import (
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/storage/kv"
-	"github.com/tikv/pd/server/storage/endpoint"
 )
 
 // memoryStorage is a storage that stores data in a memory B-Tree without any locks,
diff --git a/server/storage/storage.go b/server/storage/storage.go
index 393a71e03..4a4d4c604 100644
--- a/server/storage/storage.go
+++ b/server/storage/storage.go
@@ -20,10 +20,10 @@ import (
 
 	"github.com/pingcap/kvproto/pkg/metapb"
 	"github.com/tikv/pd/pkg/encryption"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/storage/kv"
 	"github.com/tikv/pd/pkg/utils/syncutil"
 	"github.com/tikv/pd/server/core"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"go.etcd.io/etcd/clientv3"
 )
 
diff --git a/server/util.go b/server/util.go
index 421927ac1..3d03e56e7 100644
--- a/server/util.go
+++ b/server/util.go
@@ -26,8 +26,8 @@ import (
 	"github.com/tikv/pd/pkg/errs"
 	"github.com/tikv/pd/pkg/utils/etcdutil"
 	"github.com/tikv/pd/pkg/utils/typeutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
-	"github.com/tikv/pd/server/versioninfo"
 	"go.etcd.io/etcd/clientv3"
 	"go.uber.org/zap"
 )
diff --git a/tools/pd-simulator/simulator/config.go b/tools/pd-simulator/simulator/config.go
index 000d0de4b..c26325950 100644
--- a/tools/pd-simulator/simulator/config.go
+++ b/tools/pd-simulator/simulator/config.go
@@ -23,9 +23,9 @@ import (
 	"github.com/docker/go-units"
 	"github.com/tikv/pd/pkg/utils/tempurl"
 	"github.com/tikv/pd/pkg/utils/typeutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/schedule/placement"
-	"github.com/tikv/pd/server/versioninfo"
 )
 
 const (


Test patch:
diff --git a/server/api/config_test.go b/server/api/config_test.go
index 1d7093bd8..b7a895530 100644
--- a/server/api/config_test.go
+++ b/server/api/config_test.go
@@ -23,9 +23,9 @@ import (
 	"github.com/stretchr/testify/suite"
 	tu "github.com/tikv/pd/pkg/utils/testutil"
 	"github.com/tikv/pd/pkg/utils/typeutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server"
 	"github.com/tikv/pd/server/config"
-	"github.com/tikv/pd/server/versioninfo"
 )
 
 type configTestSuite struct {
diff --git a/server/api/operator_test.go b/server/api/operator_test.go
index c120a9b3d..d5995921f 100644
--- a/server/api/operator_test.go
+++ b/server/api/operator_test.go
@@ -32,12 +32,12 @@ import (
 	"github.com/tikv/pd/pkg/mock/mockhbstream"
 	"github.com/tikv/pd/pkg/utils/apiutil"
 	tu "github.com/tikv/pd/pkg/utils/testutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	pdoperator "github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/placement"
-	"github.com/tikv/pd/server/versioninfo"
 )
 
 type operatorTestSuite struct {
diff --git a/server/api/service_gc_safepoint_test.go b/server/api/service_gc_safepoint_test.go
index 3f15bc24a..b6661f6b8 100644
--- a/server/api/service_gc_safepoint_test.go
+++ b/server/api/service_gc_safepoint_test.go
@@ -22,9 +22,9 @@ import (
 
 	"github.com/pingcap/kvproto/pkg/metapb"
 	"github.com/stretchr/testify/suite"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/apiutil"
 	"github.com/tikv/pd/server"
-	"github.com/tikv/pd/server/storage/endpoint"
 )
 
 type serviceGCSafepointTestSuite struct {
diff --git a/server/api/status_test.go b/server/api/status_test.go
index bedf6c0e5..7017c4271 100644
--- a/server/api/status_test.go
+++ b/server/api/status_test.go
@@ -20,7 +20,7 @@ import (
 	"testing"
 
 	"github.com/stretchr/testify/require"
-	"github.com/tikv/pd/server/versioninfo"
+	"github.com/tikv/pd/pkg/versioninfo"
 )
 
 func checkStatusResponse(re *require.Assertions, body []byte) {
diff --git a/server/cluster/cluster_test.go b/server/cluster/cluster_test.go
index b08c259d6..c8dbca4bb 100644
--- a/server/cluster/cluster_test.go
+++ b/server/cluster/cluster_test.go
@@ -29,11 +29,12 @@ import (
 	"github.com/pingcap/kvproto/pkg/pdpb"
 	"github.com/stretchr/testify/require"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/id"
 	"github.com/tikv/pd/pkg/mock/mockid"
 	"github.com/tikv/pd/pkg/progress"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
-	"github.com/tikv/pd/server/id"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/schedule/filter"
 	"github.com/tikv/pd/server/schedule/labeler"
@@ -41,7 +42,6 @@ import (
 	"github.com/tikv/pd/server/schedulers"
 	"github.com/tikv/pd/server/statistics"
 	"github.com/tikv/pd/server/storage"
-	"github.com/tikv/pd/server/versioninfo"
 )
 
 func TestStoreHeartbeat(t *testing.T) {
diff --git a/server/core/region_test.go b/server/core/region_test.go
index 412d922b7..b4bacac6b 100644
--- a/server/core/region_test.go
+++ b/server/core/region_test.go
@@ -24,8 +24,8 @@ import (
 	"github.com/pingcap/kvproto/pkg/metapb"
 	"github.com/pingcap/kvproto/pkg/pdpb"
 	"github.com/stretchr/testify/require"
+	"github.com/tikv/pd/pkg/id"
 	"github.com/tikv/pd/pkg/mock/mockid"
-	"github.com/tikv/pd/server/id"
 )
 
 func TestNeedMerge(t *testing.T) {
diff --git a/server/gc/safepoint_test.go b/server/gc/safepoint_test.go
index dd42745b3..41ce02639 100644
--- a/server/gc/safepoint_test.go
+++ b/server/gc/safepoint_test.go
@@ -21,8 +21,8 @@ import (
 	"time"
 
 	"github.com/stretchr/testify/require"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/storage/kv"
-	"github.com/tikv/pd/server/storage/endpoint"
 )
 
 func newGCStorage() endpoint.GCSafePointStorage {
diff --git a/server/keyspace/keyspace_test.go b/server/keyspace/keyspace_test.go
index ed9a30f73..31ea0930c 100644
--- a/server/keyspace/keyspace_test.go
+++ b/server/keyspace/keyspace_test.go
@@ -25,8 +25,8 @@ import (
 	"github.com/pingcap/kvproto/pkg/keyspacepb"
 	"github.com/stretchr/testify/require"
 	"github.com/tikv/pd/pkg/mock/mockid"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/storage/kv"
-	"github.com/tikv/pd/server/storage/endpoint"
 )
 
 const (
diff --git a/server/schedule/checker/learner_checker_test.go b/server/schedule/checker/learner_checker_test.go
index afe4b9203..b55550d97 100644
--- a/server/schedule/checker/learner_checker_test.go
+++ b/server/schedule/checker/learner_checker_test.go
@@ -21,10 +21,10 @@ import (
 	"github.com/pingcap/kvproto/pkg/metapb"
 	"github.com/stretchr/testify/require"
 	"github.com/tikv/pd/pkg/mock/mockcluster"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule/operator"
-	"github.com/tikv/pd/server/versioninfo"
 )
 
 func TestPromoteLearner(t *testing.T) {
diff --git a/server/schedule/checker/merge_checker_test.go b/server/schedule/checker/merge_checker_test.go
index 77030125a..2c2d4aac3 100644
--- a/server/schedule/checker/merge_checker_test.go
+++ b/server/schedule/checker/merge_checker_test.go
@@ -24,6 +24,7 @@ import (
 	"github.com/stretchr/testify/suite"
 	"github.com/tikv/pd/pkg/mock/mockcluster"
 	"github.com/tikv/pd/pkg/utils/testutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/core/storelimit"
@@ -32,7 +33,6 @@ import (
 	"github.com/tikv/pd/server/schedule/labeler"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/placement"
-	"github.com/tikv/pd/server/versioninfo"
 	"go.uber.org/goleak"
 )
 
diff --git a/server/schedule/checker/replica_checker_test.go b/server/schedule/checker/replica_checker_test.go
index e2a5bbfaf..857107489 100644
--- a/server/schedule/checker/replica_checker_test.go
+++ b/server/schedule/checker/replica_checker_test.go
@@ -26,10 +26,10 @@ import (
 	"github.com/tikv/pd/pkg/cache"
 	"github.com/tikv/pd/pkg/mock/mockcluster"
 	"github.com/tikv/pd/pkg/utils/testutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule/operator"
-	"github.com/tikv/pd/server/versioninfo"
 )
 
 type replicaCheckerTestSuite struct {
diff --git a/server/schedule/checker/rule_checker_test.go b/server/schedule/checker/rule_checker_test.go
index 6a0297c21..ae3419895 100644
--- a/server/schedule/checker/rule_checker_test.go
+++ b/server/schedule/checker/rule_checker_test.go
@@ -28,11 +28,11 @@ import (
 	"github.com/tikv/pd/pkg/errs"
 	"github.com/tikv/pd/pkg/mock/mockcluster"
 	"github.com/tikv/pd/pkg/utils/testutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/placement"
-	"github.com/tikv/pd/server/versioninfo"
 )
 
 func TestRuleCheckerTestSuite(t *testing.T) {
diff --git a/server/schedule/labeler/labeler_test.go b/server/schedule/labeler/labeler_test.go
index bbf7aba7d..8a435bf01 100644
--- a/server/schedule/labeler/labeler_test.go
+++ b/server/schedule/labeler/labeler_test.go
@@ -25,8 +25,9 @@ import (
 
 	"github.com/pingcap/failpoint"
 	"github.com/stretchr/testify/require"
+	"github.com/tikv/pd/pkg/storage/endpoint"
+	"github.com/tikv/pd/pkg/storage/kv"
 	"github.com/tikv/pd/server/core"
-	"github.com/tikv/pd/server/storage"
 )
 
 func TestAdjustRule(t *testing.T) {
@@ -89,7 +90,7 @@ func TestAdjustRule2(t *testing.T) {
 
 func TestGetSetRule(t *testing.T) {
 	re := require.New(t)
-	store := storage.NewStorageWithMemoryBackend()
+	store := endpoint.NewStorageEndpoint(kv.NewMemoryKV(), nil)
 	labeler, err := NewRegionLabeler(context.Background(), store, time.Millisecond*10)
 	re.NoError(err)
 	rules := []*LabelRule{
@@ -135,7 +136,7 @@ func TestGetSetRule(t *testing.T) {
 
 func TestIndex(t *testing.T) {
 	re := require.New(t)
-	store := storage.NewStorageWithMemoryBackend()
+	store := endpoint.NewStorageEndpoint(kv.NewMemoryKV(), nil)
 	labeler, err := NewRegionLabeler(context.Background(), store, time.Millisecond*10)
 	re.NoError(err)
 	rules := []*LabelRule{
@@ -177,7 +178,7 @@ func TestIndex(t *testing.T) {
 
 func TestSaveLoadRule(t *testing.T) {
 	re := require.New(t)
-	store := storage.NewStorageWithMemoryBackend()
+	store := endpoint.NewStorageEndpoint(kv.NewMemoryKV(), nil)
 	labeler, err := NewRegionLabeler(context.Background(), store, time.Millisecond*10)
 	re.NoError(err)
 	rules := []*LabelRule{
@@ -222,7 +223,7 @@ func expectSameRules(re *require.Assertions, r1, r2 *LabelRule) {
 
 func TestKeyRange(t *testing.T) {
 	re := require.New(t)
-	store := storage.NewStorageWithMemoryBackend()
+	store := endpoint.NewStorageEndpoint(kv.NewMemoryKV(), nil)
 	labeler, err := NewRegionLabeler(context.Background(), store, time.Millisecond*10)
 	re.NoError(err)
 	rules := []*LabelRule{
@@ -263,7 +264,7 @@ func TestKeyRange(t *testing.T) {
 
 func TestLabelerRuleTTL(t *testing.T) {
 	re := require.New(t)
-	store := storage.NewStorageWithMemoryBackend()
+	store := endpoint.NewStorageEndpoint(kv.NewMemoryKV(), nil)
 	labeler, err := NewRegionLabeler(context.Background(), store, time.Millisecond*10)
 	re.NoError(err)
 	rules := []*LabelRule{
@@ -336,7 +337,7 @@ func checkRuleInMemoryAndStoage(re *require.Assertions, labeler *RegionLabeler,
 func TestGC(t *testing.T) {
 	re := require.New(t)
 	// set gcInterval to 1 hour.
-	store := storage.NewStorageWithMemoryBackend()
+	store := endpoint.NewStorageEndpoint(kv.NewMemoryKV(), nil)
 	labeler, err := NewRegionLabeler(context.Background(), store, time.Hour)
 	re.NoError(err)
 	ttls := []string{"1ms", "1ms", "1ms", "5ms", "5ms", "10ms", "1h", "24h"}
diff --git a/server/schedule/operator/create_operator_test.go b/server/schedule/operator/create_operator_test.go
index 33f6658af..ae4b117d4 100644
--- a/server/schedule/operator/create_operator_test.go
+++ b/server/schedule/operator/create_operator_test.go
@@ -25,10 +25,10 @@ import (
 	"github.com/stretchr/testify/require"
 	"github.com/stretchr/testify/suite"
 	"github.com/tikv/pd/pkg/mock/mockcluster"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule/placement"
-	"github.com/tikv/pd/server/versioninfo"
 )
 
 type createOperatorTestSuite struct {
diff --git a/server/schedule/placement/rule_manager_test.go b/server/schedule/placement/rule_manager_test.go
index e518ff085..21735341a 100644
--- a/server/schedule/placement/rule_manager_test.go
+++ b/server/schedule/placement/rule_manager_test.go
@@ -21,14 +21,14 @@ import (
 	"github.com/pingcap/kvproto/pkg/metapb"
 	"github.com/stretchr/testify/require"
 	"github.com/tikv/pd/pkg/codec"
+	"github.com/tikv/pd/pkg/storage/endpoint"
+	"github.com/tikv/pd/pkg/storage/kv"
 	"github.com/tikv/pd/server/core"
-	"github.com/tikv/pd/server/storage"
-	"github.com/tikv/pd/server/storage/endpoint"
 )
 
 func newTestManager(t *testing.T) (endpoint.RuleStorage, *RuleManager) {
 	re := require.New(t)
-	store := storage.NewStorageWithMemoryBackend()
+	store := endpoint.NewStorageEndpoint(kv.NewMemoryKV(), nil)
 	var err error
 	manager := NewRuleManager(store, nil, nil)
 	err = manager.Initialize(3, []string{"zone", "rack", "host"})
diff --git a/server/schedule/region_scatterer_test.go b/server/schedule/region_scatterer_test.go
index 8e88c5555..965b5b989 100644
--- a/server/schedule/region_scatterer_test.go
+++ b/server/schedule/region_scatterer_test.go
@@ -27,12 +27,12 @@ import (
 	"github.com/pingcap/kvproto/pkg/metapb"
 	"github.com/stretchr/testify/require"
 	"github.com/tikv/pd/pkg/mock/mockcluster"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule/hbstream"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/placement"
-	"github.com/tikv/pd/server/versioninfo"
 )
 
 type sequencer struct {
diff --git a/server/schedulers/balance_test.go b/server/schedulers/balance_test.go
index ede6aa069..d1fb637d9 100644
--- a/server/schedulers/balance_test.go
+++ b/server/schedulers/balance_test.go
@@ -27,6 +27,7 @@ import (
 	"github.com/stretchr/testify/suite"
 	"github.com/tikv/pd/pkg/mock/mockcluster"
 	"github.com/tikv/pd/pkg/utils/testutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
@@ -34,7 +35,6 @@ import (
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/schedule/plan"
 	"github.com/tikv/pd/server/storage"
-	"github.com/tikv/pd/server/versioninfo"
 )
 
 type testBalanceSpeedCase struct {
diff --git a/server/schedulers/hot_region_test.go b/server/schedulers/hot_region_test.go
index e75bc0324..19ba8c638 100644
--- a/server/schedulers/hot_region_test.go
+++ b/server/schedulers/hot_region_test.go
@@ -25,8 +25,10 @@ import (
 	"github.com/pingcap/kvproto/pkg/metapb"
 	"github.com/stretchr/testify/require"
 	"github.com/tikv/pd/pkg/mock/mockcluster"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/testutil"
 	"github.com/tikv/pd/pkg/utils/typeutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
@@ -34,8 +36,6 @@ import (
 	"github.com/tikv/pd/server/schedule/placement"
 	"github.com/tikv/pd/server/statistics"
 	"github.com/tikv/pd/server/storage"
-	"github.com/tikv/pd/server/storage/endpoint"
-	"github.com/tikv/pd/server/versioninfo"
 )
 
 func init() {
diff --git a/server/schedulers/hot_region_v2_test.go b/server/schedulers/hot_region_v2_test.go
index c321adeab..411286b48 100644
--- a/server/schedulers/hot_region_v2_test.go
+++ b/server/schedulers/hot_region_v2_test.go
@@ -22,12 +22,12 @@ import (
 	"github.com/stretchr/testify/require"
 	"github.com/tikv/pd/pkg/mock/mockcluster"
 	"github.com/tikv/pd/pkg/utils/testutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/schedule"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/statistics"
 	"github.com/tikv/pd/server/storage"
-	"github.com/tikv/pd/server/versioninfo"
 )
 
 func TestHotWriteRegionScheduleWithRevertRegionsDimSecond(t *testing.T) {
diff --git a/server/schedulers/scheduler_test.go b/server/schedulers/scheduler_test.go
index a4875153a..c6cf0caa6 100644
--- a/server/schedulers/scheduler_test.go
+++ b/server/schedulers/scheduler_test.go
@@ -23,6 +23,7 @@ import (
 	"github.com/stretchr/testify/require"
 	"github.com/tikv/pd/pkg/mock/mockcluster"
 	"github.com/tikv/pd/pkg/utils/testutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/schedule"
@@ -30,7 +31,6 @@ import (
 	"github.com/tikv/pd/server/schedule/placement"
 	"github.com/tikv/pd/server/statistics"
 	"github.com/tikv/pd/server/storage"
-	"github.com/tikv/pd/server/versioninfo"
 )
 
 func TestShuffleLeader(t *testing.T) {
diff --git a/server/storage/keyspace_test.go b/server/storage/keyspace_test.go
index 967a87c28..7d469dd06 100644
--- a/server/storage/keyspace_test.go
+++ b/server/storage/keyspace_test.go
@@ -20,7 +20,7 @@ import (
 
 	"github.com/pingcap/kvproto/pkg/keyspacepb"
 	"github.com/stretchr/testify/require"
-	"github.com/tikv/pd/server/storage/endpoint"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 )
 
 func TestSaveLoadKeyspace(t *testing.T) {
diff --git a/server/storage/storage_gc_test.go b/server/storage/storage_gc_test.go
index 76540f05a..e7d6d36df 100644
--- a/server/storage/storage_gc_test.go
+++ b/server/storage/storage_gc_test.go
@@ -21,7 +21,7 @@ import (
 
 	"github.com/pingcap/failpoint"
 	"github.com/stretchr/testify/require"
-	"github.com/tikv/pd/server/storage/endpoint"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 )
 
 func testGCSafePoints() ([]string, []uint64) {
@@ -102,7 +102,7 @@ func TestLoadMinServiceSafePoint(t *testing.T) {
 		re.NoError(storage.SaveServiceSafePoint(testKeySpace, serviceSafePoint))
 	}
 	// enabling failpoint to make expired key removal immediately observable
-	re.NoError(failpoint.Enable("github.com/tikv/pd/server/storage/endpoint/removeExpiredKeys", "return(true)"))
+	re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/storage/endpoint/removeExpiredKeys", "return(true)"))
 	minSafePoint, err := storage.LoadMinServiceSafePoint(testKeySpace, currentTime)
 	re.NoError(err)
 	re.Equal(serviceSafePoints[0], minSafePoint)
@@ -121,7 +121,7 @@ func TestLoadMinServiceSafePoint(t *testing.T) {
 	ssp, err = storage.LoadMinServiceSafePoint(testKeySpace, currentTime.Add(500*time.Second))
 	re.NoError(err)
 	re.Nil(ssp)
-	re.NoError(failpoint.Disable("github.com/tikv/pd/server/storage/endpoint/removeExpiredKeys"))
+	re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/storage/endpoint/removeExpiredKeys"))
 }
 
 func TestRemoveServiceSafePoint(t *testing.T) {
diff --git a/server/storage/storage_test.go b/server/storage/storage_test.go
index 32e994f2b..5aa9f0265 100644
--- a/server/storage/storage_test.go
+++ b/server/storage/storage_test.go
@@ -28,8 +28,8 @@ import (
 	"github.com/pingcap/failpoint"
 	"github.com/pingcap/kvproto/pkg/metapb"
 	"github.com/stretchr/testify/require"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/server/core"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"go.etcd.io/etcd/clientv3"
 )
 
diff --git a/tests/client/client_test.go b/tests/client/client_test.go
index eaaee3609..dd31aa0c6 100644
--- a/tests/client/client_test.go
+++ b/tests/client/client_test.go
@@ -34,6 +34,7 @@ import (
 	"github.com/stretchr/testify/suite"
 	pd "github.com/tikv/pd/client"
 	"github.com/tikv/pd/pkg/mock/mockid"
+	"github.com/tikv/pd/pkg/storage/endpoint"
 	"github.com/tikv/pd/pkg/utils/assertutil"
 	"github.com/tikv/pd/pkg/utils/testutil"
 	"github.com/tikv/pd/pkg/utils/tsoutil"
@@ -41,7 +42,6 @@ import (
 	"github.com/tikv/pd/server"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
-	"github.com/tikv/pd/server/storage/endpoint"
 	"github.com/tikv/pd/server/tso"
 	"github.com/tikv/pd/tests"
 	"go.uber.org/goleak"
diff --git a/tests/cluster.go b/tests/cluster.go
index 730f70c13..fb1682fab 100644
--- a/tests/cluster.go
+++ b/tests/cluster.go
@@ -30,6 +30,7 @@ import (
 	"github.com/tikv/pd/pkg/autoscaling"
 	"github.com/tikv/pd/pkg/dashboard"
 	"github.com/tikv/pd/pkg/errs"
+	"github.com/tikv/pd/pkg/id"
 	"github.com/tikv/pd/pkg/swaggerserver"
 	"github.com/tikv/pd/pkg/utils/testutil"
 	"github.com/tikv/pd/server"
@@ -38,7 +39,6 @@ import (
 	"github.com/tikv/pd/server/cluster"
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
-	"github.com/tikv/pd/server/id"
 	"github.com/tikv/pd/server/join"
 	"github.com/tikv/pd/server/tso"
 	"go.etcd.io/etcd/clientv3"
diff --git a/tests/pdctl/helper.go b/tests/pdctl/helper.go
index 608bee71e..87e2ecb04 100644
--- a/tests/pdctl/helper.go
+++ b/tests/pdctl/helper.go
@@ -25,10 +25,10 @@ import (
 	"github.com/spf13/cobra"
 	"github.com/stretchr/testify/require"
 	"github.com/tikv/pd/pkg/utils/typeutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server"
 	"github.com/tikv/pd/server/api"
 	"github.com/tikv/pd/server/core"
-	"github.com/tikv/pd/server/versioninfo"
 	"github.com/tikv/pd/tests"
 )
 
diff --git a/tests/pdctl/scheduler/scheduler_test.go b/tests/pdctl/scheduler/scheduler_test.go
index e47fb9be2..5185bdd9d 100644
--- a/tests/pdctl/scheduler/scheduler_test.go
+++ b/tests/pdctl/scheduler/scheduler_test.go
@@ -23,8 +23,8 @@ import (
 	"github.com/pingcap/kvproto/pkg/metapb"
 	"github.com/stretchr/testify/require"
 	"github.com/tikv/pd/pkg/utils/testutil"
+	"github.com/tikv/pd/pkg/versioninfo"
 	"github.com/tikv/pd/server/config"
-	"github.com/tikv/pd/server/versioninfo"
 	"github.com/tikv/pd/tests"
 	"github.com/tikv/pd/tests/pdctl"
 	pdctlCmd "github.com/tikv/pd/tools/pd-ctl/pdctl"
diff --git a/tests/server/cluster/cluster_test.go b/tests/server/cluster/cluster_test.go
index a4b0f6bfc..7b74e3e3f 100644
--- a/tests/server/cluster/cluster_test.go
+++ b/tests/server/cluster/cluster_test.go
@@ -31,6 +31,7 @@ import (
 	"github.com/pingcap/kvproto/pkg/replication_modepb"
 	"github.com/stretchr/testify/require"
 	"github.com/tikv/pd/pkg/dashboard"
+	"github.com/tikv/pd/pkg/id"
 	"github.com/tikv/pd/pkg/mock/mockid"
 	"github.com/tikv/pd/pkg/utils/testutil"
 	"github.com/tikv/pd/pkg/utils/tsoutil"
@@ -40,7 +41,6 @@ import (
 	"github.com/tikv/pd/server/config"
 	"github.com/tikv/pd/server/core"
 	"github.com/tikv/pd/server/core/storelimit"
-	"github.com/tikv/pd/server/id"
 	syncer "github.com/tikv/pd/server/region_syncer"
 	"github.com/tikv/pd/server/schedule/operator"
 	"github.com/tikv/pd/server/storage"