Skip to content

Commit

Permalink
Use vshard-ee if available (#2237)
Browse files Browse the repository at this point in the history
Co-authored-by: Georgy Moiseev <[email protected]>
  • Loading branch information
yngvar-antonsson and DifferentialOrange authored May 21, 2024
1 parent f3ed7cf commit 6981250
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 28 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ and this project adheres to
Unreleased
-------------------------------------------------------------------------------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Added
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- VShard and DDL versions are displayed in the WebUI.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Changed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Cartridge now uses ``vshard-ee`` instead of ``vshard`` if available.

- Cartridge now uses ``ddl-ee`` instead of ``ddl`` if available.

-------------------------------------------------------------------------------
[2.11.0] - 2024-05-15
-------------------------------------------------------------------------------
Expand Down
18 changes: 17 additions & 1 deletion cartridge/lua-api/boxinfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,22 @@ local function get_info(uri)
local membership_myself = require('membership').myself()
local membership_options = require('membership.options')

local ok, vshard, vshard_version, ddl, ddl_version
ok, vshard = pcall(require, 'vshard-ee')
if ok then
vshard_version = vshard._VERSION .. ' EE'
else
vshard = require('vshard')
vshard_version = vshard._VERSION
end

local vshard = package.loaded.vshard
ok, ddl = pcall(require, 'ddl-ee')
if ok then
ddl_version = ddl._VERSION .. ' EE'
else
ddl = require('ddl')
ddl_version = ddl._VERSION
end

local routers = vshard and vshard.router.internal.routers or {}
local router_info = {}
Expand Down Expand Up @@ -193,6 +207,8 @@ local function get_info(uri)
},
cartridge = {
version = require('cartridge').VERSION,
vshard_version = vshard_version,
ddl_version = ddl_version,
state = server_state,
error = server_error,
},
Expand Down
7 changes: 6 additions & 1 deletion cartridge/roles/vshard-router.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
local log = require('log')
local vshard = require('vshard')

local ok, vshard = pcall(require, 'vshard-ee')
if not ok then
vshard = require('vshard')
end

local checks = require('checks')
local errors = require('errors')

Expand Down
7 changes: 6 additions & 1 deletion cartridge/roles/vshard-storage.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
local log = require('log')
local vshard = require('vshard')

local ok, vshard = pcall(require, 'vshard-ee')
if not ok then
vshard = require('vshard')
end

local checks = require('checks')

local vars = require('cartridge.vars').new('cartridge.roles.vshard-storage')
Expand Down
15 changes: 13 additions & 2 deletions cartridge/twophase.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion cartridge/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 5 additions & 1 deletion cartridge/vshard-utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
8 changes: 7 additions & 1 deletion cartridge/webui/api-config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions cartridge/webui/api-ddl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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 }
Expand Down
10 changes: 9 additions & 1 deletion cartridge/webui/gql-boxinfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,15 @@ local boxinfo_schema = {
description =
'Error details if instance is in' ..
' failure state',
}
},
vshard_version = {
kind = gql_types.string,
description = 'VShard version',
},
ddl_version = {
kind = gql_types.string,
description = 'DDL version',
},
}
}).nonNull,
membership = gql_types.object({
Expand Down
16 changes: 11 additions & 5 deletions doc/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# source: http://127.0.0.1:8081/admin/api
# timestamp: Thu Apr 25 2024 14:01:07 GMT+0300 (Moscow Standard Time)
# timestamp: Wed May 15 2024 19:16:51 GMT+0300 (Moscow Standard Time)

"""Custom scalar specification."""
directive @specifiedBy(
Expand Down Expand Up @@ -725,14 +725,20 @@ type ServerInfo {
}

type ServerInfoCartridge {
"""Current instance state"""
state: String!
"""Error details if instance is in failure state"""
error: Error

"""VShard version"""
vshard_version: String

"""Cartridge version"""
version: String!

"""Error details if instance is in failure state"""
error: Error
"""Current instance state"""
state: String!

"""DDL version"""
ddl_version: String
}

type ServerInfoGeneral {
Expand Down
6 changes: 6 additions & 0 deletions rst/cartridge_admin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ Cartridge doesn't support Tarantool 3.0 and higher.
- Tarantool 2.10
- Tarantool 2.11
- Additional notes
* - Cartridge scm-1
- \+
- \+
- \+
- \+
- Cartridge uses enterprise versions of ``vshard`` and ``ddl`` if available
* - Cartridge 2.11.0
- \+
- \+
Expand Down
5 changes: 0 additions & 5 deletions test/integration/vshardless_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ g.before_all = function()
}},
})
g.cluster:start()
g.cluster.main_server:eval([[
package.preload['vshard'] = function()
error('Requiring vshard is prohibited in this test', 0)
end
]])
end

g.after_all = function()
Expand Down
10 changes: 7 additions & 3 deletions webui/src/generated/graphql-typing-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,10 @@ export type ServerInfoCartridge = {|
state: $ElementType<Scalars, 'String'>,
/** Cartridge version */
version: $ElementType<Scalars, 'String'>,
/** VShard version */
vshard_version?: $ElementType<Scalars, 'String'>,
/** DDL version */
ddl_version?: $ElementType<Scalars, 'String'>,
|};

