Skip to content

Commit

Permalink
Fix: Added Sleep/Retry on Forward Control Rule resource (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
willguibr authored Oct 5, 2024
1 parent 4b99400 commit 45a003a
Show file tree
Hide file tree
Showing 9 changed files with 225 additions and 147 deletions.
266 changes: 133 additions & 133 deletions .github/workflows/zia-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,152 +18,85 @@ on:
workflow_dispatch:

jobs:
zia-zsbeta-tests:
environment: ZIA_ZSBETA
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
goVersion: ["1.21"]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.goVersion }}

- name: Set Go env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup Go Tools
run: make tools

- name: Download Go Dependencies
run: |
go mod tidy && go mod vendor
- name: Setup Go Tools
run: make tools

- name: Check Formatting
run: make fmtcheck

# - name: Vet Code
# run: make vet

- name: Lint Code
run: make lint

- name: Check Build
run: make build

- name: Run tests with retry
uses: nick-fields/retry@v3
with:
max_attempts: 3
timeout_minutes: 120
command: |
make sweep
make test:integration:zia
make sweep
env:
ZIA_USERNAME: ${{ secrets.ZIA_USERNAME }}
ZIA_PASSWORD: ${{ secrets.ZIA_PASSWORD }}
ZIA_API_KEY: ${{ secrets.ZIA_API_KEY }}
ZIA_CLOUD: ${{ secrets.ZIA_CLOUD }}
ZIA_SANDBOX_TOKEN: ${{ secrets.ZIA_SANDBOX_TOKEN }}
ZPA_CLIENT_ID: ${{ secrets.ZPA_CLIENT_ID }}
ZPA_CLIENT_SECRET: ${{ secrets.ZPA_CLIENT_SECRET }}
ZPA_CUSTOMER_ID: ${{ secrets.ZPA_CUSTOMER_ID }}
ZPA_CLOUD: ${{ secrets.ZPA_CLOUD }}
TF_ACC: ${{ secrets.TF_ACC }}
ZIA_ACC_TEST_FORCE_SWEEPERS: ${{ secrets.ZIA_ACC_TEST_FORCE_SWEEPERS }}
# zia-zsbeta-tests:
# environment: ZIA_ZSBETA
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# goVersion: ["1.21"]
# steps:
# - name: Checkout code
# uses: actions/checkout@v4

zia-test-tenants:
needs: [zia-zsbeta-tests]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
goVersion: ["1.21"]
environment:
# - ZIA_ZSCLOUD
- ZIA_ZS0
# - ZIA_ZS1
# - ZIA_ZS2
# - ZIA_ZS3
environment: ${{ matrix.environment }}
steps:
- name: Checkout code
uses: actions/checkout@v4
# - name: Setup Go
# uses: actions/setup-go@v5
# with:
# go-version: ${{ matrix.goVersion }}

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.goVersion }}
# - name: Set Go env
# run: |
# echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
# echo "$(go env GOPATH)/bin" >> $GITHUB_PATH

- name: Set Go env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
# - name: Setup Go Tools
# run: make tools

- name: Setup Go Tools
run: make tools
# - name: Download Go Dependencies
# run: |
# go mod tidy && go mod vendor

- name: Download Go Dependencies
run: |
go mod tidy && go mod vendor
# - name: Setup Go Tools
# run: make tools

- name: Setup Go Tools
run: make tools
# - name: Check Formatting
# run: make fmtcheck

- name: Check Formatting
run: make fmtcheck
# # - name: Vet Code
# # run: make vet

# - name: Vet Code
# run: make vet
# - name: Lint Code
# run: make lint

- name: Lint Code
run: make lint
# - name: Check Build
# run: make build

- name: Check Build
run: make build
# - name: Run tests with retry
# uses: nick-fields/retry@v3
# with:
# max_attempts: 3
# timeout_minutes: 120
# command: |
# make sweep
# make test:integration:zia
# make sweep

