Page MenuHomePhabricator

D12927.diff
No OneTemporary

D12927.diff

diff --git a/keyserver/src/keyserver.js b/keyserver/src/keyserver.js
--- a/keyserver/src/keyserver.js
+++ b/keyserver/src/keyserver.js
@@ -47,7 +47,10 @@
import { initENSCache } from './utils/ens-cache.js';
import { initFCCache } from './utils/fc-cache.js';
import { getContentSigningKey } from './utils/olm-utils.js';
-import { isPrimaryNode } from './utils/primary-secondary-utils.js';
+import {
+ isPrimaryNode,
+ isSecondaryNode,
+} from './utils/primary-secondary-utils.js';
import { getRunServerConfig } from './utils/server-utils.js';
import {
prefetchAllURLFacts,
@@ -131,20 +134,32 @@
} else {
// Allow login to be optional until staging environment is available
try {
- // We await here to ensure that the keyserver has been provisioned a
- // commServicesAccessToken. In the future, this will be necessary for
- // many keyserver operations.
- const identityInfo = await verifyUserLoggedIn();
+ await (async () => {
+ // Should not be run by Landing or WebApp nodes
+ if (!isPrimaryNode && !isSecondaryNode) {
+ return;
+ }
+
+ // We await here to ensure that the keyserver has been provisioned a
+ // commServicesAccessToken. In the future, this will be necessary for
+ // many keyserver operations.
+ const identityInfo = await verifyUserLoggedIn();
+
+ if (!isPrimaryNode) {
+ return;
+ }
- if (isPrimaryNode) {
// We don't await here, as Tunnelbroker communication is not needed
// for normal keyserver behavior yet. In addition, this doesn't
// return information useful for other keyserver functions.
ignorePromiseRejections(createAndMaintainTunnelbrokerWebsocket(null));
- if (process.env.NODE_ENV === 'development') {
- await createAuthoritativeKeyserverConfigFiles(identityInfo.userId);
+
+ if (process.env.NODE_ENV !== 'development') {
+ return;
}
- }
+
+ await createAuthoritativeKeyserverConfigFiles(identityInfo.userId);
+ })();
} catch (e) {
console.warn(
'Failed identity login. Login optional until staging environment is available',
diff --git a/keyserver/src/utils/primary-secondary-utils.js b/keyserver/src/utils/primary-secondary-utils.js
--- a/keyserver/src/utils/primary-secondary-utils.js
+++ b/keyserver/src/utils/primary-secondary-utils.js
@@ -3,3 +3,7 @@
export const isPrimaryNode: boolean = process.env.COMM_NODE_ROLE
? process.env.COMM_NODE_ROLE === 'primary'
: true;
+
+export const isSecondaryNode: boolean = process.env.COMM_NODE_ROLE
+ ? process.env.COMM_NODE_ROLE === 'secondary'
+ : false;

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 11:10 PM (10 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2581377
Default Alt Text
D12927.diff (2 KB)

Event Timeline