export type ServerInfoGeneral = {|
Expand Down Expand Up @@ -1061,7 +1065,7 @@ export type ServerDetailsFieldsFragment = ({
...{ __typename?: 'ServerInfo' },
...{| cartridge: ({
...{ __typename?: 'ServerInfoCartridge' },
...$Pick<ServerInfoCartridge, {| version: * |}>
...$Pick<ServerInfoCartridge, {| version: *, vshard_version?: *, ddl_version?: * |}>
}), membership: ({
...{ __typename?: 'ServerInfoMembership' },
...$Pick<ServerInfoMembership, {| status?: *, incarnation?: *, PROTOCOL_PERIOD_SECONDS?: *, ACK_TIMEOUT_SECONDS?: *, ANTI_ENTROPY_PERIOD_SECONDS?: *, SUSPECT_TIMEOUT_SECONDS?: *, NUM_FAILURE_DETECTION_SUBGROUPS?: * |}>
Expand Down Expand Up @@ -1118,7 +1122,7 @@ export type InstanceDataQuery = ({
...{ __typename?: 'ServerInfo' },
...{| cartridge: ({
...{ __typename?: 'ServerInfoCartridge' },
...$Pick<ServerInfoCartridge, {| version: * |}>
...$Pick<ServerInfoCartridge, {| version: *, vshard_version?: *, ddl_version?: * |}>
}), membership: ({
...{ __typename?: 'ServerInfoMembership' },
...$Pick<ServerInfoMembership, {| status?: *, incarnation?: *, PROTOCOL_PERIOD_SECONDS?: *, ACK_TIMEOUT_SECONDS?: *, ANTI_ENTROPY_PERIOD_SECONDS?: *, SUSPECT_TIMEOUT_SECONDS?: *, NUM_FAILURE_DETECTION_SUBGROUPS?: * |}>
Expand Down Expand Up @@ -1224,7 +1228,7 @@ export type BoxInfoQuery = ({
...{ __typename?: 'ServerInfo' },
...{| cartridge: ({
...{ __typename?: 'ServerInfoCartridge' },
...$Pick<ServerInfoCartridge, {| version: * |}>
...$Pick<ServerInfoCartridge, {| version: *, vshard_version?: *, ddl_version?: * |}>
}), membership: ({
...{ __typename?: 'ServerInfoMembership' },
...$Pick<ServerInfoMembership, {| status?: *, incarnation?: *, PROTOCOL_PERIOD_SECONDS?: *, ACK_TIMEOUT_SECONDS?: *, ANTI_ENTROPY_PERIOD_SECONDS?: *, SUSPECT_TIMEOUT_SECONDS?: *, NUM_FAILURE_DETECTION_SUBGROUPS?: * |}>
Expand Down
25 changes: 22 additions & 3 deletions webui/src/generated/graphql-typing-ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,10 @@ export type ServerInfoCartridge = {
state: Scalars['String'];
/** Cartridge version */
version: Scalars['String'];
/** VShard version */
vshard_version?: Maybe<Scalars['String']>;
/** DDL version */
ddl_version?: Maybe<Scalars['String']>;
};

export type ServerInfoGeneral = {
Expand Down Expand Up @@ -1168,7 +1172,12 @@ export type ServerDetailsFieldsFragment = {
labels?: Array<{ __typename?: 'Label'; name: string; value: string } | null> | null;
boxinfo?: {
__typename?: 'ServerInfo';
cartridge: { __typename?: 'ServerInfoCartridge'; version: string };
cartridge: {
__typename?: 'ServerInfoCartridge';
version: string;
vshard_version: string | null;
ddl_version: string | null;
};
membership: {
__typename?: 'ServerInfoMembership';
status?: string | null;
Expand Down Expand Up @@ -1296,7 +1305,12 @@ export type InstanceDataQuery = {
labels?: Array<{ __typename?: 'Label'; name: string; value: string } | null> | null;
boxinfo?: {
__typename?: 'ServerInfo';
cartridge: { __typename?: 'ServerInfoCartridge'; version: string };
cartridge: {
__typename?: 'ServerInfoCartridge';
version: string;
vshard_version: string | null;
ddl_version: string | null;
};
membership: {
__typename?: 'ServerInfoMembership';
status?: string | null;
Expand Down Expand Up @@ -1457,7 +1471,12 @@ export type BoxInfoQuery = {
labels?: Array<{ __typename?: 'Label'; name: string; value: string } | null> | null;
boxinfo?: {
__typename?: 'ServerInfo';
cartridge: { __typename?: 'ServerInfoCartridge'; version: string };
cartridge: {
__typename?: 'ServerInfoCartridge';
version: string;
vshard_version: string | null;
ddl_version: string | null;
};
membership: {
__typename?: 'ServerInfoMembership';
status?: string | null;
Expand Down
2 changes: 2 additions & 0 deletions webui/src/store/request/queries.graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ export const serverDetailsFields = gql`
boxinfo {
cartridge {
version
vshard_version
ddl_version
}
membership {
status
Expand Down

0 comments on commit 6981250

Please sign in to comment.