Skip to content

Commit aaaae01

Browse files
committed
fix: workerManager related bugs
1 parent dab5cd8 commit aaaae01

File tree

11 files changed

+27
-58
lines changed

11 files changed

+27
-58
lines changed

src/PolykeyAgent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import process from 'process';
1010
import Logger from '@matrixai/logger';
1111
import { DB } from '@matrixai/db';
1212
import { CreateDestroyStartStop } from '@matrixai/async-init/dist/CreateDestroyStartStop';
13-
import { WorkerManager } from '@matrixai/workers';
13+
import { WorkerManager } from './workers';
1414
import * as networkUtils from './network/utils';
1515
import KeyRing from './keys/KeyRing';
1616
import CertManager from './keys/CertManager';

src/bin/agent/CommandStart.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ class CommandStart extends CommandPolykey {
191191
const messageIn: AgentChildProcessInput = {
192192
logLevel: this.logger.getEffectiveLevel(),
193193
format: options.format,
194-
workers: options.workers,
195194
agentConfig,
196195
};
197196
agentProcess.send(messageIn, (e) => {

src/bin/polykey-agent.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* @module
66
*/
77
import type { AgentChildProcessInput, AgentChildProcessOutput } from './types';
8-
import type { PolykeyWorkerManagerInterface } from '../workers/types';
98
import fs from 'fs';
109
import process from 'process';
1110
/**
@@ -23,7 +22,6 @@ import Logger, { StreamHandler, formatting } from '@matrixai/logger';
2322
import * as binUtils from './utils';
2423
import PolykeyAgent from '../PolykeyAgent';
2524
import * as nodesUtils from '../nodes/utils';
26-
import { WorkerManager, utils as workersUtils } from '../workers';
2725
import ErrorPolykey from '../ErrorPolykey';
2826
import grpcSetLogger from '../grpc/utils/setLogger';
2927
import { promisify, promise } from '../utils';
@@ -57,10 +55,7 @@ async function main(_argv = process.argv): Promise<number> {
5755
// Set the global upstream GRPC logger
5856
grpcSetLogger(logger.getChild('grpc'));
5957
let pkAgent: PolykeyAgent;
60-
let workerManager: PolykeyWorkerManagerInterface;
6158
exitHandlers.handlers.push(async () => {
62-
pkAgent?.unsetWorkerManager();
63-
await workerManager?.destroy();
6459
await pkAgent?.stop();
6560
});
6661
try {
@@ -69,13 +64,6 @@ async function main(_argv = process.argv): Promise<number> {
6964
logger: logger.getChild(PolykeyAgent.name),
7065
...messageIn.agentConfig,
7166
});
72-
if (messageIn.workers !== 0) {
73-
workerManager = await workersUtils.createWorkerManager({
74-
cores: messageIn.workers,
75-
logger: logger.getChild(WorkerManager.name),
76-
});
77-
pkAgent.setWorkerManager(workerManager);
78-
}
7967
} catch (e) {
8068
if (e instanceof ErrorPolykey) {
8169
process.stderr.write(

tests/PolykeyAgent.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ describe('PolykeyAgent', () => {
6363
passwordMemLimit: keysUtils.passwordMemLimits.min,
6464
strictMemoryLock: false,
6565
},
66+
workers: 0,
6667
});
6768
let nodePathContents = await fs.promises.readdir(nodePath);
6869
expect(nodePathContents).toContain(config.defaults.statusBase);

tests/bin/agent/start.test.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('start', () => {
4747
'--proxy-host',
4848
'127.0.0.1',
4949
'--workers',
50-
'0',
50+
'none',
5151
'--verbose',
5252
'--format',
5353
'json',
@@ -124,7 +124,7 @@ describe('start', () => {
124124
'--background-err-file',
125125
path.join(dataDir, 'err.log'),
126126
'--workers',
127-
'0',
127+
'none',
128128
'--verbose',
129129
'--format',
130130
'json',
@@ -223,7 +223,7 @@ describe('start', () => {
223223
'--proxy-host',
224224
'127.0.0.1',
225225
'--workers',
226-
'0',
226+
'none',
227227
'--verbose',
228228
'--format',
229229
'json',
@@ -249,7 +249,7 @@ describe('start', () => {
249249
'--proxy-host',
250250
'127.0.0.1',
251251
'--workers',
252-
'0',
252+
'none',
253253
'--verbose',
254254
'--format',
255255
'json',
@@ -323,7 +323,7 @@ describe('start', () => {
323323
'--proxy-host',
324324
'127.0.0.1',
325325
'--workers',
326-
'0',
326+
'none',
327327
'--verbose',
328328
'--format',
329329
'json',
@@ -385,7 +385,6 @@ describe('start', () => {
385385
errorStatusLocked,
386386
]);
387387
bootstrapProcess.kill('SIGTERM');
388-
} else if (index === 1) {
389388
testUtils.expectProcessError(exitCode!, stdErrLine2, [
390389
errorStatusLocked,
391390
]);
@@ -409,7 +408,7 @@ describe('start', () => {
409408
'--proxy-host',
410409
'127.0.0.1',
411410
'--workers',
412-
'0',
411+
'none',
413412
'--verbose',
414413
],
415414
{
@@ -439,7 +438,7 @@ describe('start', () => {
439438
'--proxy-host',
440439
'127.0.0.1',
441440
'--workers',
442-
'0',
441+
'none',
443442
'--verbose',
444443
],
445444
{
@@ -487,7 +486,7 @@ describe('start', () => {
487486
'--proxy-host',
488487
'127.0.0.1',
489488
'--workers',
490-
'0',
489+
'none',
491490
'--verbose',
492491
],
493492
{
@@ -528,7 +527,7 @@ describe('start', () => {
528527
'--proxy-host',
529528
'127.0.0.1',
530529
'--workers',
531-
'0',
530+
'none',
532531
'--fresh',
533532
'--verbose',
534533
'--format',
@@ -615,7 +614,7 @@ describe('start', () => {
615614
'--proxy-host',
616615
'127.0.0.1',
617616
'--workers',
618-
'0',
617+
'none',
619618
'--verbose',
620619
'--format',
621620
'json',
@@ -655,7 +654,7 @@ describe('start', () => {
655654
'--proxy-host',
656655
'127.0.0.1',
657656
'--workers',
658-
'0',
657+
'none',
659658
'--verbose',
660659
],
661660
{
@@ -678,7 +677,7 @@ describe('start', () => {
678677
await testUtils.processExit(agentProcess2);
679678
// Check that the password has changed
680679
const agentProcess3 = await testUtils.pkSpawn(
681-
['agent', 'start', '--workers', '0', '--verbose'],
680+
['agent', 'start', '--workers', 'none', '--verbose'],
682681
{
683682
env: {
684683
PK_NODE_PATH: path.join(dataDir, 'polykey'),
@@ -712,7 +711,7 @@ describe('start', () => {
712711
'--proxy-host',
713712
'127.0.0.1',
714713
'--workers',
715-
'0',
714+
'none',
716715
'--verbose',
717716
],
718717
{
@@ -763,7 +762,7 @@ describe('start', () => {
763762
'agent',
764763
'start',
765764
'--workers',
766-
'0',
765+
'none',
767766
'--client-host',
768767
clientHost,
769768
'--client-port',
@@ -833,7 +832,7 @@ describe('start', () => {
833832
'agent',
834833
'start',
835834
'--workers',
836-
'0',
835+
'none',
837836
'--verbose',
838837
'--private-key-file',
839838
privateKeyPath,
@@ -931,7 +930,7 @@ describe('start', () => {
931930
'--proxy-host',
932931
'127.0.0.1',
933932
'--workers',
934-
'0',
933+
'none',
935934
'--seed-nodes',
936935
`${seedNodeId1}@${seedNodeHost1}:${seedNodePort1};<defaults>`,
937936
'--network',
@@ -998,7 +997,7 @@ describe('start', () => {
998997
'--proxy-host',
999998
'127.0.0.1',
1000999
'--workers',
1001-
'0',
1000+
'none',
10021001
'--verbose',
10031002
],
10041003
{

tests/bin/agent/status.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('status', () => {
4848
'--proxy-host',
4949
'127.0.0.1',
5050
'--workers',
51-
'0',
51+
'none',
5252
'--verbose',
5353
],
5454
{

tests/bin/agent/stop.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('stop', () => {
3737
'--proxy-host',
3838
'127.0.0.1',
3939
'--workers',
40-
'0',
40+
'none',
4141
],
4242
{
4343
env: {
@@ -103,7 +103,7 @@ describe('stop', () => {
103103
'--proxy-host',
104104
'127.0.0.1',
105105
'--workers',
106-
'0',
106+
'none',
107107
],
108108
{
109109
env: {
@@ -201,7 +201,7 @@ describe('stop', () => {
201201
'--proxy-host',
202202
'127.0.0.1',
203203
'--workers',
204-
'0',
204+
'none',
205205
'--verbose',
206206
],
207207
{
@@ -255,7 +255,7 @@ describe('stop', () => {
255255
'--proxy-host',
256256
'127.0.0.1',
257257
'--workers',
258-
'0',
258+
'none',
259259
],
260260
{
261261
env: {

tests/bin/identities/authenticateAuthenticated.test.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,10 @@ describe('authenticate/authenticated', () => {
140140
},
141141
));
142142
expect(exitCode).toBe(sysexits.USAGE);
143-
// Invalid identity
144-
({ exitCode } = await testUtils.pkStdio(
145-
['identities', 'authenticate', testToken.providerId, ''],
146-
{
147-
env: {
148-
PK_NODE_PATH: nodePath,
149-
PK_PASSWORD: password,
150-
},
151-
cwd: dataDir,
152-
},
153-
));
154-
expect(exitCode).toBe(sysexits.USAGE);
155143
// Authenticated
156144
// Invalid provider
157145
({ exitCode } = await testUtils.pkStdio(
158-
['identities', 'authenticate', '--provider-id', ''],
146+
['identities', 'authenticate', ''],
159147
{
160148
env: {
161149
PK_NODE_PATH: nodePath,

tests/bin/polykey.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('polykey', () => {
3838
'--proxy-host',
3939
'127.0.0.1',
4040
'--workers',
41-
'0',
41+
'none',
4242
'--verbose',
4343
'--format',
4444
'json',

tests/bin/utils.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ describe('bin/utils', () => {
141141
).toBe(`${standardError.name}: ${standardError.message}\n`);
142142
expect(binUtils.outputFormatter({ type: 'error', data: pkError })).toBe(
143143
`${pkError.name}: ${pkError.description} - ${pkError.message}\n` +
144-
` exitCode\t${pkError.exitCode}\n` +
145-
` timestamp\t${timestamp.toString()}\n` +
146144
` data\t${JSON.stringify(data)}\n`,
147145
);
148146
expect(
@@ -155,8 +153,6 @@ describe('bin/utils', () => {
155153
` port\t${port}\n` +
156154
` timestamp\t${timestamp.toString()}\n` +
157155
` cause: ${remoteError.cause.name}: ${remoteError.cause.description} - ${remoteError.cause.message}\n` +
158-
` exitCode\t${pkError.exitCode}\n` +
159-
` timestamp\t${timestamp.toString()}\n` +
160156
` data\t${JSON.stringify(data)}\n`,
161157
);
162158
expect(
@@ -175,8 +171,6 @@ describe('bin/utils', () => {
175171
` port\t${port}\n` +
176172
` timestamp\t${timestamp.toString()}\n` +
177173
` cause: ${twoRemoteErrors.cause.cause.name}: ${twoRemoteErrors.cause.cause.description} - ${twoRemoteErrors.cause.cause.message}\n` +
178-
` exitCode\t${pkError.exitCode}\n` +
179-
` timestamp\t${timestamp.toString()}\n` +
180174
` cause: ${standardError.name}: ${standardError.message}\n`,
181175
);
182176
// JSON

0 commit comments

Comments
 (0)