From fa90a2f08025ed1f50bed10170bd3c8295f8633c Mon Sep 17 00:00:00 2001 From: Elena Stoeva <59341489+ElenaStoeva@users.noreply.github.com> Date: Thu, 27 Jul 2023 09:42:15 +0100 Subject: [PATCH] [Snapshot Restore] Fix broken Snapshot restore form (#161113) Fix https://github.com/elastic/kibana/issues/160974 Fix https://github.com/elastic/kibana/issues/160929 ## Summary From Es 8.10, the `version` field from the Get Snapshot response has a different format - it will no longer be a string representing the release version, but rather it will be a string representing the version id (see https://github.com/elastic/kibana/issues/160974#issuecomment-1618087194 for more details). This PR replaces the use of the `version` field with the `versionId` field when checking in the Snapshot Restore form if the current version is greater than 7.12 (which corresponds to `versionID` 7120099). The PR also unskips the functional test that failed with the promotion of Es to 8.10. **How to test:** 1. Start Es with `yarn es snapshot -E path.repo=./tmp/snap` and Kibana with `yarn start` 2. Go to Stack Management -> Snapshot and Restore 3. Create a Shared File System repository with location `./tmp/snap` 4. Create a policy that uses the repository created in the previous step. 5. Run the policy to create a snapshot. 6. Go to the Snapshots tab and click the Restore button for the created snapshot. 7. Verify that the Snapshot restore form works as expected. --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../steps/step_logistics/step_logistics.tsx | 9 +++++---- .../functional/apps/snapshot_restore/snapshot_restore.ts | 3 +-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/snapshot_restore/public/application/components/restore_snapshot_form/steps/step_logistics/step_logistics.tsx b/x-pack/plugins/snapshot_restore/public/application/components/restore_snapshot_form/steps/step_logistics/step_logistics.tsx index e9fd9559deecf..70f3255bb4d0c 100644 --- a/x-pack/plugins/snapshot_restore/public/application/components/restore_snapshot_form/steps/step_logistics/step_logistics.tsx +++ b/x-pack/plugins/snapshot_restore/public/application/components/restore_snapshot_form/steps/step_logistics/step_logistics.tsx @@ -7,7 +7,6 @@ import React, { Fragment, useState, useMemo } from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; -import semverGt from 'semver/functions/gt'; import { EuiButtonEmpty, EuiDescribedFormGroup, @@ -61,7 +60,7 @@ export const RestoreSnapshotStepLogistics: React.FunctionComponent = indices: unfilteredSnapshotIndices, dataStreams: snapshotDataStreams = [], includeGlobalState: snapshotIncludeGlobalState, - version, + versionId, featureStates: snapshotIncludeFeatureStates, } = snapshotDetails; @@ -647,8 +646,10 @@ export const RestoreSnapshotStepLogistics: React.FunctionComponent = defaultMessage="Restores the configuration, history, and other data stored in Elasticsearch by a feature such as Elasticsearch security." /> - {/* Only display callout if includeFeatureState is enabled and the snapshot was created by ES 7.12+ */} - {semverGt(version, '7.12.0') && isFeatureStatesToggleEnabled && ( + {/* Only display callout if includeFeatureState is enabled and the snapshot was created by ES 7.12+ + The versionId field represents the build id of the ES version. We check if the current ES version is >7.12 + by comparing its build id with the build id of ES 7.12, which is 7120099. */} + {versionId > 7120099 && isFeatureStatesToggleEnabled && ( <> diff --git a/x-pack/test/functional/apps/snapshot_restore/snapshot_restore.ts b/x-pack/test/functional/apps/snapshot_restore/snapshot_restore.ts index 3b8ea30f5e98d..a1a6bfe6276f5 100644 --- a/x-pack/test/functional/apps/snapshot_restore/snapshot_restore.ts +++ b/x-pack/test/functional/apps/snapshot_restore/snapshot_restore.ts @@ -15,8 +15,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const es = getService('es'); const security = getService('security'); - // FAILING ES PROMOTION: https://github.com/elastic/kibana/issues/160929 - describe.skip('Snapshot restore', function () { + describe('Snapshot restore', function () { before(async () => { await security.testUser.setRoles(['snapshot_restore_user'], { skipBrowserRefresh: true }); await pageObjects.common.navigateToApp('snapshotRestore');