From f27f3034f7348e2c8f5665fb2ef933cb9ccf45f6 Mon Sep 17 00:00:00 2001 From: Igor Zolotarev Date: Wed, 15 May 2024 13:24:36 +0300 Subject: [PATCH] Use vshard-ee if available --- CHANGELOG.rst | 4 ++++ cartridge/lua-api/boxinfo.lua | 10 +++++++++- cartridge/roles/vshard-router.lua | 7 ++++++- cartridge/roles/vshard-storage.lua | 7 ++++++- cartridge/webui/gql-boxinfo.lua | 6 +++++- doc/schema.graphql | 5 ++++- webui/src/generated/graphql-typing-flow.js | 8 +++++--- webui/src/generated/graphql-typing-ts.ts | 8 +++++--- webui/src/store/request/queries.graphql.js | 1 + 9 files changed, 45 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 813711dc6..5d07ec9e0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -23,6 +23,8 @@ Added - GraphQL API to enable previously disabled instances: ``mutation { cluster { enable_servers(uuids: [...]) { } } }``. +- VShard version is displayed in the WebUI. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Changed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -34,6 +36,8 @@ Changed - Update ``vshard`` dependency to `0.1.27 `_. +- Cartridge now uses ``vshard-ee`` instead of ``vshard`` if available. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/cartridge/lua-api/boxinfo.lua b/cartridge/lua-api/boxinfo.lua index e08a2ec8b..cbfd02b96 100644 --- a/cartridge/lua-api/boxinfo.lua +++ b/cartridge/lua-api/boxinfo.lua @@ -51,8 +51,15 @@ local function get_info(uri) local membership_myself = require('membership').myself() local membership_options = require('membership.options') + local vshard, vshard_version + if package.loaded['vshard-ee'] ~= nil then + vshard = package.loaded['vshard-ee'] + vshard_version = vshard._VERSION .. ' EE' + else + vshard = package.loaded.vshard + vshard_version = vshard._VERSION + end - local vshard = package.loaded.vshard local routers = vshard and vshard.router.internal.routers or {} local router_info = {} @@ -193,6 +200,7 @@ local function get_info(uri) }, cartridge = { version = require('cartridge').VERSION, + vshard_version = vshard_version, state = server_state, error = server_error, }, diff --git a/cartridge/roles/vshard-router.lua b/cartridge/roles/vshard-router.lua index 6496149fb..1741f3231 100644 --- a/cartridge/roles/vshard-router.lua +++ b/cartridge/roles/vshard-router.lua @@ -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') diff --git a/cartridge/roles/vshard-storage.lua b/cartridge/roles/vshard-storage.lua index 432a98feb..e1b943b08 100644 --- a/cartridge/roles/vshard-storage.lua +++ b/cartridge/roles/vshard-storage.lua @@ -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') diff --git a/cartridge/webui/gql-boxinfo.lua b/cartridge/webui/gql-boxinfo.lua index 5b2ca3907..6b988eb3c 100644 --- a/cartridge/webui/gql-boxinfo.lua +++ b/cartridge/webui/gql-boxinfo.lua @@ -356,7 +356,11 @@ local boxinfo_schema = { description = 'Error details if instance is in' .. ' failure state', - } + }, + vshard_version = { + kind = gql_types.string, + description = 'VShard version', + }, } }).nonNull, membership = gql_types.object({ diff --git a/doc/schema.graphql b/doc/schema.graphql index 71dee73f8..6af3e1e6b 100644 --- a/doc/schema.graphql +++ b/doc/schema.graphql @@ -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: Tue May 14 2024 20:35:31 GMT+0300 (Moscow Standard Time) """Custom scalar specification.""" directive @specifiedBy( @@ -728,6 +728,9 @@ type ServerInfoCartridge { """Current instance state""" state: String! + """VShard version""" + vshard_version: String + """Cartridge version""" version: String! diff --git a/webui/src/generated/graphql-typing-flow.js b/webui/src/generated/graphql-typing-flow.js index ce1f8a3f2..89b91f4c8 100644 --- a/webui/src/generated/graphql-typing-flow.js +++ b/webui/src/generated/graphql-typing-flow.js @@ -613,6 +613,8 @@ export type ServerInfoCartridge = {| state: $ElementType, /** Cartridge version */ version: $ElementType, + /** VShard version */ + vshard_version?: $ElementType, |}; export type ServerInfoGeneral = {| @@ -1061,7 +1063,7 @@ export type ServerDetailsFieldsFragment = ({ ...{ __typename?: 'ServerInfo' }, ...{| cartridge: ({ ...{ __typename?: 'ServerInfoCartridge' }, - ...$Pick + ...$Pick }), membership: ({ ...{ __typename?: 'ServerInfoMembership' }, ...$Pick @@ -1118,7 +1120,7 @@ export type InstanceDataQuery = ({ ...{ __typename?: 'ServerInfo' }, ...{| cartridge: ({ ...{ __typename?: 'ServerInfoCartridge' }, - ...$Pick + ...$Pick }), membership: ({ ...{ __typename?: 'ServerInfoMembership' }, ...$Pick @@ -1224,7 +1226,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 ad7e708a6..8d03d9e2d 100644 --- a/webui/src/generated/graphql-typing-ts.ts +++ b/webui/src/generated/graphql-typing-ts.ts @@ -590,6 +590,8 @@ export type ServerInfoCartridge = { state: Scalars['String']; /** Cartridge version */ version: Scalars['String']; + /** VShard version */ + vshard_version?: Maybe; }; export type ServerInfoGeneral = { @@ -1168,7 +1170,7 @@ 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 }; membership: { __typename?: 'ServerInfoMembership'; status?: string | null; @@ -1296,7 +1298,7 @@ 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 }; membership: { __typename?: 'ServerInfoMembership'; status?: string | null; @@ -1457,7 +1459,7 @@ 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 }; 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 2c9b32b06..f83b17793 100644 --- a/webui/src/store/request/queries.graphql.js +++ b/webui/src/store/request/queries.graphql.js @@ -142,6 +142,7 @@ export const serverDetailsFields = gql` boxinfo { cartridge { version + vshard_version } membership { status