Skip to content

Commit d91462b

Browse files
fix: prevent using the same name for local alias and remote cluster
Signed-off-by: panagiotisevaggelou <panagiotisevaggelou02@gmail.com>
1 parent 64d02d9 commit d91462b

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

docs/how-to/import-remote-cluster.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ At the primary cluster, this token can be imported to create the remote record.
2626
2727
sudo microceph remote import simple eyJmc2lkIjoiN2FiZmMwYmItNjIwNC00M2FmLTg4NDQtMjg3NDg2OGNiYTc0Iiwia2V5cmluZy5jbGllbnQubWFnaWNhbCI6IkFRQ0hJdmRtNG91SUNoQUFraGsvRldCUFI0WXZCRkpzUC92dDZ3PT0iLCJtb24uaG9zdC5zaW1wbGUtcmVpbmRlZXIiOiIxMC40Mi44OC42OSIsInB1YmxpY19uZXR3b3JrIjoiMTAuNDIuODguNjkvMjQifQ== --local-name magical
2828
29+
.. note::
30+
31+
The value of ``--local-name`` must be different from the remote cluster name (``simple`` in this example).
32+
Using the same name for both will result in an error to avoid conflicts during replication.
33+
2934
This will create the required $simple.conf and $simple.keyring files.
3035
Note: Importing a remote cluster is a uni-directional operation. For symmetric
3136
relations both clusters should be added as remotes at each other.

microceph/api/ops_replication.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ func cmdOpsReplication(s state.State, r *http.Request, patchRequest types.Replic
100100
return response.InternalError(err)
101101
}
102102

103+
if data.RemoteName == data.LocalAlias {
104+
return response.SmartError(fmt.Errorf("local alias (--local-name) and remote name must be different to avoid site conflicts"))
105+
}
106+
103107
// carry RbdReplicationRequest in interface object.
104108
data.SetAPIObjectId(resource)
105109
// Patch request type.

microceph/api/types/replication_rbd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ type RbdReplicationRequest struct {
9797
SourcePool string `json:"source_pool" yaml:"source_pool"`
9898
SourceImage string `json:"source_image" yaml:"source_image"`
9999
RemoteName string `json:"remote" yaml:"remote"`
100+
LocalAlias string `json:"local_alias" yaml:"local_alias"`
100101
// snapshot in d,h,m format
101102
Schedule string `json:"schedule" yaml:"schedule"`
102103
ReplicationType RbdReplicationType `json:"replication_type" yaml:"replication_type"`

0 commit comments

Comments
 (0)