Skip to content

Commit c8032a3

Browse files
Giridharan AnbarasanMaxrovr
authored andcommitted
Added - Max Parallel Chunks configurable via env
1 parent c51b1bf commit c8032a3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

internal/resourcediscovery/export_compartment.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"runtime"
1414
"runtime/debug"
1515
"sort"
16+
"strconv"
1617
"strings"
1718
"sync"
1819
"time"
@@ -300,7 +301,13 @@ func RunExportCommand(args *tf_export.ExportCommandArgs) (err error, status Stat
300301
numCPU := runtime.NumCPU()
301302
MaxParallelFindResource = numCPU * 4
302303
// max parallel chunks for state genation that can be executed in parallel
303-
MaxParallelChunks = numCPU * 4
304+
MaxParallelChunks = numCPU * 2 // default value
305+
if env := os.Getenv("TF_MAX_PARALLEL_CHUNKS"); env != "" {
306+
if value, err := strconv.Atoi(env); err == nil && value > 0 {
307+
MaxParallelChunks = value
308+
utils.Debugf("[INFO] Found ENV Variable TF_MAX_PARALLEL_CHUNKS. Value - %d", MaxParallelChunks)
309+
}
310+
}
304311
utils.Debugf("[INFO] Setting MaxParalleFindResources=%d, MaxParallelChunks=%d", MaxParallelFindResource, MaxParallelChunks)
305312

306313
ctx, err := createResourceDiscoveryContext(clients.(*tf_client.OracleClients), args, tenancyOcid)

website/docs/guides/resource_discovery.html.markdown

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@ Make sure the `output_path` is empty before running resource discovery
248248
* The compartment export functionality currently supports discovery of the target compartment. The ability to discover resources in child compartments is not yet supported.
249249
* If using Instance Principals, resources can not be discovered if compartment_id is not specified
250250

251+
252+
You can specify the maximum number of parallel chunks used for importing resources by setting the following environment variable. By default, it is set to twice the number of CPU cores.
253+
254+
```
255+
export TF_MAX_PARALLEL_CHUNKS=<Positive Integer>
256+
```
257+
251258
### Exit status
252259

253260
While discovering resources if there is any error related to the APIs or service unavailability, the tool will move on to find next resource. All the errors encountered will be displayed after the discovery is complete.

0 commit comments

Comments
 (0)