Skip to content
This repository was archived by the owner on Sep 12, 2024. It is now read-only.

Commit 2ee7161

Browse files
committed
feat: add motion support
1 parent 276be28 commit 2ee7161

File tree

8 files changed

+134
-15
lines changed

8 files changed

+134
-15
lines changed

config.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"metricsListenOn": [],
66
"replicationGroupId": "RG001",
77
"restEndpoints": {
8-
"localhost": "us-east-1",
8+
"localhost": "location-motion-v1",
99
"127.0.0.1": "us-east-1",
1010
"cloudserver-front": "us-east-1",
1111
"s3.docker.test": "us-east-1",
@@ -60,7 +60,7 @@
6060
},
6161
"clusters": 1,
6262
"log": {
63-
"logLevel": "info",
63+
"logLevel": "debug",
6464
"dumpLevel": "error"
6565
},
6666
"healthChecks": {
@@ -90,6 +90,10 @@
9090
"bindAddress": "localhost",
9191
"port": 9992
9292
},
93+
"motionDaemon": {
94+
"bindAddress": "localhost",
95+
"port": 40080
96+
},
9397
"recordLog": {
9498
"enabled": true,
9599
"recordLogName": "s3-recordlog"

constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ const constants = {
129129
},
130130
},
131131
/* eslint-disable camelcase */
132-
externalBackends: { aws_s3: true, azure: true, gcp: true, pfs: true, dmf: true, azure_archive: true },
132+
externalBackends: { aws_s3: true, azure: true, gcp: true, pfs: true, dmf: true, azure_archive: true, motion: true },
133133
// some of the available data backends (if called directly rather
134134
// than through the multiple backend gateway) need a key provided
135135
// as a string as first parameter of the get/delete methods.
@@ -138,7 +138,7 @@ const constants = {
138138
// for external backends, don't call unless at least 1 minute
139139
// (60,000 milliseconds) since last call
140140
externalBackendHealthCheckInterval: 60000,
141-
versioningNotImplBackends: { azure: true, gcp: true },
141+
versioningNotImplBackends: { azure: true, gcp: true, motion: true },
142142
mpuMDStoredExternallyBackend: { aws_s3: true, gcp: true },
143143
skipBatchDeleteBackends: { azure: true, gcp: true },
144144
s3HandledBackends: { azure: true, gcp: true },

lib/Config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,6 +1851,11 @@ class Config extends EventEmitter {
18511851
this.locationConstraints[locationConstraint].details.pfsDaemonEndpoint;
18521852
}
18531853

1854+
getMotionDaemonEndpoint(locationConstraint) {
1855+
return process.env[`${locationConstraint}_MOTION_ENDPOINT`] ||
1856+
this.locationConstraints[locationConstraint].details.motionDaemonEndpoint;
1857+
}
1858+
18541859
isSameAzureAccount(locationConstraintSrc, locationConstraintDest) {
18551860
if (!locationConstraintDest) {
18561861
return true;

lib/data/external/motionClient.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import arsenal from 'arsenal';
2+
3+
export class MotionClient {
4+
constructor(config) {
5+
this.motionEndpoint = config.motionEndpoint;
6+
this.client = new arsenal.network.rest.RESTClient({
7+
host: config.host,
8+
port: config.port,
9+
isPassthrough: true,
10+
})
11+
}
12+
13+
createMotionKey(bucketName, objectKey) {
14+
return `${bucketName}/${objectKey}`;
15+
}
16+
17+
put(stream, size, keyContext, reqUids, callback) {
18+
const motionKey = this.createMotionKey(keyContext.bucketName, keyContext.objectKey);
19+
}
20+
21+
get(keyContext, reqUids, callback) {
22+
const motionKey = this.createMotionKey(keyContext.bucketName, keyContext.objectKey);
23+
}
24+
}

locationConfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,18 @@
108108
"legacyAwsBehavior": false,
109109
"isCold": true,
110110
"details": {}
111+
},
112+
"location-motion-v1": {
113+
"type": "motion",
114+
"objectId": "location-motion-v1",
115+
"legacyAwsBehavior": false,
116+
"isCold": false,
117+
"details": {
118+
"motionDaemonEndpoint": {
119+
"host": "localhost",
120+
"path": "/v0/blob",
121+
"port": 40080
122+
}
123+
}
111124
}
112125
}

motionserver.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict'; // eslint-disable-line strict
2+
3+
const arsenal = require('arsenal');
4+
const { config } = require('./lib/Config.js');
5+
const logger = require('./lib/utilities/logger.js');
6+
7+
const pfsServer = new arsenal.network.rest.RESTServer({
8+
bindAddress: config.motionDaemon.bindAddress,
9+
port: config.motionDaemon.port,
10+
dataStore: new arsenal.storage.data.file.DataFileStore({
11+
dataPath: config.motionDaemon.dataPath,
12+
log: config.log,
13+
noSync: config.motionDaemon.noSync,
14+
noCache: config.motionDaemon.noCache,
15+
isPassthrough: true,
16+
isReadOnly: config.motionDaemon.isReadOnly,
17+
}),
18+
log: config.log,
19+
});
20+
21+
motionServer.setup(err => {
22+
if (err) {
23+
logger.error('Error initializing REST MotionServer', {
24+
error: err,
25+
});
26+
return;
27+
}
28+
pfsServer.start();
29+
});

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"dependencies": {
2222
"@azure/storage-blob": "^12.12.0",
2323
"@hapi/joi": "^17.1.0",
24-
"arsenal": "git+https://github.com/scality/arsenal#8.1.105",
24+
"arsenal": "git+https://github.com/filecoin-project/motion-arsenal",
2525
"async": "~2.5.0",
2626
"aws-sdk": "2.905.0",
2727
"bucketclient": "scality/bucketclient#8.1.9",
@@ -100,6 +100,7 @@
100100
"start_mdserver": "node mdserver.js",
101101
"start_dataserver": "node dataserver.js",
102102
"start_pfsserver": "node pfsserver.js",
103+
"start_motionserver": "node motionserver.js",
103104
"start_s3server": "node index.js",
104105
"start_dmd": "npm-run-all --parallel start_mdserver start_dataserver",
105106
"start_utapi": "node lib/utapi/utapi.js",

yarn.lock

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -747,9 +747,10 @@ arraybuffer.slice@~0.0.7:
747747
resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz#3bbc4275dd584cc1b10809b89d4e8b63a69e7675"
748748
integrity sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog==
749749

750-
"arsenal@git+https://github.com/scality/Arsenal#8.1.87":
751-
version "8.1.87"
752-
resolved "git+https://github.com/scality/Arsenal#ab0324da059c62171da4b9cf496dd067e22caac9"
750+
"arsenal@git+https://github.com/filecoin-project/motion-arsenal":
751+
version "8.1.105"
752+
uid "6e08c4fa9bddb7ac5733d69d5f1ee0cc3fb7bef5"
753+
resolved "git+https://github.com/filecoin-project/motion-arsenal#6e08c4fa9bddb7ac5733d69d5f1ee0cc3fb7bef5"
753754
dependencies:
754755
"@azure/identity" "^3.1.1"
755756
"@azure/storage-blob" "^12.12.0"
@@ -766,7 +767,7 @@ arraybuffer.slice@~0.0.7:
766767
bson "4.0.0"
767768
debug "~4.1.0"
768769
diskusage "^1.1.1"
769-
fcntl "github:scality/node-fcntl#0.2.0"
770+
fcntl "github:scality/node-fcntl#0.2.2"
770771
hdclient scality/hdclient#1.1.5
771772
httpagent scality/httpagent#1.0.6
772773
https-proxy-agent "^2.2.0"
@@ -775,23 +776,23 @@ arraybuffer.slice@~0.0.7:
775776
joi "^17.6.0"
776777
level "~5.0.1"
777778
level-sublevel "~6.6.5"
778-
mongodb "^3.0.1"
779+
mongodb "^5.2.0"
779780
node-forge "^1.3.0"
780781
prom-client "14.2.0"
781782
simple-glob "^0.2.0"
782-
socket.io "2.4.1"
783-
socket.io-client "2.4.0"
784-
sproxydclient scality/sproxydclient#8.0.7
783+
socket.io "~4.6.1"
784+
socket.io-client "~4.6.1"
785+
sproxydclient "git+https://github.com/scality/sproxydclient#8.0.9"
785786
utf8 "3.0.0"
786787
uuid "^3.0.1"
787788
werelogs scality/werelogs#8.1.2
788789
xml2js "~0.4.23"
789790
optionalDependencies:
790791
ioctl "^2.0.2"
791792

792-
"arsenal@git+https://github.com/scality/arsenal#8.1.105":
793+
"arsenal@git+https://github.com/kylehuntsman/Arsenal#6e08c4fa":
793794
version "8.1.105"
794-
resolved "git+https://github.com/scality/arsenal#7c4f4611966fc21e2d79d74928a3ab0cea287a93"
795+
resolved "git+https://github.com/kylehuntsman/Arsenal#6e08c4fa9bddb7ac5733d69d5f1ee0cc3fb7bef5"
795796
dependencies:
796797
"@azure/identity" "^3.1.1"
797798
"@azure/storage-blob" "^12.12.0"
@@ -831,6 +832,48 @@ arraybuffer.slice@~0.0.7:
831832
optionalDependencies:
832833
ioctl "^2.0.2"
833834

835+
"arsenal@git+https://github.com/scality/Arsenal#8.1.87":
836+
version "8.1.87"
837+
resolved "git+https://github.com/scality/Arsenal#ab0324da059c62171da4b9cf496dd067e22caac9"
838+
dependencies:
839+
"@azure/identity" "^3.1.1"
840+
"@azure/storage-blob" "^12.12.0"
841+
"@types/async" "^3.2.12"
842+
"@types/utf8" "^3.0.1"
843+
JSONStream "^1.0.0"
844+
agentkeepalive "^4.1.3"
845+
ajv "6.12.3"
846+
async "~2.6.4"
847+
aws-sdk "^2.1005.0"
848+
backo "^1.1.0"
849+
base-x "3.0.8"
850+
base62 "2.0.1"
851+
bson "4.0.0"
852+
debug "~4.1.0"
853+
diskusage "^1.1.1"
854+
fcntl "github:scality/node-fcntl#0.2.0"
855+
hdclient scality/hdclient#1.1.5
856+
httpagent scality/httpagent#1.0.6
857+
https-proxy-agent "^2.2.0"
858+
ioredis "^4.28.5"
859+
ipaddr.js "1.9.1"
860+
joi "^17.6.0"
861+
level "~5.0.1"
862+
level-sublevel "~6.6.5"
863+
mongodb "^3.0.1"
864+
node-forge "^1.3.0"
865+
prom-client "14.2.0"
866+
simple-glob "^0.2.0"
867+
socket.io "2.4.1"
868+
socket.io-client "2.4.0"
869+
sproxydclient scality/sproxydclient#8.0.7
870+
utf8 "3.0.0"
871+
uuid "^3.0.1"
872+
werelogs scality/werelogs#8.1.2
873+
xml2js "~0.4.23"
874+
optionalDependencies:
875+
ioctl "^2.0.2"
876+
834877
asn1@~0.2.3:
835878
version "0.2.6"
836879
resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.6.tgz#0d3a7bb6e64e02a90c0303b31f292868ea09a08d"

0 commit comments

Comments
 (0)