Skip to content

Commit 1daf9ad

Browse files
committed
Clean up permissions, security, and stats logic.
- Remove security dependency. - Render timestamp for autofollow errors. - Fix license check so that CCR won't render if the license is invalid. - Fix server security check to be more precise by checking if ES has security disabled.
1 parent 8076605 commit 1daf9ad

File tree

15 files changed

+40
-19
lines changed

15 files changed

+40
-19
lines changed

x-pack/plugins/cross_cluster_replication/common/constants/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { LicenseType } from '../../../licensing/common/types';
1111
const platinumLicense: LicenseType = 'platinum';
1212

1313
export const PLUGIN = {
14-
ID: 'cross_cluster_replication',
14+
ID: 'crossClusterReplication',
1515
TITLE: i18n.translate('xpack.crossClusterReplication.appTitle', {
1616
defaultMessage: 'Cross-Cluster Replication',
1717
}),
@@ -23,7 +23,8 @@ export const APPS = {
2323
REMOTE_CLUSTER_APP: 'remote_cluster',
2424
};
2525

26-
export const BASE_PATH = '/management/elasticsearch/cross_cluster_replication';
26+
export const MANAGEMENT_ID = 'cross_cluster_replication';
27+
export const BASE_PATH = `/management/elasticsearch/${MANAGEMENT_ID}`;
2728
export const BASE_PATH_REMOTE_CLUSTERS = '/management/elasticsearch/remote_clusters';
2829
export const API_BASE_PATH = '/api/cross_cluster_replication';
2930
export const API_REMOTE_CLUSTERS_BASE_PATH = '/api/remote_clusters';

x-pack/plugins/cross_cluster_replication/common/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export interface FollowerIndexAdvancedSettingsToEs {
140140
}
141141

142142
export interface RecentAutoFollowError {
143+
timestamp: number;
143144
leaderIndex: string;
144145
autoFollowException: {
145146
type: string;
@@ -148,6 +149,7 @@ export interface RecentAutoFollowError {
148149
}
149150

150151
export interface RecentAutoFollowErrorFromEs {
152+
timestamp: number;
151153
leader_index: string;
152154
auto_follow_exception: {
153155
type: string;

x-pack/plugins/cross_cluster_replication/kibana.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
"indexManagement"
1212
],
1313
"optionalPlugins": [
14-
"usageCollection",
15-
"security"
14+
"usageCollection"
1615
],
1716
"configPath": ["xpack", "ccr"]
1817
}

x-pack/plugins/cross_cluster_replication/public/__jest__/client_integration/auto_follow_pattern_list.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,12 @@ describe('<AutoFollowPatternList />', () => {
302302
const message = 'bar';
303303
const recentAutoFollowErrors = [
304304
{
305+
timestamp: 1587081600021,
305306
leaderIndex: `${autoFollowPattern1.name}:my-leader-test`,
306307
autoFollowException: { type: 'exception', reason: message },
307308
},
308309
{
310+
timestamp: 1587081600021,
309311
leaderIndex: `${autoFollowPattern2.name}:my-leader-test`,
310312
autoFollowException: { type: 'exception', reason: message },
311313
},
@@ -324,7 +326,7 @@ describe('<AutoFollowPatternList />', () => {
324326
expect(exists('autoFollowPatternDetail.errors')).toBe(true);
325327
expect(exists('autoFollowPatternDetail.titleErrors')).toBe(true);
326328
expect(find('autoFollowPatternDetail.recentError').map(error => error.text())).toEqual([
327-
message,
329+
'April 16th, 2020 8:00:00 PM: bar',
328330
]);
329331
});
330332
});

x-pack/plugins/cross_cluster_replication/public/app/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export async function mountApp({
4242
I18nContext: I18nStart['Context'];
4343
ELASTIC_WEBSITE_URL: string;
4444
DOC_LINK_VERSION: string;
45-
}): UnmountCallback {
45+
}): Promise<UnmountCallback> {
4646
// Initialize additional services.
4747
initBreadcrumbs(setBreadcrumbs);
4848
initDocumentation(`${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/`);

x-pack/plugins/cross_cluster_replication/public/app/sections/home/auto_follow_pattern_list/components/detail_panel/detail_panel.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import React, { Component } from 'react';
88
import PropTypes from 'prop-types';
99
import { FormattedMessage } from '@kbn/i18n/react';
10+
import moment from 'moment';
11+
1012
import { getIndexListUri } from '../../../../../../../../../plugins/index_management/public';
1113

1214
import {
@@ -247,6 +249,7 @@ export class DetailPanel extends Component {
247249
<ul>
248250
{autoFollowPattern.errors.map((error, i) => (
249251
<li key={i} data-test-subj="recentError">
252+
<strong>{moment(error.timestamp).format('MMMM Do, YYYY h:mm:ss A')}</strong>:{' '}
250253
{error.autoFollowException.reason}
251254
</li>
252255
))}

x-pack/plugins/cross_cluster_replication/public/app/services/auto_follow_errors.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ export const parseAutoFollowError = error => {
99
return null;
1010
}
1111

12-
const { leaderIndex, autoFollowException } = error;
12+
const { leaderIndex, autoFollowException, timestamp } = error;
1313
const id = leaderIndex.substring(0, leaderIndex.lastIndexOf(':'));
1414

1515
return {
1616
id,
17+
timestamp,
1718
leaderIndex,
1819
autoFollowException,
1920
};

x-pack/plugins/cross_cluster_replication/public/plugin.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { get } from 'lodash';
99
import { first } from 'rxjs/operators';
1010
import { CoreSetup, Plugin, PluginInitializerContext } from 'src/core/public';
1111

12-
import { PLUGIN } from '../common/constants';
12+
import { PLUGIN, MANAGEMENT_ID } from '../common/constants';
1313
import { init as initUiMetric } from './app/services/track_ui_metric';
1414
import { init as initNotification } from './app/services/notifications';
1515
import { PluginDependencies, ClientConfigType } from './types';
@@ -27,8 +27,8 @@ export class CrossClusterReplicationPlugin implements Plugin {
2727
.pipe(first())
2828
.toPromise()
2929
.then(license => {
30-
const isLicenseOk = license.isAvailable && license.isActive;
31-
30+
const licenseStatus = license.check(PLUGIN.ID, PLUGIN.minimumLicenseType);
31+
const isLicenseOk = licenseStatus.state === 'valid';
3232
const config = this.initializerContext.config.get<ClientConfigType>();
3333

3434
// The UI is also dependent upon the Remote Clusters UI.
@@ -48,7 +48,7 @@ export class CrossClusterReplicationPlugin implements Plugin {
4848
initNotification(toasts, fatalErrors);
4949

5050
management.sections.getSection('elasticsearch')!.registerApp({
51-
id: PLUGIN.ID,
51+
id: MANAGEMENT_ID,
5252
title: PLUGIN.TITLE,
5353
order: 4,
5454
mount: async ({ element, setBreadcrumbs }) => {

x-pack/plugins/cross_cluster_replication/server/lib/__snapshots__/ccr_stats_serialization.test.ts.snap

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugins/cross_cluster_replication/server/lib/ccr_stats_serialization.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe('[CCR] auto-follow stats serialization', () => {
1515
recent_auto_follow_errors: [
1616
{
1717
leader_index: 'pattern-1:kibana_sample_1',
18+
timestamp: 1587081600021,
1819
auto_follow_exception: {
1920
type: 'exception',
2021
reason:
@@ -23,6 +24,7 @@ describe('[CCR] auto-follow stats serialization', () => {
2324
},
2425
{
2526
leader_index: 'pattern-2:kibana_sample_1',
27+
timestamp: 1587081600021,
2628
auto_follow_exception: {
2729
type: 'exception',
2830
reason:

0 commit comments

Comments
 (0)