From e507e90a222b487fe4b58ecfb13099fe4b4073e6 Mon Sep 17 00:00:00 2001 From: Igor Zolotarev Date: Wed, 15 May 2024 19:05:04 +0300 Subject: [PATCH] Add ddl-ee --- CHANGELOG.rst | 2 ++ cartridge/lua-api/boxinfo.lua | 8 +++++++- cartridge/twophase.lua | 15 ++++++++++++-- cartridge/utils.lua | 6 +++++- cartridge/vshard-utils.lua | 6 +++++- cartridge/webui/api-config.lua | 8 +++++++- cartridge/webui/api-ddl.lua | 17 +++++++++++++--- cartridge/webui/gql-boxinfo.lua | 4 ++++ webui/src/generated/graphql-typing-flow.js | 8 +++++--- webui/src/generated/graphql-typing-ts.ts | 23 +++++++++++++++++++--- webui/src/store/request/queries.graphql.js | 1 + 11 files changed, 83 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5d07ec9e0..41bf06060 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -38,6 +38,8 @@ Changed - Cartridge now uses ``vshard-ee`` instead of ``vshard`` if available. +- Cartridge now uses ``ddl-ee`` instead of ``ddl`` if available. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/cartridge/lua-api/boxinfo.lua b/cartridge/lua-api/boxinfo.lua index 3cc85ad9f..1f199b534 100644 --- a/cartridge/lua-api/boxinfo.lua +++ b/cartridge/lua-api/boxinfo.lua @@ -51,7 +51,7 @@ local function get_info(uri) local membership_myself = require('membership').myself() local membership_options = require('membership.options') - local vshard, vshard_version + local vshard, vshard_version, ddl_version if package.loaded['vshard-ee'] ~= nil then vshard = package.loaded['vshard-ee'] vshard_version = vshard._VERSION .. ' EE' @@ -60,6 +60,11 @@ local function get_info(uri) vshard_version = vshard._VERSION end + if package.loaded['ddl-ee'] ~= nil then + ddl_version = require('ddl-ee.version') .. ' EE' + elseif package.loaded['vshard'] ~= nil then + ddl_version = require('ddl.version') + end local routers = vshard and vshard.router.internal.routers or {} local router_info = {} @@ -201,6 +206,7 @@ local function get_info(uri) cartridge = { version = require('cartridge').VERSION, vshard_version = vshard_version, + ddl_version = ddl_version, state = server_state, error = server_error, }, diff --git a/cartridge/twophase.lua b/cartridge/twophase.lua index 584bd37a1..d8f761a0e 100644 --- a/cartridge/twophase.lua +++ b/cartridge/twophase.lua @@ -46,6 +46,17 @@ vars:new('options', { apply_config_timeout = 10, }) +local function get_ddl_manager() + local ddl_manager + local ok, _ = pcall(require, 'ddl-ee') + if not ok then + ddl_manager = service_registry.get('ddl-manager') + else + ddl_manager = service_registry.get('ddl-manager-ee') + end + return ddl_manager +end + local function release_config_lock() local prepared_config = vars.prepared_config vars.prepared_config = nil @@ -789,7 +800,7 @@ local function get_schema() ) end - local ddl_manager = assert(service_registry.get('ddl-manager')) + local ddl_manager = assert(get_ddl_manager()) return ddl_manager.get_clusterwide_schema_yaml() end @@ -809,7 +820,7 @@ local function set_schema(schema_yml) ) end - local ddl_manager = assert(service_registry.get('ddl-manager')) + local ddl_manager = assert(get_ddl_manager()) local ok, err = ddl_manager.set_clusterwide_schema_yaml(schema_yml) if ok == nil then return nil, err diff --git a/cartridge/utils.lua b/cartridge/utils.lua index f33b0c975..550823fb1 100644 --- a/cartridge/utils.lua +++ b/cartridge/utils.lua @@ -13,7 +13,11 @@ local errors = require('errors') local digest = require('digest') local tarantool = require('tarantool') -local semver = require('vshard.version') + +local ok, semver = pcall(require, 'vshard-ee.version') +if not ok then + semver = require('vshard.version') +end local FcntlError = errors.new_class('FcntlError') local OpenFileError = errors.new_class('OpenFileError') diff --git a/cartridge/vshard-utils.lua b/cartridge/vshard-utils.lua index d78ada8a2..b754c66b3 100644 --- a/cartridge/vshard-utils.lua +++ b/cartridge/vshard-utils.lua @@ -13,7 +13,11 @@ local topology = require('cartridge.topology') local failover = require('cartridge.failover') local twophase = require('cartridge.twophase') local confapplier = require('cartridge.confapplier') -local vshard_consts = require('vshard.consts') + +local ok, vshard_consts = pcall(require, 'vshard-ee.consts') +if not ok then + vshard_consts = require('vshard.consts') +end local ValidateConfigError = errors.new_class('ValidateConfigError') diff --git a/cartridge/webui/api-config.lua b/cartridge/webui/api-config.lua index ea2cb42a5..7fc1d05e5 100644 --- a/cartridge/webui/api-config.lua +++ b/cartridge/webui/api-config.lua @@ -286,7 +286,13 @@ local function validate_config(_, args) -- confapplier.validate_config as well but only for leaders. The -- following is used to perform the validation on non-leader instances. if patch['schema.yml'] and not require('cartridge.failover').is_leader() then - local ddl_manager = assert(service_registry.get('ddl-manager')) + local ddl_manager + local ok, _ = pcall(require, 'ddl-ee') + if not ok then + ddl_manager = assert(service_registry.get('ddl-manager')) + else + ddl_manager = assert(service_registry.get('ddl-manager-ee')) + end local ok, err = ddl_manager.check_schema_yaml(args.as_yaml) if not ok then if err.class_name == ddl_manager.CheckSchemaError.name then diff --git a/cartridge/webui/api-ddl.lua b/cartridge/webui/api-ddl.lua index 096511b40..d9c0c0786 100644 --- a/cartridge/webui/api-ddl.lua +++ b/cartridge/webui/api-ddl.lua @@ -8,6 +8,17 @@ local module_name = 'cartridge.webui.api-ddl' local GetSchemaError = errors.new_class('GetSchemaError') local CheckSchemaError = errors.new_class('CheckSchemaError') +local function get_ddl_manager() + local ddl_manager + local ok, _ = pcall(require, 'ddl-ee') + if not ok then + ddl_manager = service_registry.get('ddl-manager') + else + ddl_manager = service_registry.get('ddl-manager-ee') + end + return ddl_manager +end + local gql_type_schema = gql_types.object({ name = 'DDLSchema', description = 'The schema', @@ -35,7 +46,7 @@ local function graphql_get_schema() ) end - local ddl_manager = assert(service_registry.get('ddl-manager')) + local ddl_manager = assert(get_ddl_manager()) return {as_yaml = ddl_manager.get_clusterwide_schema_yaml()} end @@ -46,7 +57,7 @@ local function graphql_set_schema(_, args) ) end - local ddl_manager = assert(service_registry.get('ddl-manager')) + local ddl_manager = assert(get_ddl_manager()) local ok, err = ddl_manager.set_clusterwide_schema_yaml(args.as_yaml) if ok == nil then return nil, err @@ -62,7 +73,7 @@ local function graphql_check_schema(_, args) ) end - local ddl_manager = assert(service_registry.get('ddl-manager')) + local ddl_manager = assert(get_ddl_manager()) local ok, err = ddl_manager.check_schema_yaml(args.as_yaml) if ok then return { error = box.NULL } diff --git a/cartridge/webui/gql-boxinfo.lua b/cartridge/webui/gql-boxinfo.lua index 6b988eb3c..5ca31a4e4 100644 --- a/cartridge/webui/gql-boxinfo.lua +++ b/cartridge/webui/gql-boxinfo.lua @@ -361,6 +361,10 @@ local boxinfo_schema = { kind = gql_types.string, description = 'VShard version', }, + ddl_version = { + kind = gql_types.string, + description = 'DDL version', + }, } }).nonNull, membership = gql_types.object({ diff --git a/webui/src/generated/graphql-typing-flow.js b/webui/src/generated/graphql-typing-flow.js index 89b91f4c8..e1654dcd3 100644 --- a/webui/src/generated/graphql-typing-flow.js +++ b/webui/src/generated/graphql-typing-flow.js @@ -615,6 +615,8 @@ export type ServerInfoCartridge = {| version: $ElementType, /** VShard version */ vshard_version?: $ElementType, + /** DDL version */ + ddl_version?: $ElementType, |}; export type ServerInfoGeneral = {| @@ -1063,7 +1065,7 @@ export type ServerDetailsFieldsFragment = ({ ...{ __typename?: 'ServerInfo' }, ...{| cartridge: ({ ...{ __typename?: 'ServerInfoCartridge' }, - ...$Pick + ...$Pick }), membership: ({ ...{ __typename?: 'ServerInfoMembership' }, ...$Pick @@ -1120,7 +1122,7 @@ export type InstanceDataQuery = ({ ...{ __typename?: 'ServerInfo' }, ...{| cartridge: ({ ...{ __typename?: 'ServerInfoCartridge' }, - ...$Pick + ...$Pick }), membership: ({ ...{ __typename?: 'ServerInfoMembership' }, ...$Pick @@ -1226,7 +1228,7 @@ export type BoxInfoQuery = ({ ...{ __typename?: 'ServerInfo' }, ...{| cartridge: ({ ...{ __typename?: 'ServerInfoCartridge' }, - ...$Pick + ...$Pick }), membership: ({ ...{ __typename?: 'ServerInfoMembership' }, ...$Pick diff --git a/webui/src/generated/graphql-typing-ts.ts b/webui/src/generated/graphql-typing-ts.ts index 8d03d9e2d..37d594878 100644 --- a/webui/src/generated/graphql-typing-ts.ts +++ b/webui/src/generated/graphql-typing-ts.ts @@ -592,6 +592,8 @@ export type ServerInfoCartridge = { version: Scalars['String']; /** VShard version */ vshard_version?: Maybe; + /** DDL version */ + ddl_version?: Maybe; }; export type ServerInfoGeneral = { @@ -1170,7 +1172,12 @@ export type ServerDetailsFieldsFragment = { labels?: Array<{ __typename?: 'Label'; name: string; value: string } | null> | null; boxinfo?: { __typename?: 'ServerInfo'; - cartridge: { __typename?: 'ServerInfoCartridge'; version: string; vshard_version: string | null }; + cartridge: { + __typename?: 'ServerInfoCartridge'; + version: string; + vshard_version: string | null; + ddl_version: string | null; + }; membership: { __typename?: 'ServerInfoMembership'; status?: string | null; @@ -1298,7 +1305,12 @@ export type InstanceDataQuery = { labels?: Array<{ __typename?: 'Label'; name: string; value: string } | null> | null; boxinfo?: { __typename?: 'ServerInfo'; - cartridge: { __typename?: 'ServerInfoCartridge'; version: string; vshard_version: string | null }; + cartridge: { + __typename?: 'ServerInfoCartridge'; + version: string; + vshard_version: string | null; + ddl_version: string | null; + }; membership: { __typename?: 'ServerInfoMembership'; status?: string | null; @@ -1459,7 +1471,12 @@ export type BoxInfoQuery = { labels?: Array<{ __typename?: 'Label'; name: string; value: string } | null> | null; boxinfo?: { __typename?: 'ServerInfo'; - cartridge: { __typename?: 'ServerInfoCartridge'; version: string; vshard_version: string | null }; + cartridge: { + __typename?: 'ServerInfoCartridge'; + version: string; + vshard_version: string | null; + ddl_version: string | null; + }; membership: { __typename?: 'ServerInfoMembership'; status?: string | null; diff --git a/webui/src/store/request/queries.graphql.js b/webui/src/store/request/queries.graphql.js index f83b17793..7de9e0356 100644 --- a/webui/src/store/request/queries.graphql.js +++ b/webui/src/store/request/queries.graphql.js @@ -143,6 +143,7 @@ export const serverDetailsFields = gql` cartridge { version vshard_version + ddl_version } membership { status