Explorar el Código

Fix issue with creating migrations from replicas

This fixes a regression bug introduced by using the plugin system for
disabling OCI's root disk mapping.
Sergiu Miclea hace 6 años
padre
commit
0358e72f7d
Se han modificado 2 ficheros con 22 adiciones y 9 borrados
  1. 5 5
      src/sources/InstanceSource.js
  2. 17 4
      src/stores/InstanceStore.js

+ 5 - 5
src/sources/InstanceSource.js

@@ -75,15 +75,16 @@ class InstanceSource {
     return response.data.instances
   }
 
-  async loadInstanceDetails(
+  async loadInstanceDetails(opts: {
     endpointId: string,
     instanceName: string,
-    targetProvider: string,
+    targetProvider?: string,
     reqId: number,
     quietError?: boolean,
     env?: any,
     cache?: ?boolean,
-  ): Promise<{ instance: Instance, reqId: number }> {
+  }): Promise<{ instance: Instance, reqId: number }> {
+    let { endpointId, instanceName, targetProvider, reqId, quietError, env, cache } = opts
     let url = `${servicesUrl.coriolis}/${Api.projectId}/endpoints/${endpointId}/instances/${btoa(instanceName)}`
     if (env) {
       url += `?env=${btoa(JSON.stringify(env))}`
@@ -95,8 +96,7 @@ class InstanceSource {
       cache,
     })
 
-
-    let instanceInfoParser = InstanceInfoPlugin[targetProvider] || InstanceInfoPlugin.default
+    let instanceInfoParser = (targetProvider && InstanceInfoPlugin[targetProvider]) || InstanceInfoPlugin.default
     let instance = instanceInfoParser.parseInstance(response.data.instance)
 
     return { instance, reqId }

+ 17 - 4
src/stores/InstanceStore.js

@@ -229,8 +229,14 @@ class InstanceStore {
     try {
       await Promise.all(instanceInfos.map(async i => {
         await Promise.all(i.instanceNames.map(async name => {
-          let instanceDetails = await InstanceSource.loadInstanceDetails(i.endpointId, name, this.reqId, false,
-            i.env, true)
+          let instanceDetails = await InstanceSource.loadInstanceDetails({
+            endpointId: i.endpointId,
+            instanceName: name,
+            reqId: this.reqId,
+            quietError: false,
+            env: i.env,
+            cache: true,
+          })
           runInAction(() => {
             this.instancesDetails = this.instancesDetails.filter(i => (i.name || i.instance_name || '') !== name)
             this.instancesDetails.push(instanceDetails.instance)
@@ -270,8 +276,15 @@ class InstanceStore {
       Promise.all(instancesInfo.map(async instanceInfo => {
         try {
           let resp: { instance: Instance, reqId: number } =
-            await InstanceSource.loadInstanceDetails(endpointId, instanceInfo.instance_name || instanceInfo.name,
-              targetProvider, this.reqId, quietError, env, cache)
+            await InstanceSource.loadInstanceDetails({
+              endpointId,
+              instanceName: instanceInfo.instance_name || instanceInfo.name,
+              targetProvider,
+              reqId: this.reqId,
+              quietError,
+              env,
+              cache,
+            })
           if (resp.reqId !== this.reqId) {
             return
           }