@@ -44,6 +44,7 @@ type IsoNetworkIface interface {
44
44
func (c * client ) getOfferingID () (string , error ) {
45
45
offeringID , count , retErr := c .cs .NetworkOffering .GetNetworkOfferingID (NetOffering )
46
46
if retErr != nil {
47
+ c .customMetrics .EvaluateErrorAndIncrementAcsReconciliationErrorCounter (retErr )
47
48
return "" , retErr
48
49
} else if count != 1 {
49
50
return "" , errors .New ("found more than one network offering" )
@@ -60,7 +61,6 @@ func (c *client) AssociatePublicIPAddress(
60
61
// Check specified IP address is available or get an unused one if not specified.
61
62
publicAddress , err := c .GetPublicIP (zone , isoNet , csCluster )
62
63
if err != nil {
63
- c .customMetrics .IncrementAcsReconciliationErrors (err )
64
64
return errors .Wrapf (err , "fetching a public IP address" )
65
65
}
66
66
isoNet .Spec .ControlPlaneEndpoint .Host = publicAddress .Ipaddress
@@ -77,6 +77,7 @@ func (c *client) AssociatePublicIPAddress(
77
77
p .SetIpaddress (isoNet .Spec .ControlPlaneEndpoint .Host )
78
78
p .SetNetworkid (isoNet .Spec .ID )
79
79
if _ , err := c .cs .Address .AssociateIpAddress (p ); err != nil {
80
+ c .customMetrics .EvaluateErrorAndIncrementAcsReconciliationErrorCounter (err )
80
81
return errors .Wrapf (err ,
81
82
"associating public IP address with ID %s to network with ID %s" ,
82
83
publicAddress .Id , isoNet .Spec .ID )
@@ -102,6 +103,7 @@ func (c *client) CreateIsolatedNetwork(zone *capcv1.CloudStackZone, isoNet *capc
102
103
p := c .cs .Network .NewCreateNetworkParams (isoNet .Spec .Name , isoNet .Spec .Name , offeringID , zone .Spec .ID )
103
104
resp , err := c .cs .Network .CreateNetwork (p )
104
105
if err != nil {
106
+ c .customMetrics .EvaluateErrorAndIncrementAcsReconciliationErrorCounter (err )
105
107
return errors .Wrapf (err , "creating network with name %s" , isoNet .Spec .Name )
106
108
}
107
109
isoNet .Spec .ID = resp .Id
@@ -115,6 +117,7 @@ func (c *client) OpenFirewallRules(isoNet *capcv1.CloudStackIsolatedNetwork) (re
115
117
if retErr != nil && strings .Contains (strings .ToLower (retErr .Error ()), "there is already" ) { // Already a firewall rule here.
116
118
retErr = nil
117
119
}
120
+ c .customMetrics .EvaluateErrorAndIncrementAcsReconciliationErrorCounter (retErr )
118
121
return retErr
119
122
}
120
123
@@ -132,6 +135,7 @@ func (c *client) GetPublicIP(
132
135
setIfNotEmpty (ip , p .SetIpaddress )
133
136
publicAddresses , err := c .cs .Address .ListPublicIpAddresses (p )
134
137
if err != nil {
138
+ c .customMetrics .EvaluateErrorAndIncrementAcsReconciliationErrorCounter (err )
135
139
return nil , err
136
140
} else if ip != "" && publicAddresses .Count == 1 { // Endpoint specified and IP found.
137
141
// Ignore already allocated here since the IP was specified.
@@ -157,6 +161,7 @@ func (c *client) GetPublicIP(
157
161
func (c * client ) GetIsolatedNetwork (isoNet * capcv1.CloudStackIsolatedNetwork ) (retErr error ) {
158
162
netDetails , count , err := c .cs .Network .GetNetworkByName (isoNet .Spec .Name )
159
163
if err != nil {
164
+ c .customMetrics .EvaluateErrorAndIncrementAcsReconciliationErrorCounter (err )
160
165
retErr = multierror .Append (retErr , errors .Wrapf (err , "could not get Network ID from %s" , isoNet .Spec .Name ))
161
166
} else if count != 1 {
162
167
retErr = multierror .Append (retErr , errors .Errorf (
@@ -168,6 +173,7 @@ func (c *client) GetIsolatedNetwork(isoNet *capcv1.CloudStackIsolatedNetwork) (r
168
173
169
174
netDetails , count , err = c .cs .Network .GetNetworkByID (isoNet .Spec .ID )
170
175
if err != nil {
176
+ c .customMetrics .EvaluateErrorAndIncrementAcsReconciliationErrorCounter (err )
171
177
return multierror .Append (retErr , errors .Wrapf (err , "could not get Network by ID %s" , isoNet .Spec .ID ))
172
178
} else if count != 1 {
173
179
return multierror .Append (retErr , errors .Errorf ("expected 1 Network with UUID %s, but got %d" , isoNet .Spec .ID , count ))
@@ -186,6 +192,7 @@ func (c *client) ResolveLoadBalancerRuleDetails(
186
192
p .SetPublicipid (isoNet .Status .PublicIPID )
187
193
loadBalancerRules , err := c .cs .LoadBalancer .ListLoadBalancerRules (p )
188
194
if err != nil {
195
+ c .customMetrics .EvaluateErrorAndIncrementAcsReconciliationErrorCounter (err )
189
196
return errors .Wrap (err , "listing load balancer rules" )
190
197
}
191
198
for _ , rule := range loadBalancerRules .LoadBalancerRules {
@@ -230,6 +237,7 @@ func (c *client) GetOrCreateLoadBalancerRule(
230
237
p .SetProtocol (NetworkProtocolTCP )
231
238
resp , err := c .cs .LoadBalancer .CreateLoadBalancerRule (p )
232
239
if err != nil {
240
+ c .customMetrics .EvaluateErrorAndIncrementAcsReconciliationErrorCounter (err )
233
241
return err
234
242
}
235
243
isoNet .Status .LBRuleID = resp .Id
@@ -279,6 +287,7 @@ func (c *client) AssignVMToLoadBalancerRule(isoNet *capcv1.CloudStackIsolatedNet
279
287
lbRuleInstances , retErr := c .cs .LoadBalancer .ListLoadBalancerRuleInstances (
280
288
c .cs .LoadBalancer .NewListLoadBalancerRuleInstancesParams (isoNet .Status .LBRuleID ))
281
289
if retErr != nil {
290
+ c .customMetrics .EvaluateErrorAndIncrementAcsReconciliationErrorCounter (retErr )
282
291
return retErr
283
292
}
284
293
for _ , instance := range lbRuleInstances .LoadBalancerRuleInstances {
@@ -291,12 +300,14 @@ func (c *client) AssignVMToLoadBalancerRule(isoNet *capcv1.CloudStackIsolatedNet
291
300
p := c .cs .LoadBalancer .NewAssignToLoadBalancerRuleParams (isoNet .Status .LBRuleID )
292
301
p .SetVirtualmachineids ([]string {instanceID })
293
302
_ , retErr = c .cs .LoadBalancer .AssignToLoadBalancerRule (p )
303
+ c .customMetrics .EvaluateErrorAndIncrementAcsReconciliationErrorCounter (retErr )
294
304
return retErr
295
305
}
296
306
297
307
// DeleteNetwork deletes an isolated network.
298
308
func (c * client ) DeleteNetwork (net capcv1.Network ) error {
299
309
_ , err := c .cs .Network .DeleteNetwork (c .cs .Network .NewDeleteNetworkParams (net .ID ))
310
+ c .customMetrics .EvaluateErrorAndIncrementAcsReconciliationErrorCounter (err )
300
311
return errors .Wrapf (err , "deleting network with id %s" , net .ID )
301
312
}
302
313
@@ -351,6 +362,7 @@ func (c *client) DisassociatePublicIPAddressIfNotInUse(isoNet *capcv1.CloudStack
351
362
if tagsAllowDisposal , err := c .DoClusterTagsAllowDisposal (ResourceTypeIPAddress , isoNet .Status .PublicIPID ); err != nil {
352
363
return err
353
364
} else if publicIP , _ , err := c .cs .Address .GetPublicIpAddressByID (isoNet .Status .PublicIPID ); err != nil {
365
+ c .customMetrics .EvaluateErrorAndIncrementAcsReconciliationErrorCounter (err )
354
366
return err
355
367
} else if publicIP == nil || publicIP .Issourcenat { // Can't disassociate an address if it's the source NAT address.
356
368
return nil
@@ -370,5 +382,6 @@ func (c *client) DisassociatePublicIPAddress(isoNet *capcv1.CloudStackIsolatedNe
370
382
371
383
p := c .cs .Address .NewDisassociateIpAddressParams (isoNet .Status .PublicIPID )
372
384
_ , retErr = c .cs .Address .DisassociateIpAddress (p )
385
+ c .customMetrics .EvaluateErrorAndIncrementAcsReconciliationErrorCounter (retErr )
373
386
return retErr
374
387
}
0 commit comments