From a24714c55305280838576fa6dec9a9781763e893 Mon Sep 17 00:00:00 2001
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Date: Fri, 13 Jan 2023 00:19:54 +0100
Subject: [PATCH] box: rename a few 'cluster's to 'replicaset's

In a few places visible to users and in iproto naming the term
"cluster" really means "replicaset". One of those places is a
part of public API - box.iproto.key.CLUSTER_UUID - which is not
yet released.

The commit renames "cluster" in those places as a preparation for
introduction of actual "cluster", like a set of replicasets. It
will start from introduction of cluster name in addition to
replicaset uuid/name.

There are places which still mention 'cluster', but their rename
would be breaking. It will be addressed in scope of a bigger
patchset.

Part of #5029

NO_CHANGELOG=Was not released

@TarantoolBot document
Title: Rename `IPROTO_CLUSTER_UUID` to `IPROTO_REPLICASET_UUID`

This is a name for one of the IProto keys. The key value doesn't
change and the protocol is still backward compatible. But better
rename it to `IPROTO_REPLICASET_UUID`, because in future
`IPROTO_CLUSTER_UUID` will most likely mean a different thing.
---
 src/box/iproto_constants.c                                  | 4 ++--
 src/box/iproto_constants.h                                  | 2 +-
 src/box/lua/iproto.c                                        | 2 +-
 src/box/xrow.c                                              | 6 +++---
 .../gh_7894_export_iproto_constants_and_features_test.lua   | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/box/iproto_constants.c b/src/box/iproto_constants.c
index 44cf625595..7a468e6b32 100644
--- a/src/box/iproto_constants.c
+++ b/src/box/iproto_constants.c
@@ -82,7 +82,7 @@ const unsigned char iproto_key_type[IPROTO_KEY_MAX] =
 	/* 0x22 */	MP_STR, /* IPROTO_FUNCTION_NAME */
 	/* 0x23 */	MP_STR, /* IPROTO_USER_NAME */
 	/* 0x24 */	MP_STR, /* IPROTO_INSTANCE_UUID */
-	/* 0x25 */	MP_STR, /* IPROTO_CLUSTER_UUID */
+	/* 0x25 */	MP_STR, /* IPROTO_REPLICASET_UUID */
 	/* 0x26 */	MP_MAP, /* IPROTO_VCLOCK */
 	/* 0x27 */	MP_STR, /* IPROTO_EXPR */
 	/* 0x28 */	MP_ARRAY, /* IPROTO_OPS */
@@ -236,7 +236,7 @@ const char *iproto_key_strs[IPROTO_KEY_MAX] = {
 	"function name",    /* 0x22 */
 	"user name",        /* 0x23 */
 	"instance uuid",    /* 0x24 */
-	"cluster uuid",     /* 0x25 */
+	"replicaset uuid",  /* 0x25 */
 	"vector clock",     /* 0x26 */
 	"expression",       /* 0x27 */
 	"operations",       /* 0x28 */
diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h
index aa8169d071..9a9a519b64 100644
--- a/src/box/iproto_constants.h
+++ b/src/box/iproto_constants.h
@@ -105,7 +105,7 @@ enum iproto_key {
 	 * the USER_NAME key.
 	 */
 	IPROTO_INSTANCE_UUID = 0x24,
-	IPROTO_CLUSTER_UUID = 0x25,
+	IPROTO_REPLICASET_UUID = 0x25,
 	IPROTO_VCLOCK = 0x26,
 
 	/* Also request keys. See the comment above. */
diff --git a/src/box/lua/iproto.c b/src/box/lua/iproto.c
index 7e8428f59e..7e4a173447 100644
--- a/src/box/lua/iproto.c
+++ b/src/box/lua/iproto.c
@@ -106,7 +106,7 @@ push_iproto_key_enum(struct lua_State *L)
 		{"FUNCTION_NAME", IPROTO_FUNCTION_NAME},
 		{"USER_NAME", IPROTO_USER_NAME},
 		{"INSTANCE_UUID", IPROTO_INSTANCE_UUID},
-		{"CLUSTER_UUID", IPROTO_CLUSTER_UUID},
+		{"REPLICASET_UUID", IPROTO_REPLICASET_UUID},
 		{"VCLOCK", IPROTO_VCLOCK},
 		{"EXPR", IPROTO_EXPR},
 		{"OPS", IPROTO_OPS},
diff --git a/src/box/xrow.c b/src/box/xrow.c
index 604f9ffd98..0cdb30e036 100644
--- a/src/box/xrow.c
+++ b/src/box/xrow.c
@@ -1907,7 +1907,7 @@ xrow_decode_ballot_event(const struct watch_request *req,
  * type, but the iproto keys are fixed.
  */
 struct replication_request {
-	/** IPROTO_CLUSTER_UUID. */
+	/** IPROTO_REPLICASET_UUID. */
 	struct tt_uuid *replicaset_uuid;
 	/** IPROTO_INSTANCE_UUID. */
 	struct tt_uuid *instance_uuid;
@@ -1937,7 +1937,7 @@ xrow_encode_replication_request(struct xrow_header *row,
 	uint32_t map_size = 0;
 	if (req->replicaset_uuid != NULL) {
 		++map_size;
-		data = mp_encode_uint(data, IPROTO_CLUSTER_UUID);
+		data = mp_encode_uint(data, IPROTO_REPLICASET_UUID);
 		data = xrow_encode_uuid(data, req->replicaset_uuid);
 	}
 	if (req->instance_uuid != NULL) {
@@ -2007,7 +2007,7 @@ xrow_decode_replication_request(const struct xrow_header *row,
 		}
 		uint8_t key = mp_decode_uint(&d);
 		switch (key) {
-		case IPROTO_CLUSTER_UUID:
+		case IPROTO_REPLICASET_UUID:
 			if (req->replicaset_uuid == NULL)
 				goto skip;
 			if (xrow_decode_uuid(&d, req->replicaset_uuid) != 0) {
diff --git a/test/box-luatest/gh_7894_export_iproto_constants_and_features_test.lua b/test/box-luatest/gh_7894_export_iproto_constants_and_features_test.lua
index 6529cd90ba..37b47cb145 100644
--- a/test/box-luatest/gh_7894_export_iproto_constants_and_features_test.lua
+++ b/test/box-luatest/gh_7894_export_iproto_constants_and_features_test.lua
@@ -47,7 +47,7 @@ local reference_table = {
         FUNCTION_NAME = 0x22,
         USER_NAME = 0x23,
         INSTANCE_UUID = 0x24,
-        CLUSTER_UUID = 0x25,
+        REPLICASET_UUID = 0x25,
         VCLOCK = 0x26,
         EXPR = 0x27,
         OPS = 0x28,
-- 
GitLab