@@ -1223,10 +1223,7 @@ func (fs *FileSystem) startPlanning(t *bolt.Tx, workspaceId, projectId string, d
1223
1223
}
1224
1224
message := "Project: " + project .Id + ";"
1225
1225
// This contains the metadata about a run (host and port of the plan progress server, etc.)
1226
- planProgressServerMeta := types.QAServerMetadata {Host : getDNSHostName (), Debug : debugMode }
1227
- if planProgressServerMeta .Host == "" {
1228
- planProgressServerMeta .Host = "localhost"
1229
- }
1226
+ planProgressServerMeta := types.QAServerMetadata {Host : common .Config .Host , Debug : debugMode }
1230
1227
planProgressServerMeta .Port , err = freeport .GetFreePort ()
1231
1228
if err != nil {
1232
1229
return fmt .Errorf ("failed to get a free port. Error: %q" , err )
@@ -1554,10 +1551,7 @@ func (fs *FileSystem) resumeTransformation(t *bolt.Tx, workspaceId, projectId, p
1554
1551
}
1555
1552
// update state
1556
1553
// resume the transformation
1557
- qaServerMeta .Host = getDNSHostName ()
1558
- if qaServerMeta .Host == "" {
1559
- qaServerMeta .Host = "localhost"
1560
- }
1554
+ qaServerMeta .Host = common .Config .Host
1561
1555
qaServerMeta .Port , err = freeport .GetFreePort ()
1562
1556
if err != nil {
1563
1557
return fmt .Errorf ("failed to get a free port. Error: %q" , err )
@@ -1605,7 +1599,8 @@ func (fs *FileSystem) resumeTransformation(t *bolt.Tx, workspaceId, projectId, p
1605
1599
}
1606
1600
currentRunConfigPaths = append (commonConfigPaths , currentRunConfigPaths ... )
1607
1601
}
1608
- go fs .runTransform (currentRunDir , currentRunConfigPaths , currentRunSrcDir , currentRunCustDir , currentRunOutDir , message , qaServerMeta .Port , transformCh , workspaceId , projectId , projOutput , debugMode )
1602
+ // resume the transformation
1603
+ go fs .runTransform (currentRunDir , currentRunConfigPaths , currentRunSrcDir , currentRunCustDir , currentRunOutDir , message , qaServerMeta .Port , transformCh , workspaceId , projectId , projOutput , debugMode , true )
1609
1604
return nil
1610
1605
}
1611
1606
@@ -1686,10 +1681,7 @@ func (fs *FileSystem) startTransformation(t *bolt.Tx, workspaceId, projectId str
1686
1681
return fmt .Errorf ("failed to update the project with id %s . Error: %q" , projectId , err )
1687
1682
}
1688
1683
// This file contains the metadata about a run (host and port of the QA engine's http server, etc.)
1689
- qaServerMeta := types.QAServerMetadata {Host : getDNSHostName (), Debug : debugMode }
1690
- if qaServerMeta .Host == "" {
1691
- qaServerMeta .Host = "localhost"
1692
- }
1684
+ qaServerMeta := types.QAServerMetadata {Host : common .Config .Host , Debug : debugMode }
1693
1685
qaServerMeta .Port , err = freeport .GetFreePort ()
1694
1686
if err != nil {
1695
1687
return fmt .Errorf ("failed to get a free port. Error: %q" , err )
@@ -1797,7 +1789,7 @@ func (fs *FileSystem) startTransformation(t *bolt.Tx, workspaceId, projectId str
1797
1789
currentRunConfigPaths = append (commonConfigPaths , currentRunConfigPaths ... )
1798
1790
}
1799
1791
// start the transformation
1800
- go fs .runTransform (currentRunDir , currentRunConfigPaths , currentRunSrcDir , currentRunCustDir , currentRunOutDir , message , qaServerMeta .Port , transformCh , workspaceId , projectId , projOutput , debugMode )
1792
+ go fs .runTransform (currentRunDir , currentRunConfigPaths , currentRunSrcDir , currentRunCustDir , currentRunOutDir , message , qaServerMeta .Port , transformCh , workspaceId , projectId , projOutput , debugMode , false )
1801
1793
logrus .Infof ("Waiting for QA engine to start for the output %s of the project %s" , projOutput .Id , projectId )
1802
1794
if err := <- transformCh ; err != nil {
1803
1795
return fmt .Errorf ("failed to start the transformation and qa engine. Error: %q" , err )
@@ -2338,13 +2330,16 @@ func (fs *FileSystem) runPlan(currentRunDir string, currentRunConfigPaths []stri
2338
2330
return err
2339
2331
}
2340
2332
2341
- func (fs * FileSystem ) runTransform (currentRunDir string , currentRunConfigPaths []string , currentRunSrcDir , currentRunCustDir , currentRunOutDir , message string , port int , transformCh chan error , workspaceId , projectId string , projOutput types.ProjectOutput , debugMode bool ) error {
2333
+ func (fs * FileSystem ) runTransform (currentRunDir string , currentRunConfigPaths []string , currentRunSrcDir , currentRunCustDir , currentRunOutDir , message string , port int , transformCh chan error , workspaceId , projectId string , projOutput types.ProjectOutput , debugMode bool , overwriteOutDir bool ) error {
2342
2334
logrus .Infof ("Starting transformation in %s with configs from %+v and source from %s , customizations from %s and output to %s" , currentRunDir , currentRunConfigPaths , currentRunSrcDir , currentRunCustDir , currentRunOutDir )
2343
2335
portStr , err := cast .ToStringE (port )
2344
2336
if err != nil {
2345
2337
return fmt .Errorf ("failed to convert the port '%d' to a string. Error: %q" , port , err )
2346
2338
}
2347
2339
cmdArgs := []string {"transform" , "--qa-disable-cli" , "--qa-port" , portStr , "--source" , currentRunSrcDir , "--output" , currentRunOutDir , "--log-file" , M2K_CLI_LOG_FILE }
2340
+ if overwriteOutDir {
2341
+ cmdArgs = append (cmdArgs , "--overwrite" )
2342
+ }
2348
2343
verbose := debugMode || isVerbose ()
2349
2344
if verbose {
2350
2345
cmdArgs = append (cmdArgs , "--log-level" , "trace" )
@@ -2541,46 +2536,6 @@ func copyOverPlanConfigAndQACache(srcDir, destDir string) error {
2541
2536
return nil
2542
2537
}
2543
2538
2544
- func getDNSHostName () string {
2545
- logrus .Trace ("getDNSHostName start" )
2546
- dnsHostName := ""
2547
- ifaces , err := net .Interfaces ()
2548
- if err != nil {
2549
- logrus .Errorf ("failed to get the interfaces. Error: %q" , err )
2550
- return ""
2551
- }
2552
- for _ , iface := range ifaces {
2553
- addrs , err := iface .Addrs ()
2554
- if err != nil {
2555
- logrus .Errorf ("failed to get the addresses for the interface %s . Error: %q" , iface .Name , err )
2556
- continue
2557
- }
2558
- for _ , addr := range addrs {
2559
- var ip net.IP
2560
- switch v := addr .(type ) {
2561
- case * net.IPNet :
2562
- ip = v .IP
2563
- case * net.IPAddr :
2564
- ip = v .IP
2565
- }
2566
- ptr , err := net .LookupAddr (ip .String ())
2567
- if err != nil {
2568
- logrus .Errorf ("failed to do a reverse lookup for the address %s . Error: %q" , addr .String (), err )
2569
- continue
2570
- }
2571
- for _ , ptrvalue := range ptr {
2572
- logrus .Debugf ("host: %s" , ptrvalue )
2573
- if len (dnsHostName ) <= len (ptrvalue ) {
2574
- dnsHostName = ptrvalue
2575
- }
2576
- }
2577
- }
2578
- }
2579
- logrus .Debugf ("dnsHostName: '%s'" , dnsHostName )
2580
- logrus .Trace ("getDNSHostName end" )
2581
- return dnsHostName
2582
- }
2583
-
2584
2539
// generateVerboseLogs synchronizes move2kube-api loggging level wrt move2kube logging level
2585
2540
func generateVerboseLogs (message string ) {
2586
2541
var loggingLevel string
0 commit comments