@@ -15,6 +15,7 @@ import (
15
15
const (
16
16
defaultK8SClusterTimeout = 15 * time .Minute
17
17
defaultK8SPoolTimeout = 15 * time .Minute
18
+ defaultK8SRetryInterval = 5 * time .Second
18
19
)
19
20
20
21
func k8sAPIWithRegion (d * schema.ResourceData , m interface {}) (* k8s.API , scw.Region , error ) {
@@ -75,30 +76,48 @@ func k8sGetLatestVersionFromMinor(ctx context.Context, k8sAPI *k8s.API, region s
75
76
}
76
77
77
78
func waitK8SCluster (ctx context.Context , k8sAPI * k8s.API , region scw.Region , clusterID string , timeout time.Duration ) (* k8s.Cluster , error ) {
78
- return k8sAPI .WaitForCluster (& k8s.WaitForClusterRequest {
79
+ retryInterval := defaultK8SRetryInterval
80
+ if DefaultWaitRetryInterval != nil {
81
+ retryInterval = * DefaultWaitRetryInterval
82
+ }
83
+
84
+ cluster , err := k8sAPI .WaitForCluster (& k8s.WaitForClusterRequest {
79
85
ClusterID : clusterID ,
80
86
Region : region ,
81
87
Timeout : scw .TimeDurationPtr (timeout ),
82
- RetryInterval : DefaultWaitRetryInterval ,
88
+ RetryInterval : & retryInterval ,
83
89
}, scw .WithContext (ctx ))
90
+
91
+ return cluster , err
84
92
}
85
93
86
94
func waitK8SClusterPool (ctx context.Context , k8sAPI * k8s.API , region scw.Region , clusterID string , timeout time.Duration ) (* k8s.Cluster , error ) {
95
+ retryInterval := defaultK8SRetryInterval
96
+ if DefaultWaitRetryInterval != nil {
97
+ retryInterval = * DefaultWaitRetryInterval
98
+ }
99
+
87
100
return k8sAPI .WaitForClusterPool (& k8s.WaitForClusterRequest {
88
101
ClusterID : clusterID ,
89
102
Region : region ,
90
103
Timeout : scw .TimeDurationPtr (timeout ),
91
- RetryInterval : DefaultWaitRetryInterval ,
104
+ RetryInterval : & retryInterval ,
92
105
}, scw .WithContext (ctx ))
93
106
}
94
107
95
108
func waitK8SClusterDeleted (ctx context.Context , k8sAPI * k8s.API , region scw.Region , clusterID string , timeout time.Duration ) error {
109
+ retryInterval := defaultK8SRetryInterval
110
+ if DefaultWaitRetryInterval != nil {
111
+ retryInterval = * DefaultWaitRetryInterval
112
+ }
113
+
96
114
cluster , err := k8sAPI .WaitForCluster (& k8s.WaitForClusterRequest {
97
115
ClusterID : clusterID ,
98
116
Region : region ,
99
117
Timeout : scw .TimeDurationPtr (timeout ),
100
- RetryInterval : DefaultWaitRetryInterval ,
118
+ RetryInterval : & retryInterval ,
101
119
}, scw .WithContext (ctx ))
120
+
102
121
if err != nil {
103
122
if is404Error (err ) {
104
123
return nil
@@ -109,22 +128,27 @@ func waitK8SClusterDeleted(ctx context.Context, k8sAPI *k8s.API, region scw.Regi
109
128
return fmt .Errorf ("cluster %s has state %s, wants %s" , clusterID , cluster .Status , k8s .ClusterStatusDeleted )
110
129
}
111
130
112
- func waitK8SPoolReady (ctx context.Context , k8sAPI * k8s.API , region scw.Region , poolID string , timeout time.Duration ) error {
131
+ func waitK8SPoolReady (ctx context.Context , k8sAPI * k8s.API , region scw.Region , poolID string , timeout time.Duration ) (* k8s.Pool , error ) {
132
+ retryInterval := defaultK8SRetryInterval
133
+ if DefaultWaitRetryInterval != nil {
134
+ retryInterval = * DefaultWaitRetryInterval
135
+ }
136
+
113
137
pool , err := k8sAPI .WaitForPool (& k8s.WaitForPoolRequest {
114
138
PoolID : poolID ,
115
139
Region : region ,
116
140
Timeout : scw .TimeDurationPtr (timeout ),
117
- RetryInterval : DefaultWaitRetryInterval ,
141
+ RetryInterval : & retryInterval ,
118
142
}, scw .WithContext (ctx ))
119
143
120
144
if err != nil {
121
- return err
145
+ return nil , err
122
146
}
123
147
124
148
if pool .Status != k8s .PoolStatusReady {
125
- return fmt .Errorf ("pool %s has state %s, wants %s" , poolID , pool .Status , k8s .PoolStatusReady )
149
+ return nil , fmt .Errorf ("pool %s has state %s, wants %s" , poolID , pool .Status , k8s .PoolStatusReady )
126
150
}
127
- return nil
151
+ return pool , nil
128
152
}
129
153
130
154
// convert a list of nodes to a list of map
0 commit comments