Skip to content

Commit

Permalink
[Non-Inclusive Language] Replace isDevClusterMaster with isDevCluster…
Browse files Browse the repository at this point in the history
…Manager

As part of the meta issue opensearch-project/OpenSearch#2589 to track the plan and progress of applying inclusive naming across OpenSearch Repositories
Every repository that uses non-inclusive words should replace all the non-inclusive usages in the code base.

In this change we are replacing the instances of the terminology "isDevClusterMaster" with "isDevClusterManager".

Signed-off-by: manasvis <[email protected]>
  • Loading branch information
manasvinibs committed Jun 14, 2022
1 parent 3ff99cf commit a5a9248
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 11 deletions.
2 changes: 2 additions & 0 deletions packages/osd-config/src/__mocks__/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@ export function getEnvOptions(options: DeepPartial<EnvOptions> = {}): EnvOptions
},
isDevClusterMaster:
options.isDevClusterMaster !== undefined ? options.isDevClusterMaster : false,
isDevClusterManager:
options.isDevClusterManager !== undefined ? options.isDevClusterManager : false,
};
}
6 changes: 6 additions & 0 deletions packages/osd-config/src/__snapshots__/env.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/osd-config/src/env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ test('correctly creates default environment in dev mode.', () => {
getEnvOptions({
configs: ['/test/cwd/config/opensearch_dashboards.yml'],
isDevClusterMaster: true,
isDevClusterManager: true,
})
);

Expand Down
12 changes: 11 additions & 1 deletion packages/osd-config/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ import { PackageInfo, EnvironmentMode } from './types';
export interface EnvOptions {
configs: string[];
cliArgs: CliArgs;
/** @deprecated use isDevClusterManager */
isDevClusterMaster: boolean;
isDevClusterManager: boolean;
}

/** @internal */
Expand Down Expand Up @@ -110,11 +112,18 @@ export class Env {
public readonly configs: readonly string[];

/**
* Indicates that this OpenSearch Dashboards instance is run as development Node Cluster master.
* Indicates that this OpenSearch Dashboards instance is run as development Node master.
* @internal
* @deprecated use isDevClusterManager
*/
public readonly isDevClusterMaster: boolean;

/**
* Indicates that this OpenSearch Dashboards instance is run as development Node Cluster manager.
* @internal
*/
public readonly isDevClusterManager: boolean;

/**
* @internal
*/
Expand All @@ -138,6 +147,7 @@ export class Env {
this.cliArgs = Object.freeze(options.cliArgs);
this.configs = Object.freeze(options.configs);
this.isDevClusterMaster = options.isDevClusterMaster;
this.isDevClusterManager = options.isDevClusterManager;

const isDevMode = this.cliArgs.dev || this.cliArgs.envName === 'development';
this.mode = Object.freeze<EnvironmentMode>({
Expand Down
5 changes: 3 additions & 2 deletions src/core/server/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/

import chalk from 'chalk';
import { isMaster } from 'cluster';
import { isMaster as isClusterManager } from 'cluster';
import { CliArgs, Env, RawConfigService } from './config';
import { Root } from './root';
import { CriticalError } from './errors';
Expand Down Expand Up @@ -82,7 +82,8 @@ export async function bootstrap({
const env = Env.createDefault(REPO_ROOT, {
configs,
cliArgs,
isDevClusterMaster: isMaster && cliArgs.dev && features.isClusterModeSupported,
isDevClusterMaster: isClusterManager && cliArgs.dev && features.isClusterModeSupported,
isDevClusterManager: isClusterManager && cliArgs.dev && features.isClusterModeSupported,
});

const rawConfigService = new RawConfigService(env.configs, applyConfigOverrides);
Expand Down
8 changes: 7 additions & 1 deletion src/core/server/http/http_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,13 @@ test('does not start http server if process is dev cluster master', async () =>
const service = new HttpService({
coreId,
configService,
env: Env.createDefault(REPO_ROOT, getEnvOptions({ isDevClusterMaster: true })),
env: Env.createDefault(
REPO_ROOT,
getEnvOptions({
isDevClusterManager: true,
isDevClusterMaster: true,
})
),
logger,
});

Expand Down
5 changes: 4 additions & 1 deletion src/core/server/http/http_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ export class HttpService
* @internal
* */
private shouldListen(config: HttpConfig) {
return !this.coreContext.env.isDevClusterMaster && config.autoListen;
return (
!(this.coreContext.env.isDevClusterMaster || this.coreContext.env.isDevClusterManager) &&
config.autoListen
);
}

public async stop() {
Expand Down
2 changes: 2 additions & 0 deletions src/core/server/legacy/legacy_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ describe('once LegacyService is set up in `devClusterMaster` mode', () => {
getEnvOptions({
cliArgs: { silent: true, basePath: false },
isDevClusterMaster: true,
isDevClusterManager: true,
})
),
logger,
Expand Down Expand Up @@ -403,6 +404,7 @@ describe('once LegacyService is set up in `devClusterMaster` mode', () => {
getEnvOptions({
cliArgs: { quiet: true, basePath: true },
isDevClusterMaster: true,
isDevClusterManager: true,
})
),
logger,
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/legacy/legacy_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class LegacyService implements CoreService {
this.log.debug('starting legacy service');

// Receive initial config and create osdServer/ClusterManager.
if (this.coreContext.env.isDevClusterMaster) {
if (this.coreContext.env.isDevClusterMaster || this.coreContext.env.isDevClusterManager) {
await this.createClusterManager(this.legacyRawConfig!);
} else {
this.osdServer = await this.createOsdServer(
Expand Down
4 changes: 3 additions & 1 deletion src/core/server/plugins/plugins_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ export class PluginsService implements CoreService<PluginsServiceSetup, PluginsS
const config = await this.config$.pipe(first()).toPromise();

let contracts = new Map<PluginName, unknown>();
const initialize = config.initialize && !this.coreContext.env.isDevClusterMaster;
const initialize =
config.initialize &&
!(this.coreContext.env.isDevClusterMaster || this.coreContext.env.isDevClusterManager);
if (initialize) {
contracts = await this.pluginsSystem.setupPlugins(deps);
this.registerPluginStaticDirs(deps);
Expand Down
1 change: 1 addition & 0 deletions src/core/test_helpers/osd_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export function createRootWithSettings(
...cliArgs,
},
isDevClusterMaster: false,
isDevClusterManager: false,
});

return new Root(
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/server/logging/rotate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* under the License.
*/

import { isMaster, isWorker } from 'cluster';
import { isMaster as isClusterManager, isWorker } from 'cluster';
import { Server } from '@hapi/hapi';
import { LogRotator } from './log_rotator';
import { OpenSearchDashboardsConfig } from '../../osd_server';
Expand All @@ -43,7 +43,7 @@ export async function setupLoggingRotate(server: Server, config: OpenSearchDashb

// We just want to start the logging rotate service once
// and we choose to use the master (prod) or the worker server (dev)
if (!isMaster && isWorker && process.env.osdWorkerType !== 'server') {
if (!isClusterManager && isWorker && process.env.osdWorkerType !== 'server') {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/legacy/server/logging/rotate/log_rotator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/

import * as chokidar from 'chokidar';
import { isMaster } from 'cluster';
import { isMaster as isClusterManager } from 'cluster';
import fs from 'fs';
import { Server } from '@hapi/hapi';
import { throttle } from 'lodash';
Expand Down Expand Up @@ -359,7 +359,7 @@ export class LogRotator {
}

_sendReloadLogConfigSignal() {
if (isMaster) {
if (isClusterManager) {
(process as NodeJS.EventEmitter).emit('SIGHUP');
return;
}
Expand Down

0 comments on commit a5a9248

Please sign in to comment.