- name: Run tests with retry on Ubuntu
uses: nick-fields/retry@v3
with:
max_attempts: 3
timeout_minutes: 120
command: |
make sweep
make test:integration:zscalerone
make sweep
env:
ZIA_USERNAME: ${{ secrets.ZIA_USERNAME }}
ZIA_PASSWORD: ${{ secrets.ZIA_PASSWORD }}
ZIA_API_KEY: ${{ secrets.ZIA_API_KEY }}
ZIA_CLOUD: ${{ secrets.ZIA_CLOUD }}
ZIA_SANDBOX_TOKEN: ${{ secrets.ZIA_SANDBOX_TOKEN }}
ZPA_CLIENT_ID: ${{ secrets.ZPA_CLIENT_ID }}
ZPA_CLIENT_SECRET: ${{ secrets.ZPA_CLIENT_SECRET }}
ZPA_CUSTOMER_ID: ${{ secrets.ZPA_CUSTOMER_ID }}
ZPA_CLOUD: ${{ secrets.ZPA_CLOUD }}
TF_ACC: ${{ secrets.TF_ACC }}
ZIA_ACC_TEST_FORCE_SWEEPERS: ${{ secrets.ZIA_ACC_TEST_FORCE_SWEEPERS }}
# env:
# ZIA_USERNAME: ${{ secrets.ZIA_USERNAME }}
# ZIA_PASSWORD: ${{ secrets.ZIA_PASSWORD }}
# ZIA_API_KEY: ${{ secrets.ZIA_API_KEY }}
# ZIA_CLOUD: ${{ secrets.ZIA_CLOUD }}
# ZIA_SANDBOX_TOKEN: ${{ secrets.ZIA_SANDBOX_TOKEN }}
# ZPA_CLIENT_ID: ${{ secrets.ZPA_CLIENT_ID }}
# ZPA_CLIENT_SECRET: ${{ secrets.ZPA_CLIENT_SECRET }}
# ZPA_CUSTOMER_ID: ${{ secrets.ZPA_CUSTOMER_ID }}
# ZPA_CLOUD: ${{ secrets.ZPA_CLOUD }}
# TF_ACC: ${{ secrets.TF_ACC }}
# ZIA_ACC_TEST_FORCE_SWEEPERS: ${{ secrets.ZIA_ACC_TEST_FORCE_SWEEPERS }}

# zia-zscalerone-test:
# zia-test-tenants:
# needs: [zia-zsbeta-tests]
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# goVersion: ["1.21"]
# environment:
# - ZIA_ZS1
# # - ZIA_ZSCLOUD
# - ZIA_ZS0
# # - ZIA_ZS1
# # - ZIA_ZS2
# # - ZIA_ZS3
# environment: ${{ matrix.environment }}
# steps:
# - name: Checkout code
Expand Down Expand Up @@ -205,7 +138,7 @@ jobs:
# uses: nick-fields/retry@v3
# with:
# max_attempts: 3
# timeout_minutes: 45 # Adjust as needed
# timeout_minutes: 120
# command: |
# make sweep
# make test:integration:zscalerone
Expand All @@ -223,14 +156,14 @@ jobs:
# TF_ACC: ${{ secrets.TF_ACC }}
# ZIA_ACC_TEST_FORCE_SWEEPERS: ${{ secrets.ZIA_ACC_TEST_FORCE_SWEEPERS }}

# zia-zscalertwo-test:
# zia-zscalerone-test:
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# goVersion: ["1.21"]
# environment:
# - ZIA_ZS2
# - ZIA_ZS1
# environment: ${{ matrix.environment }}
# steps:
# - name: Checkout code
Expand Down Expand Up @@ -272,10 +205,10 @@ jobs:
# uses: nick-fields/retry@v3
# with:
# max_attempts: 3
# timeout_minutes: 120
# timeout_minutes: 45 # Adjust as needed
# command: |
# make sweep
# make test:integration:zia
# make test:integration:zscalerone
# make sweep
# env:
# ZIA_USERNAME: ${{ secrets.ZIA_USERNAME }}
Expand All @@ -290,6 +223,73 @@ jobs:
# TF_ACC: ${{ secrets.TF_ACC }}
# ZIA_ACC_TEST_FORCE_SWEEPERS: ${{ secrets.ZIA_ACC_TEST_FORCE_SWEEPERS }}

zia-zscalertwo-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
goVersion: ["1.21"]
environment:
- ZIA_ZS2
environment: ${{ matrix.environment }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.goVersion }}

- name: Set Go env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup Go Tools
run: make tools

- name: Download Go Dependencies
run: |
go mod tidy && go mod vendor
- name: Setup Go Tools
run: make tools

- name: Check Formatting
run: make fmtcheck

# - name: Vet Code
# run: make vet

- name: Lint Code
run: make lint

- name: Check Build
run: make build

- name: Run tests with retry on Ubuntu
uses: nick-fields/retry@v3
with:
max_attempts: 3
timeout_minutes: 120
command: |
make sweep
make test:integration:zia
make sweep
env:
ZIA_USERNAME: ${{ secrets.ZIA_USERNAME }}
ZIA_PASSWORD: ${{ secrets.ZIA_PASSWORD }}
ZIA_API_KEY: ${{ secrets.ZIA_API_KEY }}
ZIA_CLOUD: ${{ secrets.ZIA_CLOUD }}
ZIA_SANDBOX_TOKEN: ${{ secrets.ZIA_SANDBOX_TOKEN }}
ZPA_CLIENT_ID: ${{ secrets.ZPA_CLIENT_ID }}
ZPA_CLIENT_SECRET: ${{ secrets.ZPA_CLIENT_SECRET }}
ZPA_CUSTOMER_ID: ${{ secrets.ZPA_CUSTOMER_ID }}
ZPA_CLOUD: ${{ secrets.ZPA_CLOUD }}
TF_ACC: ${{ secrets.TF_ACC }}
ZIA_ACC_TEST_FORCE_SWEEPERS: ${{ secrets.ZIA_ACC_TEST_FORCE_SWEEPERS }}

