Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Non-Inclusive Language] Replace master in comments and variables #1692

Closed
tmarkley opened this issue Jun 7, 2022 · 0 comments · Fixed by #1778
Closed

[Non-Inclusive Language] Replace master in comments and variables #1692

tmarkley opened this issue Jun 7, 2022 · 0 comments · Fixed by #1778

Comments

@tmarkley
Copy link
Contributor

tmarkley commented Jun 7, 2022

Parent: #1318

Instances of master in comments and variables

async function getLicenseFromLocalOrMaster(opensearchClient: OpenSearchClient) {
// Fetching the local license is cheaper than getting it from the master node and good enough
const { license } = await fetchLicense(opensearchClient, true).catch(async (err) => {
if (cachedLicense) {
try {
// Fallback to the master node's license info
const response = await fetchLicense(opensearchClient, false);
return response;
} catch (masterError) {
if ([400, 404].includes(masterError.statusCode)) {
// If the master node does not have a license, we can assume there is no license
cachedLicense = undefined;
} else {
throw err;
}
}
}
return { license: void 0 };
});
if (license) {
cachedLicense = license;
}
return license;
}
export const getLocalLicense: LicenseGetter = async (clustersDetails, { opensearchClient }) => {
const license = await getLicenseFromLocalOrMaster(opensearchClient);

* Using _cluster/state/nodes to retrieve the cluster_id of each node from master node which is considered to be a lightweight operation
* else if the nodes have different cluster_ids then fan out the request to all nodes
* else there are no nodes in the cluster
*/
const sharedClusterId =
state.body.nodes.length > 0
? get(state.body.nodes[0], `attributes.${healthcheckAttributeName}`, null)
: null;
return sharedClusterId === null ||
state.body.nodes.find(
(node: any) => sharedClusterId !== get(node, `attributes.${healthcheckAttributeName}`, null)
)
? null
: '_local';
} catch (e) {
return null;
}
};
export interface PollOpenSearchNodesVersionOptions {
internalClient: OpenSearchClient;
optimizedHealthcheckId?: string;
log: Logger;
opensearchDashboardsVersion: string;
ignoreVersionMismatch: boolean;
opensearchVersionCheckInterval: number;
}
interface NodeInfo {
version: string;
ip: string;
http?: {
publish_address: string;
};
name: string;
}
export interface NodesInfo {
nodes: {
[key: string]: NodeInfo;
};
}
export interface NodesVersionCompatibility {
isCompatible: boolean;
message?: string;
incompatibleNodes: NodeInfo[];
warningNodes: NodeInfo[];
opensearchDashboardsVersion: string;
nodesInfoRequestError?: Error;
}
function getHumanizedNodeName(node: NodeInfo) {
const publishAddress = node?.http?.publish_address + ' ' || '';
return 'v' + node.version + ' @ ' + publishAddress + '(' + node.ip + ')';
}
export function mapNodesVersionCompatibility(
nodesInfo: NodesInfo,
opensearchDashboardsVersion: string,
ignoreVersionMismatch: boolean
): NodesVersionCompatibility {
if (Object.keys(nodesInfo.nodes ?? {}).length === 0) {
return {
isCompatible: false,
message: 'Unable to retrieve version information from OpenSearch nodes.',
incompatibleNodes: [],
warningNodes: [],
opensearchDashboardsVersion,
};
}
const nodes = Object.keys(nodesInfo.nodes)
.sort() // Sorting ensures a stable node ordering for comparison
.map((key) => nodesInfo.nodes[key])
.map((node) => Object.assign({}, node, { name: getHumanizedNodeName(node) }));
// Aggregate incompatible OpenSearch nodes.
const incompatibleNodes = nodes.filter(
(node) =>
!opensearchVersionCompatibleWithOpenSearchDashboards(
node.version,
opensearchDashboardsVersion
)
);
// Aggregate OpenSearch nodes which should prompt a OpenSearch Dashboards upgrade. It's acceptable
// if OpenSearch and OpenSearch Dashboards versions are not the same as long as they are not
// incompatible, but we should warn about it.
// Ignore version qualifiers https://github.com/elastic/elasticsearch/issues/36859
const warningNodes = nodes.filter(
(node) =>
!opensearchVersionEqualsOpenSearchDashboards(node.version, opensearchDashboardsVersion)
);
// Note: If incompatible and warning nodes are present `message` only contains
// an incompatibility notice.
let message;
if (incompatibleNodes.length > 0) {
const incompatibleNodeNames = incompatibleNodes.map((node) => node.name).join(', ');
if (ignoreVersionMismatch) {
message = `Ignoring version incompatibility between OpenSearch Dashboards v${opensearchDashboardsVersion} and the following OpenSearch nodes: ${incompatibleNodeNames}`;
} else {
message = `This version of OpenSearch Dashboards (v${opensearchDashboardsVersion}) is incompatible with the following OpenSearch nodes in your cluster: ${incompatibleNodeNames}`;
}
} else if (warningNodes.length > 0) {
const warningNodeNames = warningNodes.map((node) => node.name).join(', ');
message =
`You're running OpenSearch Dashboards ${opensearchDashboardsVersion} with some different versions of ` +
'OpenSearch. Update OpenSearch Dashboards or OpenSearch to the same ' +
`version to prevent compatibility issues: ${warningNodeNames}`;
}
return {
isCompatible: ignoreVersionMismatch || incompatibleNodes.length === 0,
message,
incompatibleNodes,
warningNodes,
opensearchDashboardsVersion,
};
}
// Returns true if two NodesVersionCompatibility entries match
function compareNodes(prev: NodesVersionCompatibility, curr: NodesVersionCompatibility) {
const nodesEqual = (n: NodeInfo, m: NodeInfo) => n.ip === m.ip && n.version === m.version;
return (
curr.isCompatible === prev.isCompatible &&
curr.incompatibleNodes.length === prev.incompatibleNodes.length &&
curr.warningNodes.length === prev.warningNodes.length &&
curr.incompatibleNodes.every((node, i) => nodesEqual(node, prev.incompatibleNodes[i])) &&
curr.warningNodes.every((node, i) => nodesEqual(node, prev.warningNodes[i]))
);
}
export const pollOpenSearchNodesVersion = ({
internalClient,
optimizedHealthcheckId,
log,
opensearchDashboardsVersion,
ignoreVersionMismatch,
opensearchVersionCheckInterval: healthCheckInterval,
}: PollOpenSearchNodesVersionOptions): Observable<NodesVersionCompatibility> => {
log.debug('Checking OpenSearch version');
return timer(0, healthCheckInterval).pipe(
exhaustMap(() => {
/*
* Originally, Dashboards queries OpenSearch cluster to get the version info of each node and check the version compatibility with each node.
* The /nodes request could fail even one node in cluster fail to response
* For better dashboards resilience, the behaviour is changed to only query the local node when all the nodes have the same cluster_id
* Using _cluster/state/nodes to retrieve the cluster_id of each node from the master node

manasvinibs added a commit to manasvinibs/OpenSearch-Dashboards that referenced this issue Jun 22, 2022
As part of the meta issue opensearch-project/OpenSearch#2589 to track the plan and progress of applying inclusive naming across OpenSearch Repositories.

Issue - opensearch-project#1692
Signed-off-by: manasvinibs <[email protected]>
manasvinibs added a commit to manasvinibs/OpenSearch-Dashboards that referenced this issue Jun 22, 2022
As part of the meta issue opensearch-project/OpenSearch#2589 to track the plan and progress of applying inclusive naming across OpenSearch Repositories.

Issue - opensearch-project#1692
Signed-off-by: manasvinibs <[email protected]>
manasvinibs added a commit to manasvinibs/OpenSearch-Dashboards that referenced this issue Jun 23, 2022
As part of the meta issue opensearch-project/OpenSearch#2589 to track the plan and progress of applying inclusive naming across OpenSearch Repositories.

Issue - opensearch-project#1692
Signed-off-by: manasvinibs <[email protected]>
manasvinibs added a commit to manasvinibs/OpenSearch-Dashboards that referenced this issue Jun 23, 2022
As part of the meta issue opensearch-project/OpenSearch#2589 to track the plan and progress of applying inclusive naming across OpenSearch Repositories.

Issue - opensearch-project#1692
Signed-off-by: manasvinibs <[email protected]>
manasvinibs added a commit to manasvinibs/OpenSearch-Dashboards that referenced this issue Jun 23, 2022
…nction names

As part of the meta issue opensearch-project/OpenSearch#2589 to track the plan and progress of applying inclusive naming across OpenSearch Repositories.

Issue - opensearch-project#1692
Signed-off-by: manasvinibs <[email protected]>
manasvinibs added a commit to manasvinibs/OpenSearch-Dashboards that referenced this issue Jun 23, 2022
…nction names

As part of the meta issue opensearch-project/OpenSearch#2589 to track the plan and progress of applying inclusive naming across OpenSearch Repositories.

Issue - opensearch-project#1692
Signed-off-by: manasvinibs <[email protected]>
@kavilla kavilla linked a pull request Jun 23, 2022 that will close this issue
7 tasks
manasvinibs added a commit to manasvinibs/OpenSearch-Dashboards that referenced this issue Jun 23, 2022
…nction names

As part of the meta issue opensearch-project/OpenSearch#2589 to track the plan and progress of applying inclusive naming across OpenSearch Repositories.

Issue - opensearch-project#1692
Signed-off-by: Manasvini B Suryanarayana <[email protected]>
manasvinibs added a commit to manasvinibs/OpenSearch-Dashboards that referenced this issue Jun 23, 2022
…nction names

As part of the meta issue opensearch-project/OpenSearch#2589 to track the plan and progress of applying inclusive naming across OpenSearch Repositories.

Issue - opensearch-project#1692
Signed-off-by: Manasvini B Suryanarayana <[email protected]>
joshuarrrr pushed a commit that referenced this issue Jun 24, 2022
…nction names (#1778)

As part of the meta issue opensearch-project/OpenSearch#2589 to track the plan and progress of applying inclusive naming across OpenSearch Repositories.

Issue - #1692
Signed-off-by: Manasvini B Suryanarayana <[email protected]>
opensearch-trigger-bot bot pushed a commit that referenced this issue Jun 24, 2022
…nction names (#1778)

As part of the meta issue opensearch-project/OpenSearch#2589 to track the plan and progress of applying inclusive naming across OpenSearch Repositories.

Issue - #1692
Signed-off-by: Manasvini B Suryanarayana <[email protected]>
(cherry picked from commit e32a259)
joshuarrrr pushed a commit that referenced this issue Jun 24, 2022
…nction names (#1778) (#1793)

As part of the meta issue opensearch-project/OpenSearch#2589 to track the plan and progress of applying inclusive naming across OpenSearch Repositories.

Issue - #1692
Signed-off-by: Manasvini B Suryanarayana <[email protected]>
(cherry picked from commit e32a259)

Co-authored-by: Manasvini B Suryanarayana <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants