Skip to content

Commit

Permalink
Relax OpenSearch Node Compatibility check
Browse files Browse the repository at this point in the history
Signed-off-by: Bandini Bhopi <[email protected]>
  • Loading branch information
bandinib-amzn committed Aug 9, 2023
1 parent 04065fa commit ce08007
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
2 changes: 2 additions & 0 deletions config/opensearch_dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,5 @@
# Set the value of this setting to true to enable plugin augmentation on Dashboard
# vis_augmenter.pluginAugmentationEnabled: true

# Set the value of this setting to false when don't want to use OpenSearch to store OpenSearch-Dashboards metadata
#opensearch.asOpensearchDashboardsMetadataStorage: true
1 change: 1 addition & 0 deletions src/core/server/opensearch/client/client_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export type OpenSearchClientConfig = Pick<
| 'username'
| 'password'
| 'disablePrototypePoisoningProtection'
| 'asOpensearchDashboardsMetadataStorage'
> & {
memoryCircuitBreaker?:
| OpenSearchConfig['memoryCircuitBreaker']
Expand Down
7 changes: 7 additions & 0 deletions src/core/server/opensearch/opensearch_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export const configSchema = schema.object({
schema.boolean({ defaultValue: false })
),
disablePrototypePoisoningProtection: schema.maybe(schema.boolean({ defaultValue: false })),
asOpensearchDashboardsMetadataStorage: schema.boolean({ defaultValue: true }),
});

const deprecations: ConfigDeprecationProvider = ({ renameFromRoot, renameFromRootWithoutMap }) => [
Expand Down Expand Up @@ -325,6 +326,11 @@ export class OpenSearchConfig {
*/
public readonly disablePrototypePoisoningProtection?: boolean;

/**
* Specifies whether the OpenSearch is being used as OpenSearch Dashboards metadata storage.
*/
public readonly asOpensearchDashboardsMetadataStorage?: boolean;

constructor(rawConfig: OpenSearchConfigType) {
this.ignoreVersionMismatch = rawConfig.ignoreVersionMismatch;
this.apiVersion = rawConfig.apiVersion;
Expand All @@ -346,6 +352,7 @@ export class OpenSearchConfig {
this.password = rawConfig.password;
this.customHeaders = rawConfig.customHeaders;
this.disablePrototypePoisoningProtection = rawConfig.disablePrototypePoisoningProtection;
this.asOpensearchDashboardsMetadataStorage = rawConfig.asOpensearchDashboardsMetadataStorage;

const { alwaysPresentCertificate, verificationMode } = rawConfig.ssl;
const { key, keyPassphrase, certificate, certificateAuthorities } = readKeyAndCerts(rawConfig);
Expand Down
30 changes: 21 additions & 9 deletions src/core/server/opensearch/opensearch_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* under the License.
*/

import { Observable, Subject } from 'rxjs';
import { Observable, Subject, of } from 'rxjs';
import { first, map, shareReplay, takeUntil } from 'rxjs/operators';
import { merge } from '@osd/std';

Expand Down Expand Up @@ -91,14 +91,26 @@ export class OpenSearchService
this.legacyClient = this.createLegacyClusterClient('data', config);
this.client = this.createClusterClient('data', config);

const opensearchNodesCompatibility$ = pollOpenSearchNodesVersion({
internalClient: this.client.asInternalUser,
optimizedHealthcheck: config.optimizedHealthcheck,
log: this.log,
ignoreVersionMismatch: config.ignoreVersionMismatch,
opensearchVersionCheckInterval: config.healthCheckDelay.asMilliseconds(),
opensearchDashboardsVersion: this.opensearchDashboardsVersion,
}).pipe(takeUntil(this.stop$), shareReplay({ refCount: true, bufferSize: 1 }));
let opensearchNodesCompatibility$;
const isOpensearchMetadataStorage =
config.asOpensearchDashboardsMetadataStorage === undefined ?? true;
if (isOpensearchMetadataStorage) {
opensearchNodesCompatibility$ = pollOpenSearchNodesVersion({
internalClient: this.client.asInternalUser,
optimizedHealthcheck: config.optimizedHealthcheck,
log: this.log,
ignoreVersionMismatch: config.ignoreVersionMismatch,
opensearchVersionCheckInterval: config.healthCheckDelay.asMilliseconds(),
opensearchDashboardsVersion: this.opensearchDashboardsVersion,
}).pipe(takeUntil(this.stop$), shareReplay({ refCount: true, bufferSize: 1 }));
} else {
opensearchNodesCompatibility$ = of({
isCompatible: true,
incompatibleNodes: [],
warningNodes: [],
opensearchDashboardsVersion: this.opensearchDashboardsVersion,
});
}

this.createLegacyCustomClient = (type, clientConfig = {}) => {
const finalConfig = merge({}, config, clientConfig);
Expand Down
9 changes: 0 additions & 9 deletions src/core/server/saved_objects/saved_objects_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,15 +420,6 @@ export class SavedObjectsService
'Waiting until all OpenSearch nodes are compatible with OpenSearch Dashboards before starting saved objects migrations...'
);

// TODO: Move to Status Service https://github.com/elastic/kibana/issues/41983
this.setupDeps!.opensearch.opensearchNodesCompatibility$.subscribe(
({ isCompatible, message }) => {
if (!isCompatible && message) {
this.logger.error(message);
}
}
);

await this.setupDeps!.opensearch.opensearchNodesCompatibility$.pipe(
filter((nodes) => nodes.isCompatible),
take(1)
Expand Down

0 comments on commit ce08007

Please sign in to comment.