Skip to content

Commit b9c5b51

Browse files
Releasing version 4.39.0
Releasing version 4.39.0
2 parents 16e8284 + a09f7c9 commit b9c5b51

File tree

6 files changed

+80
-5
lines changed

6 files changed

+80
-5
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 4.39.0 (Unreleased)
2+
3+
### Added
4+
- Support for network error retry
5+
6+
### Fixed
7+
- Removed default value for `assign_private_dns_record` in `oci_core_vnic_attachment`
8+
19
## 4.38.0 (August 04, 2021)
210

311
### Added

oci/core_vnic_attachment_resource.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ func CoreVnicAttachmentResource() *schema.Resource {
4343
"assign_private_dns_record": {
4444
Type: schema.TypeBool,
4545
Optional: true,
46-
Default: true,
4746
ForceNew: true,
4847
},
4948
"assign_public_ip": {

oci/retry.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package oci
55

66
import (
7+
"log"
78
"math/rand"
89
"strings"
910
"time"
@@ -109,6 +110,12 @@ func getExpectedRetryDuration(response oci_common.OCIOperationResponse, disableN
109110

110111
func getDefaultExpectedRetryDuration(response oci_common.OCIOperationResponse, disableNotFoundRetries bool) time.Duration {
111112
defaultRetryTime := shortRetryTime
113+
114+
if oci_common.IsNetworkError(response.Error) {
115+
log.Printf("[DEBUG] Retrying for network error...")
116+
return defaultRetryTime
117+
}
118+
112119
if response.Response == nil || response.Response.HTTPResponse() == nil {
113120
return 0
114121
}
@@ -151,6 +158,10 @@ func getDefaultExpectedRetryDuration(response oci_common.OCIOperationResponse, d
151158

152159
func getIdentityExpectedRetryDuration(response oci_common.OCIOperationResponse, disableNotFoundRetries bool, optionals ...interface{}) time.Duration {
153160
defaultRetryTime := getDefaultExpectedRetryDuration(response, disableNotFoundRetries)
161+
if oci_common.IsNetworkError(response.Error) {
162+
return defaultRetryTime
163+
}
164+
154165
if response.Response == nil || response.Response.HTTPResponse() == nil {
155166
return defaultRetryTime
156167
}
@@ -173,6 +184,10 @@ func getIdentityExpectedRetryDuration(response oci_common.OCIOperationResponse,
173184

174185
func getDatabaseExpectedRetryDuration(response oci_common.OCIOperationResponse, disableNotFoundRetries bool, optionals ...interface{}) time.Duration {
175186
defaultRetryTime := getDefaultExpectedRetryDuration(response, disableNotFoundRetries)
187+
if oci_common.IsNetworkError(response.Error) {
188+
return defaultRetryTime
189+
}
190+
176191
if response.Response == nil || response.Response.HTTPResponse() == nil {
177192
return defaultRetryTime
178193
}
@@ -191,6 +206,9 @@ func getDatabaseExpectedRetryDuration(response oci_common.OCIOperationResponse,
191206

192207
func getObjectstorageServiceExpectedRetryDuration(response oci_common.OCIOperationResponse, disableNotFoundRetries bool, optionals ...interface{}) time.Duration {
193208
defaultRetryTime := getDefaultExpectedRetryDuration(response, disableNotFoundRetries)
209+
if oci_common.IsNetworkError(response.Error) {
210+
return defaultRetryTime
211+
}
194212
if response.Response == nil || response.Response.HTTPResponse() == nil {
195213
return defaultRetryTime
196214
}

oci/retry_test.go

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ package oci
55

66
import (
77
"fmt"
8+
"net"
89
"net/http"
910
"sync"
1011
"testing"
1112
"time"
1213

14+
"github.com/stretchr/testify/assert"
15+
1316
"github.com/terraform-providers/terraform-provider-oci/httpreplay"
1417

1518
"github.com/oracle/oci-go-sdk/v45/common"
@@ -45,7 +48,6 @@ func retryLoop(t *testing.T, r *retryTestInput) {
4548

4649
for i := uint(1); true; i++ {
4750
operationResponse := common.NewOCIOperationResponse(TestOCIResponse{statusCode: r.httpResponseStatusCode, header: r.header}, r.responseError, i)
48-
4951
expectedShouldRetry := getElapsedRetryDuration(startTime) < (time.Duration(r.expectedRetryTimeSeconds) * time.Second)
5052
actualShouldRetry := retryPolicy.ShouldRetryOperation(operationResponse)
5153
if actualShouldRetry != expectedShouldRetry {
@@ -78,6 +80,54 @@ func retryLoop(t *testing.T, r *retryTestInput) {
7880
}
7981
}
8082

83+
func TestNetTimeoutError(t *testing.T) {
84+
errNet := net.DNSError{
85+
Err: "Timeout",
86+
IsTimeout: true,
87+
}
88+
assert.Equal(t, common.IsNetworkError(&errNet), true)
89+
90+
if httpreplay.ModeRecordReplay() {
91+
t.Skip("Skip Retry Tests in HttpReplay mode.")
92+
}
93+
shortRetryTime = 15 * time.Second
94+
longRetryTime = 30 * time.Second
95+
configuredRetryDuration = nil
96+
r := retryTestInput{
97+
serviceName: "core",
98+
httpResponseStatusCode: 404,
99+
header: map[string][]string{},
100+
responseError: &errNet,
101+
expectedRetryTimeSeconds: 15,
102+
jitterMode: true,
103+
}
104+
retryLoop(t, &r)
105+
}
106+
107+
func TestNetTemporaryError(t *testing.T) {
108+
errNet := net.DNSError{
109+
Err: "Temporary",
110+
IsTemporary: true,
111+
}
112+
assert.Equal(t, common.IsNetworkError(&errNet), true)
113+
114+
if httpreplay.ModeRecordReplay() {
115+
t.Skip("Skip Retry Tests in HttpReplay mode.")
116+
}
117+
shortRetryTime = 15 * time.Second
118+
longRetryTime = 30 * time.Second
119+
configuredRetryDuration = nil
120+
r := retryTestInput{
121+
serviceName: "core",
122+
httpResponseStatusCode: 404,
123+
header: map[string][]string{},
124+
responseError: &errNet,
125+
expectedRetryTimeSeconds: 15,
126+
jitterMode: true,
127+
}
128+
retryLoop(t, &r)
129+
}
130+
81131
// Test a simple retry loop, simulating a 429 rate error
82132
// issue-routing-tag: terraform/default
83133
func TestUnitRetryLoop_basic(t *testing.T) {

oci/version.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"log"
88
)
99

10-
const Version = "4.38.0"
11-
const ReleaseDate = "2021-08-04"
10+
const Version = "4.39.0"
11+
const ReleaseDate = "2021-08-11"
1212

1313
func PrintVersion() {
1414
log.Printf("[INFO] terraform-provider-oci %s\n", Version)

website/docs/r/core_vnic_attachment.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ resource "oci_core_vnic_attachment" "test_vnic_attachment" {
4848
The following arguments are supported:
4949

5050
* `create_vnic_details` - (Required) (Updatable) Contains properties for a VNIC. You use this object when creating the primary VNIC during instance launch or when creating a secondary VNIC. For more information about VNICs, see [Virtual Network Interface Cards (VNICs)](https://docs.cloud.oracle.com/iaas/Content/Network/Tasks/managingVNICs.htm).
51-
* `assign_private_dns_record` - (Optional) Whether the VNIC should be assigned a DNS record. If set to false, no DNS record registion for the VNIC; if set to true, DNS record will be registered. The default value is true. Example: `true`
51+
* `assign_private_dns_record` - (Optional) Whether the VNIC should be assigned a DNS record. If set to false, no DNS record registion for the VNIC; if set to true, DNS record will be registered. Example: `true`
5252

5353
If you specify a `hostnameLabel`, the `assignPrivateDnsRecord` is require to be set to true.
5454
* `assign_public_ip` - (Optional) Whether the VNIC should be assigned a public IP address. Defaults to whether the subnet is public or private. If not set and the VNIC is being created in a private subnet (that is, where `prohibitPublicIpOnVnic` = true in the [Subnet](https://docs.cloud.oracle.com/iaas/api/#/en/iaas/latest/Subnet/)), then no public IP address is assigned. If not set and the subnet is public (`prohibitPublicIpOnVnic` = false), then a public IP address is assigned. If set to true and `prohibitPublicIpOnVnic` = true, an error is returned.

0 commit comments

Comments
 (0)