Skip to content

Commit 76d1f1f

Browse files
author
Chanwit Kaewkasi
authored
Merge pull request #494 from siiimooon/feature/enable-tf-parallelism
feat: enable parallelism option for TF apply stage
2 parents 3945ee9 + 5c109b7 commit 76d1f1f

8 files changed

Lines changed: 350 additions & 246 deletions

File tree

api/v1alpha1/terraform_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ type TerraformSpec struct {
212212
// +optional
213213
Targets []string `json:"targets,omitempty"`
214214

215+
// Parallelism limits the number of concurrent operations of Terraform apply step. Zero (0) means using the default value.
216+
// +kubebuilder:default:=0
217+
// +optional
218+
Parallelism int32 `json:"parallelism,omitempty"`
219+
215220
// StoreReadablePlan enables storing the plan in a readable format.
216221
// +kubebuilder:validation:Enum=none;json;human
217222
// +kubebuilder:default:=none

config/crd/bases/infra.contrib.fluxcd.io_terraforms.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ spec:
244244
interval:
245245
description: The interval at which to reconcile the Terraform.
246246
type: string
247+
parallelism:
248+
default: 0
249+
description: Parallelism limits the number of concurrent operations
250+
of Terraform apply step. Zero (0) means using the default value.
251+
format: int32
252+
type: integer
247253
path:
248254
description: Path to the directory containing Terraform (.tf) files.
249255
Defaults to 'None', which translates to the root path of the SourceRef.

config/crd/bases/ocirepositories.yaml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,14 @@ spec:
301301
type: object
302302
type: array
303303
contentConfigChecksum:
304-
description: 'ContentConfigChecksum is a checksum of all the configurations
304+
description: "ContentConfigChecksum is a checksum of all the configurations
305305
related to the content of the source artifact: - .spec.ignore -
306306
.spec.layerSelector observed in .status.observedGeneration version
307307
of the object. This can be used to determine if the content configuration
308308
has changed and the artifact needs to be rebuilt. It has the format
309-
of `<algo>:<checksum>`, for example: `sha256:<checksum>`.'
309+
of `<algo>:<checksum>`, for example: `sha256:<checksum>`. \n Deprecated:
310+
Replaced with explicit fields for observed artifact content config
311+
in the status."
310312
type: string
311313
lastHandledReconcileAt:
312314
description: LastHandledReconcileAt holds the value of the most recent
@@ -317,6 +319,29 @@ spec:
317319
description: ObservedGeneration is the last observed generation.
318320
format: int64
319321
type: integer
322+
observedIgnore:
323+
description: ObservedIgnore is the observed exclusion patterns used
324+
for constructing the source artifact.
325+
type: string
326+
observedLayerSelector:
327+
description: ObservedLayerSelector is the observed layer selector
328+
used for constructing the source artifact.
329+
properties:
330+
mediaType:
331+
description: MediaType specifies the OCI media type of the layer
332+
which should be extracted from the OCI Artifact. The first layer
333+
matching this type is selected.
334+
type: string
335+
operation:
336+
description: Operation specifies how the selected layer should
337+
be processed. By default, the layer compressed content is extracted
338+
to storage. When the operation is set to 'copy', the layer compressed
339+
content is persisted to storage as it is.
340+
enum:
341+
- extract
342+
- copy
343+
type: string
344+
type: object
320345
url:
321346
description: URL is the download link for the artifact output of the
322347
last OCI Repository sync.

controllers/tf_controller_apply.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func (r *TerraformReconciler) apply(ctx context.Context, terraform infrav1.Terra
7676

7777
applyRequest := &runner.ApplyRequest{
7878
TfInstance: tfInstance,
79+
Parallelism: terraform.Spec.Parallelism,
7980
RefreshBeforeApply: terraform.Spec.RefreshBeforeApply,
8081
Targets: terraform.Spec.Targets,
8182
}

docs/References/terraform.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,18 @@ TFStateSpec
14781478
</tr>
14791479
<tr>
14801480
<td>
1481+
<code>parallelism</code><br>
1482+
<em>
1483+
int32
1484+
</em>
1485+
</td>
1486+
<td>
1487+
<em>(Optional)</em>
1488+
<p>Parallelism limits the number of concurrent operations of Terraform apply step.</p>
1489+
</td>
1490+
</tr>
1491+
<tr>
1492+
<td>
14811493
<code>storeReadablePlan</code><br>
14821494
<em>
14831495
string
@@ -1514,6 +1526,20 @@ string
15141526
<em>(Optional)</em>
15151527
</td>
15161528
</tr>
1529+
<tr>
1530+
<td>
1531+
<code>enterprise</code><br>
1532+
<em>
1533+
<a href="https://pkg.go.dev/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1?tab=doc#JSON">
1534+
Kubernetes pkg/apis/apiextensions/v1.JSON
1535+
</a>
1536+
</em>
1537+
</td>
1538+
<td>
1539+
<em>(Optional)</em>
1540+
<p>Enterprise is the enterprise configuration placeholder.</p>
1541+
</td>
1542+
</tr>
15171543
</table>
15181544
</td>
15191545
</tr>
@@ -1936,6 +1962,18 @@ TFStateSpec
19361962
</tr>
19371963
<tr>
19381964
<td>
1965+
<code>parallelism</code><br>
1966+
<em>
1967+
int32
1968+
</em>
1969+
</td>
1970+
<td>
1971+
<em>(Optional)</em>
1972+
<p>Parallelism limits the number of concurrent operations of Terraform apply step.</p>
1973+
</td>
1974+
</tr>
1975+
<tr>
1976+
<td>
19391977
<code>storeReadablePlan</code><br>
19401978
<em>
19411979
string
@@ -1972,6 +2010,20 @@ string
19722010
<em>(Optional)</em>
19732011
</td>
19742012
</tr>
2013+
<tr>
2014+
<td>
2015+
<code>enterprise</code><br>
2016+
<em>
2017+
<a href="https://pkg.go.dev/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1?tab=doc#JSON">
2018+
Kubernetes pkg/apis/apiextensions/v1.JSON
2019+
</a>
2020+
</em>
2021+
</td>
2022+
<td>
2023+
<em>(Optional)</em>
2024+
<p>Enterprise is the enterprise configuration placeholder.</p>
2025+
</td>
2026+
</tr>
19752027
</tbody>
19762028
</table>
19772029
</div>

0 commit comments

Comments
 (0)