Skip to content

Commit

Permalink
Add ddl-ee
Browse files Browse the repository at this point in the history
  • Loading branch information
yngvar-antonsson committed May 15, 2024
1 parent 645e281 commit e507e90
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
8 changes: 7 additions & 1 deletion cartridge/lua-api/boxinfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 = {}
Expand Down Expand Up @@ -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,
},
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
4 changes: 4 additions & 0 deletions cartridge/webui/gql-boxinfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
8 changes: 5 additions & 3 deletions webui/src/generated/graphql-typing-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ export type ServerInfoCartridge = {|
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 @@ -1063,7 +1065,7 @@ export type ServerDetailsFieldsFragment = ({
...{ __typename?: 'ServerInfo' },
...{| cartridge: ({
...{ __typename?: 'ServerInfoCartridge' },
...$Pick<ServerInfoCartridge, {| version: *, vshard_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 @@ -1120,7 +1122,7 @@ export type InstanceDataQuery = ({
...{ __typename?: 'ServerInfo' },
...{| cartridge: ({
...{ __typename?: 'ServerInfoCartridge' },
...$Pick<ServerInfoCartridge, {| version: *, vshard_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 @@ -1226,7 +1228,7 @@ export type BoxInfoQuery = ({
...{ __typename?: 'ServerInfo' },
...{| cartridge: ({
...{ __typename?: 'ServerInfoCartridge' },
...$Pick<ServerInfoCartridge, {| version: *, vshard_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
23 changes: 20 additions & 3 deletions webui/src/generated/graphql-typing-ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ export type ServerInfoCartridge = {
version: Scalars['String'];
/** VShard version */
vshard_version?: Maybe<Scalars['String']>;
/** DDL version */
ddl_version?: Maybe<Scalars['String']>;
};

export type ServerInfoGeneral = {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions webui/src/store/request/queries.graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export const serverDetailsFields = gql`
cartridge {
version
vshard_version
ddl_version
}
membership {
status
Expand Down

0 comments on commit e507e90

Please sign in to comment.