- name: Publish test coverage
uses: codecov/codecov-action@v4
with:
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 3.0.5 (October, 4 2024)

### Notes

- Release date: **(October, 4 2024)**
- Supported Terraform version: **v1.x**

### Bug Fixes

- [PR #373](https://github.com/zscaler/terraform-provider-zia/pull/373) - The resource `zia_forwarding_control_rule` now pauses for 60 seconds before proceeding with the create or update process whenever the `forward_method` attribute is set to `ZPA`. In case of a failure related to resource synchronization, the provider will retry the resource creation or update up to 3 times, waiting 30 seconds between each retry. This behavior ensures that ZIA and ZPA have sufficient time to synchronize and replicate the necessary resource IDs, reducing the risk of transient errors during provisioning.
**NOTE** This retry mechanism helps to automatically overcome temporary latency without manual intervention. This behavior does not affect forwarding rules configured with other forward_methods such as `DIRECT`.

## 3.0.4 (September, 6 2024)

### Notes
Expand Down
6 changes: 3 additions & 3 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,14 @@ test\:integration\:zscalertwo:
build13: GOOS=$(shell go env GOOS)
build13: GOARCH=$(shell go env GOARCH)
ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
build13: DESTINATION=$(APPDATA)/terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/3.0.4/$(GOOS)_$(GOARCH)
build13: DESTINATION=$(APPDATA)/terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/3.0.5/$(GOOS)_$(GOARCH)
else
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/3.0.4/$(GOOS)_$(GOARCH)
build13: DESTINATION=$(HOME)/.terraform.d/plugins/$(ZIA_PROVIDER_NAMESPACE)/3.0.5/$(GOOS)_$(GOARCH)
endif
build13: fmtcheck
@echo "==> Installing plugin to $(DESTINATION)"
@mkdir -p $(DESTINATION)
go build -o $(DESTINATION)/terraform-provider-zia_v3.0.4
go build -o $(DESTINATION)/terraform-provider-zia_v3.0.5

coverage: test
@echo "✓ Opening coverage for unit tests ..."
Expand Down
14 changes: 13 additions & 1 deletion docs/guides/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,22 @@ description: |-
Track all ZIA Terraform provider's releases. New resources, features, and bug fixes will be tracked here.

---
``Last updated: v3.0.4``
``Last updated: v3.0.5``

---

## 3.0.5 (October, 4 2024)

### Notes

- Release date: **(October, 4 2024)**
- Supported Terraform version: **v1.x**

### Bug Fixes

- [PR #373](https://github.com/zscaler/terraform-provider-zia/pull/373) - The resource `zia_forwarding_control_rule` now pauses for 60 seconds before proceeding with the create or update process whenever the `forward_method` attribute is set to `ZPA`. In case of a failure related to resource synchronization, the provider will retry the resource creation or update up to 3 times, waiting 30 seconds between each retry. This behavior ensures that ZIA and ZPA have sufficient time to synchronize and replicate the necessary resource IDs, reducing the risk of transient errors during provisioning.
**NOTE** This retry mechanism helps to automatically overcome temporary latency without manual intervention. This behavior does not affect forwarding rules configured with other forward_methods such as `DIRECT`.

## 3.0.4 (September, 6 2024)

### Notes
Expand Down
5 changes: 5 additions & 0 deletions docs/resources/zia_forwarding_control_rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ description: |-

The **zia_forwarding_control_rule** resource allows the creation and management of ZIA Forwarding Control rules in the Zscaler Internet Access.

⚠️ **WARNING:** - [PR #373](https://github.com/zscaler/terraform-provider-zia/pull/373) - The resource `zia_forwarding_control_rule` now pauses for 60 seconds before proceeding with the create or update process whenever the `forward_method` attribute is set to `ZPA`. In case of a failure related to resource synchronization, the provider will retry the resource creation or update up to 3 times, waiting 30 seconds between each retry. This behavior ensures that ZIA and ZPA have sufficient time to synchronize and replicate the necessary resource IDs, reducing the risk of transient errors during provisioning.

**NOTE**: This retry mechanism helps to automatically overcome temporary latency without manual intervention. This behavior does not affect forwarding rules configured with other forward_methods such as `DIRECT`.


## Example Usage - DIRECT Forwarding Method

```hcl
Expand Down
Loading

0 comments on commit 45a003a

Please sign in to comment.