Parcourir la source

[rails] migrate compiles of conversions/submissions to history mode (#32053)

* [saas-e2e] test gallery templates with binary file

* [rails] add make target for fixing rubocop errors

* [rails] migrate compiles of conversions/submissions to history mode

* [rails] forward version to clsi request

* [rails] trim down compile request

* [saas-e2e] source v1 secrets after make install

GitOrigin-RevId: 65269e1df1051c9f3b4f1813d2e9dcf32a01be50
Jakob Ackermann il y a 4 mois
Parent
commit
2e389c5a41

+ 2 - 2
services/clsi/app/js/CompileManager.js

@@ -107,7 +107,7 @@ async function doCompile(request, stats, timings) {
 
   let resourceList, baseHistoryVersion
   try {
-    if (request.historyId) {
+    if (request.rawChangeOperations) {
       ;({ resourceList, baseHistoryVersion } =
         await HistoryResourceWriter.syncResourcesToDisk(
           projectId,
@@ -849,7 +849,7 @@ function _emitMetrics(request, status, stats, timings) {
   if (timings.compileE2E != null) {
     ClsiMetrics.e2eCompileDurationSeconds.observe(
       {
-        compileFromHistory: !!request.historyId,
+        compileFromHistory: !!request.rawChangeOperations,
         compile: request.metricsOpts.compile,
         group: request.compileGroup,
       },

+ 13 - 3
services/clsi/app/js/HistoryResourceWriter.js

@@ -421,7 +421,11 @@ export async function syncResourcesToDisk(
     )
   }
 
-  const blobStore = new BlobStore(request.historyId, globalBlobs)
+  const blobStore = new BlobStore(
+    request.historyId,
+    request.filestoreBlobPrefix,
+    globalBlobs
+  )
   const loadEagerStart = performance.now()
   await snapshot.loadFiles('eager', blobStore)
   timings.snapshotLoadEager = Math.ceil(performance.now() - loadEagerStart)
@@ -503,13 +507,17 @@ class BlobStore {
   #historyId
   /** @type {string[]} */
   #globalBlobs
+  /** @type {string} */
+  #filestoreBlobPrefix
 
   /**
    * @param {string} historyId
+   * @param {string} filestoreBlobPrefix
    * @param {string[]} globalBlobs
    */
-  constructor(historyId, globalBlobs) {
+  constructor(historyId, filestoreBlobPrefix, globalBlobs) {
     this.#historyId = historyId
+    this.#filestoreBlobPrefix = filestoreBlobPrefix
     this.#globalBlobs = globalBlobs
   }
 
@@ -519,7 +527,9 @@ class BlobStore {
    */
   getBlobURL(hash) {
     const u = new URL(Settings.apis.filestore.url)
-    if (this.#globalBlobs.includes(hash)) {
+    if (this.#filestoreBlobPrefix) {
+      u.pathname = `${this.#filestoreBlobPrefix}/${hash}`
+    } else if (this.#globalBlobs.includes(hash)) {
       u.pathname = `/history/global/hash/${hash}`
     } else {
       u.pathname = `/history/project/${this.#historyId}/hash/${hash}`

+ 5 - 0
services/clsi/app/js/RequestParser.js

@@ -162,6 +162,11 @@ function parse(body, callback) {
     response.rawSnapshot = compile.rawSnapshot
     response.rawChangeOperations = compile.rawChangeOperations
 
+    // v1 conversions / submissions
+    if (compile.filestoreBlobPrefix) {
+      response.filestoreBlobPrefix = _checkPath(compile.filestoreBlobPrefix)
+    }
+
     const rootResourcePath = _parseAttribute(
       'rootResourcePath',
       compile.rootResourcePath,

+ 1 - 1
services/web/app/src/Features/Compile/ClsiManager.mjs

@@ -287,7 +287,7 @@ async function _sendBuiltRequest(projectId, userId, req, options) {
     await clearClsiServerId(projectId, userId, options.compileBackendClass)
   }
   const validationProblems = ClsiFormatChecker.checkRecoursesForProblems(
-    req.compile?.resources
+    req.compile?.resources || []
   )
   if (validationProblems != null) {
     logger.debug(