Skip to content

Commit

Permalink
[job-components, terafoundation, teraslice] Remove prom metrics assig…
Browse files Browse the repository at this point in the history
…nment default label, exclude master pod from active execution list (#3799)

This PR makes the following changes:

- Remove prom metrics `assignment` default label. This should never have
been included.
- Exclude master pod from active execution list. We didn't realize this
was included in the `cluster/state` endpoint `active` array for the node
that had the master.
- bump teraslice from 2.6.0 to 2.6.1
- bump terafoundation from 1.5.1 to 1.5.2
- bump job-components from 1.5.1 to 1.5.2

Ref: #3743
  • Loading branch information
busma13 authored Oct 21, 2024
1 parent a0135ca commit b9590ca
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 23 deletions.
1 change: 1 addition & 0 deletions docs/development/k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ await config.context.apis.foundation.promMetrics.init({
ex_id: this.exId,
job_id: this.jobId,
job_name: this.config.name,
assignment: 'execution_controller',
}
});
```
Expand Down
4 changes: 4 additions & 0 deletions e2e/k8s/masterConfig/teraslice.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
terafoundation:
environment: "development"
log_level: debug
prom_metrics_enabled: false
prom_metrics_add_default: true
prom_metrics_port: 3333
prom_metrics_display_url: 'localhost'
connectors:
elasticsearch-next:
default:
Expand Down
4 changes: 4 additions & 0 deletions e2e/k8s/workerConfig/teraslice.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
terafoundation:
environment: "development"
log_level: debug
prom_metrics_enabled: false
prom_metrics_port: 3333
prom_metrics_add_default: true
prom_metrics_display_url: 'localhost'
connectors:
elasticsearch-next:
default:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "teraslice-workspace",
"displayName": "Teraslice",
"version": "2.6.0",
"version": "2.6.1",
"private": true,
"homepage": "https://github.com/terascope/teraslice",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion packages/job-components/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/job-components",
"displayName": "Job Components",
"version": "1.5.1",
"version": "1.5.2",
"description": "A teraslice library for validating jobs schemas, registering apis, and defining and running new Job APIs",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/job-components#readme",
"bugs": {
Expand Down
3 changes: 1 addition & 2 deletions packages/job-components/src/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,10 @@ export class TestContext implements i.Context {

const defaultLabels = {
name: 'mockPromMetrics',
assignment,
...labels
};

const finalPrefix = prefix || `teraslice_${config.assignment}_`;
const finalPrefix = prefix || `teraslice_${assignment}_`;

if (useDefaultMetrics) {
const defaultMetricsConfig = {
Expand Down
8 changes: 4 additions & 4 deletions packages/job-components/test/test-helpers-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe('Test Helpers', () => {
});

it('should add, inc and delete counter', async () => {
await context.apis.foundation.promMetrics.addCounter('test_counter', 'test_counter help string', ['uuid', 'name', 'assignment'], function collect() {
await context.apis.foundation.promMetrics.addCounter('test_counter', 'test_counter help string', ['uuid', 'name'], function collect() {
this.inc({ uuid: 'e&vgv%56' }, 1);
});
context.apis.foundation.promMetrics.inc('test_counter', { uuid: 'e&vgv%56' }, 1);
Expand All @@ -164,7 +164,7 @@ describe('Test Helpers', () => {
});

it('should inc, dec, and set gauge', async () => {
await context.apis.foundation.promMetrics.addGauge('test_gauge', 'help string', ['uuid', 'name', 'assignment']);
await context.apis.foundation.promMetrics.addGauge('test_gauge', 'help string', ['uuid', 'name']);
context.apis.foundation.promMetrics.set('test_gauge', { uuid: '437Ev89h' }, 10);
context.apis.foundation.promMetrics.inc('test_gauge', { uuid: '437Ev89h' }, 1);
context.apis.foundation.promMetrics.dec('test_gauge', { uuid: '437Ev89h' }, 2);
Expand All @@ -188,7 +188,7 @@ describe('Test Helpers', () => {
.toThrow('Metric missing_test_gauge is not setup');
});
it('should add and observe summary', async () => {
await context.apis.foundation.promMetrics.addSummary('test_summary', 'test_summary help string', ['uuid', 'name', 'assignment']);
await context.apis.foundation.promMetrics.addSummary('test_summary', 'test_summary help string', ['uuid', 'name']);
context.apis.foundation.promMetrics.observe('test_summary', { uuid: '34rhEqrX' }, 12);
context.apis.foundation.promMetrics.observe('test_summary', { uuid: '34rhEqrX' }, 5);
context.apis.foundation.promMetrics.observe('test_summary', { uuid: '34rhEqrX' }, 18);
Expand All @@ -200,7 +200,7 @@ describe('Test Helpers', () => {
});

it('should add and observe histogram', async () => {
await context.apis.foundation.promMetrics.addHistogram('test_histogram', 'test_histogram help string', ['uuid', 'name', 'assignment']);
await context.apis.foundation.promMetrics.addHistogram('test_histogram', 'test_histogram help string', ['uuid', 'name']);
context.apis.foundation.promMetrics.observe('test_histogram', { uuid: 'dEF4Kby6' }, 10);
context.apis.foundation.promMetrics.observe('test_histogram', { uuid: 'dEF4Kby6' }, 30);
context.apis.foundation.promMetrics.observe('test_histogram', { uuid: 'dEF4Kby6' }, 2);
Expand Down
2 changes: 1 addition & 1 deletion packages/terafoundation/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "terafoundation",
"displayName": "Terafoundation",
"version": "1.5.1",
"version": "1.5.2",
"description": "A Clustering and Foundation tool for Terascope Tools",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/terafoundation#readme",
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export class PromMetrics {

this.default_labels = {
name: terasliceName,
assignment: apiConfig.assignment,
url: prom_metrics_display_url,
...apiConfig.labels
};
Expand Down Expand Up @@ -374,7 +373,7 @@ export class PromMetrics {
private _setPodName(): void {
// in a pod the hostname is the pod name
const host = os.hostname();
if (host.startsWith('ts-wkr-')) {
if (host.startsWith('ts-wkr-') || host.startsWith('ts-exc-')) {
this.default_labels.pod_name = host;
}
}
Expand Down
3 changes: 1 addition & 2 deletions packages/terafoundation/test/apis/prom-metrics-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('promMetrics foundation API', () => {

it('should have correct default labels', async () => {
const labels = await context.apis.foundation.promMetrics.getDefaultLabels();
expect(labels).toEqual({ assignment: 'worker', name: 'tera-test', url: 'http://localhost' });
expect(labels).toEqual({ name: 'tera-test', url: 'http://localhost' });
});

it('should throw an error if promMetricsAPI is already initialized', async () => {
Expand Down Expand Up @@ -659,7 +659,6 @@ describe('promMetrics foundation API', () => {
it('should get all the default labels', () => {
expect(context.apis.foundation.promMetrics.getDefaultLabels()).toEqual({
name: 'tera-test-labels',
assignment: 'master',
default1: 'value1'
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/teraslice-test-harness/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"fs-extra": "^11.2.0"
},
"devDependencies": {
"@terascope/job-components": "^1.5.1"
"@terascope/job-components": "^1.5.2"
},
"peerDependencies": {
"@terascope/job-components": ">=1.5.1"
"@terascope/job-components": ">=1.5.2"
},
"engines": {
"node": ">=18.18.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/teraslice/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "teraslice",
"displayName": "Teraslice",
"version": "2.6.0",
"version": "2.6.1",
"description": "Distributed computing platform for processing JSON data",
"homepage": "https://github.com/terascope/teraslice#readme",
"bugs": {
Expand Down Expand Up @@ -40,7 +40,7 @@
"dependencies": {
"@kubernetes/client-node": "^0.22.0",
"@terascope/elasticsearch-api": "^4.3.1",
"@terascope/job-components": "^1.5.1",
"@terascope/job-components": "^1.5.2",
"@terascope/teraslice-messaging": "^1.6.1",
"@terascope/types": "^1.2.0",
"@terascope/utils": "^1.3.1",
Expand All @@ -63,7 +63,7 @@
"semver": "^7.6.3",
"socket.io": "^1.7.4",
"socket.io-client": "^1.7.4",
"terafoundation": "^1.5.1",
"terafoundation": "^1.5.2",
"uuid": "^10.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/teraslice/src/lib/cluster/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ export class ApiService {
for (const node in clusterState) {
if (clusterState[node].active) {
for (const worker of clusterState[node].active) {
if (!filteredExecutions[worker.ex_id]) {
if (worker.ex_id && !filteredExecutions[worker.ex_id]) {
filteredExecutions[worker.ex_id] = worker.ex_id;
const exLabel = {
ex_id: worker.ex_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ export class ExecutionController {
ex_id: exId,
job_id: jobId,
job_name: config.name,
assignment: 'execution_controller'
},
prefix: 'teraslice_job_',
prom_metrics_display_url: terafoundation.prom_metrics_display_url

});
Expand Down Expand Up @@ -1186,7 +1188,7 @@ export class ExecutionController {
const { context, executionAnalytics } = this;
await Promise.all([
this.context.apis.foundation.promMetrics.addGauge(
'info',
'execution_controller_info',
'Information about Teraslice execution controller',
['arch', 'clustering_type', 'name', 'node_version', 'platform', 'teraslice_version'],
),
Expand All @@ -1205,7 +1207,7 @@ export class ExecutionController {
]);

this.context.apis.foundation.promMetrics.set(
'info',
'execution_controller_info',
{
arch: this.context.arch,
clustering_type: this.context.sysconfig.teraslice.cluster_manager_type,
Expand Down
6 changes: 4 additions & 2 deletions packages/teraslice/src/lib/workers/worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ export class Worker {
ex_id: exId,
job_id: jobId,
job_name: config.name,
assignment: 'worker'
},
prefix: 'teraslice_job_',
prom_metrics_display_url: terafoundation.prom_metrics_display_url
});
await this.setupPromMetrics();
Expand Down Expand Up @@ -423,7 +425,7 @@ export class Worker {
const self = this;
await Promise.all([
this.context.apis.foundation.promMetrics.addGauge(
'info',
'worker_info',
'Information about Teraslice worker',
['arch', 'clustering_type', 'name', 'node_version', 'platform', 'teraslice_version'],
),
Expand All @@ -442,7 +444,7 @@ export class Worker {
]);

this.context.apis.foundation.promMetrics.set(
'info',
'worker_info',
{
arch: this.context.arch,
clustering_type: this.context.sysconfig.teraslice.cluster_manager_type,
Expand Down

0 comments on commit b9590ca

Please sign in to comment.