@@ -20,6 +20,7 @@ const s3_rest = require('./s3/s3_rest');
20
20
const blob_rest = require ( './blob/blob_rest' ) ;
21
21
const sts_rest = require ( './sts/sts_rest' ) ;
22
22
const iam_rest = require ( './iam/iam_rest' ) ;
23
+ const { CONFIG_DIR_VERSION } = require ( '../sdk/config_fs' ) ;
23
24
const lambda_rest = require ( './lambda/lambda_rest' ) ;
24
25
const endpoint_utils = require ( './endpoint_utils' ) ;
25
26
const FuncSDK = require ( '../sdk/func_sdk' ) ;
@@ -60,6 +61,13 @@ const SERVICES_TYPES_ENUM = Object.freeze({
60
61
METRICS : 'METRICS'
61
62
} ) ;
62
63
64
+ const INTERNAL_APIS_OBJ = Object . freeze ( {
65
+ VERSION : 'version' ,
66
+ CONFIG_FS_VERSION : 'config_fs_version' ,
67
+ ENDPOINT_FORK_ID : 'endpoint_fork_id' ,
68
+ TOTAL_FORK_COUNT : 'total_fork_count'
69
+ } ) ;
70
+
63
71
const new_umask = process . env . NOOBAA_ENDPOINT_UMASK || 0o000 ;
64
72
const old_umask = process . umask ( new_umask ) ;
65
73
let fork_count ;
@@ -291,15 +299,17 @@ function create_endpoint_handler(server_type, init_request_sdk, { virtual_hosts,
291
299
return lambda_rest_handler ( req , res ) ;
292
300
} else if ( req . headers [ 'x-ms-version' ] ) {
293
301
return blob_rest_handler ( req , res ) ;
294
- } else if ( req . url . startsWith ( '/total_fork_count' ) ) {
295
- return fork_count_handler ( req , res ) ;
296
- } else if ( req . url . startsWith ( '/endpoint_fork_id' ) ) {
297
- return endpoint_fork_id_handler ( req , res ) ;
298
302
} else if ( req . url . startsWith ( '/_/' ) ) {
299
303
// internals non S3 requests
300
304
const api = req . url . slice ( '/_/' . length ) ;
301
- if ( api === 'version' ) {
305
+ if ( api === INTERNAL_APIS_OBJ . VERSION ) {
302
306
return version_handler ( req , res ) ;
307
+ } else if ( api === INTERNAL_APIS_OBJ . CONFIG_FS_VERSION ) {
308
+ return config_fs_version_handler ( req , res ) ;
309
+ } else if ( api === INTERNAL_APIS_OBJ . ENDPOINT_FORK_ID ) {
310
+ return endpoint_fork_id_handler ( req , res ) ;
311
+ } else if ( api === INTERNAL_APIS_OBJ . TOTAL_FORK_COUNT ) {
312
+ return fork_count_handler ( req , res ) ;
303
313
} else {
304
314
return internal_api_error ( req , res , `Unknown API call ${ api } ` ) ;
305
315
}
@@ -351,6 +361,21 @@ function version_handler(req, res) {
351
361
res . end ( noobaa_package_version ) ;
352
362
}
353
363
364
+ /**
365
+ * config_fs_version_handler returns the version of configFS
366
+ * this is not the actual config dir version
367
+ * this is the version that NooBaa targets for writing configuration files.
368
+ * @param {EndpointRequest } req
369
+ * @param {import('http').ServerResponse } res
370
+ */
371
+ function config_fs_version_handler ( req , res ) {
372
+ const config_dir_version = CONFIG_DIR_VERSION ;
373
+ res . statusCode = 200 ;
374
+ res . setHeader ( 'Content-Type' , 'text/plain' ) ;
375
+ res . setHeader ( 'Content-Length' , Buffer . byteLength ( config_dir_version ) ) ;
376
+ res . end ( config_dir_version ) ;
377
+ }
378
+
354
379
/**
355
380
* internal_api_error returns an internal api error response
356
381
* @param {EndpointRequest } req
0 commit comments