Skip to content

Commit 69ccfae

Browse files
committed
update status if hash mismatch but id not nil
1 parent 744cd8b commit 69ccfae

15 files changed

+104
-63
lines changed

api/v1/iprangeclaim_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ var ConditionIpRangeAssignedFalse = metav1.Condition{
181181
Message: "Failed to fetch new IP Range from NetBox",
182182
}
183183

184-
var ConditionIpRangeAssignedFalseSizeMissmatch = metav1.Condition{
184+
var ConditionIpRangeAssignedFalseSizeMismatch = metav1.Condition{
185185
Type: "IPRangeAssigned",
186186
Status: "False",
187187
Reason: "IPRangeCRNotCreated",

internal/controller/expected_netboxmock_calls_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func mockIpAddressListWithHashFilter(ipamMock *mock_interfaces.MockIpamInterface
9292
}).MinTimes(1)
9393
}
9494

95-
func mockIpAddressListWithHashFilterMissmatch(ipamMock *mock_interfaces.MockIpamInterface, catchUnexpectedParams chan error) {
95+
func mockIpAddressListWithHashFilterMismatch(ipamMock *mock_interfaces.MockIpamInterface, catchUnexpectedParams chan error) {
9696
ipamMock.EXPECT().IpamIPAddressesList(gomock.Any(), gomock.Any(), gomock.Any()).
9797
DoAndReturn(func(params interface{}, authInfo interface{}, opts ...interface{}) (*ipam.IpamIPAddressesListOK, error) {
9898
got := params.(*ipam.IpamIPAddressesListParams)
@@ -104,7 +104,7 @@ func mockIpAddressListWithHashFilterMissmatch(ipamMock *mock_interfaces.MockIpam
104104
return &ipam.IpamIPAddressesListOK{Payload: nil}, err
105105
}
106106
fmt.Printf("NETBOXMOCK\t ipam.IpamIPAddressesList (empty reslut) was called with expected input,\n")
107-
return &ipam.IpamIPAddressesListOK{Payload: mockedResponseIPAddressListWithHash(customFieldsWithHashMissmatch)}, nil
107+
return &ipam.IpamIPAddressesListOK{Payload: mockedResponseIPAddressListWithHash(customFieldsWithHashMismatch)}, nil
108108
}).MinTimes(1)
109109
}
110110

internal/controller/ipaddress_controller.go

+25-12
Original file line numberDiff line numberDiff line change
@@ -170,25 +170,38 @@ func (r *IpAddressReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
170170

171171
netboxIpAddressModel, err := r.NetboxClient.ReserveOrUpdateIpAddress(ipAddressModel)
172172
if err != nil {
173-
if errors.Is(err, api.ErrRestorationHashMissmatch) && o.Status.IpAddressId == 0 {
174-
// if there is a restoration has missmatch and the IpAddressId status field is not set,
175-
// delete the ip address so it can be recreated by the ip address claim controller
176-
logger.Info("restoration hash missmatch, deleting ip address custom resource", "ipaddress", o.Spec.IpAddress)
177-
err = r.Client.Delete(ctx, o)
178-
if err != nil {
179-
updateStatusErr := r.SetConditionAndCreateEvent(ctx, o, netboxv1.ConditionIpaddressReadyFalse,
180-
corev1.EventTypeWarning, err.Error())
173+
if errors.Is(err, api.ErrRestorationHashMismatch) {
174+
if o.Status.IpAddressId == 0 {
175+
// if there is a restoration hash mismatch and the IpAddressId status field is not set,
176+
// delete the ip address so it can be recreated by the ip address claim controller
177+
// this will only affect resources that are created by a claim controller (and have a restoration hash custom field
178+
logger.Info("restoration hash mismatch, deleting ip address custom resource", "ipaddress", o.Spec.IpAddress)
179+
err = r.Client.Delete(ctx, o)
180+
if err != nil {
181+
if updateStatusErr := r.SetConditionAndCreateEvent(ctx, o, netboxv1.ConditionIpaddressReadyFalse,
182+
corev1.EventTypeWarning, err.Error()); updateStatusErr != nil {
183+
return ctrl.Result{}, fmt.Errorf("failed to update ip address status: %w, "+
184+
"after deletion of ip address cr failed: %w", updateStatusErr, err)
185+
}
186+
return ctrl.Result{Requeue: true}, nil
187+
}
188+
return ctrl.Result{}, nil
189+
}
190+
} else {
191+
if updateStatusErr := r.SetConditionAndCreateEvent(ctx, o, netboxv1.ConditionIpaddressReadyFalse,
192+
corev1.EventTypeWarning, err.Error()); updateStatusErr != nil {
181193
return ctrl.Result{}, fmt.Errorf("failed to update ip address status: %w, "+
182-
"after deletion of ip address cr failed: %w", updateStatusErr, err)
194+
"after reservation of ip in netbox failed: %w", updateStatusErr, err)
183195
}
184-
return ctrl.Result{}, nil
196+
return ctrl.Result{Requeue: true}, nil
185197
}
198+
186199
if updateStatusErr := r.SetConditionAndCreateEvent(ctx, o, netboxv1.ConditionIpaddressReadyFalse,
187-
corev1.EventTypeWarning, o.Spec.IpAddress); updateStatusErr != nil {
200+
corev1.EventTypeWarning, err.Error()); updateStatusErr != nil {
188201
return ctrl.Result{}, fmt.Errorf("failed to update ip address status: %w, "+
189202
"after reservation of ip in netbox failed: %w", updateStatusErr, err)
190203
}
191-
return ctrl.Result{}, nil
204+
return ctrl.Result{Requeue: true}, nil
192205
}
193206

194207
// 3. unlock lease of parent prefix

internal/controller/ipaddress_controller_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var _ = Describe("IpAddress Controller", Ordered, func() {
5252
cr *netboxv1.IpAddress, // our CR as typed object
5353
IpamMocksIpAddress []func(*mock_interfaces.MockIpamInterface, chan error),
5454
TenancyMocks []func(*mock_interfaces.MockTenancyInterface, chan error),
55-
restorationHashMissmatch bool, // To check for deletion if restoration hash does not match
55+
restorationHashMismatch bool, // To check for deletion if restoration hash does not match
5656
expectedConditionReady bool, // Expected state of the ConditionReady condition
5757
expectedCRStatus netboxv1.IpAddressStatus, // Expected status of the CR
5858
) {
@@ -85,7 +85,7 @@ var _ = Describe("IpAddress Controller", Ordered, func() {
8585

8686
createdCR := &netboxv1.IpAddress{}
8787

88-
if restorationHashMissmatch {
88+
if restorationHashMismatch {
8989
Eventually(func() bool {
9090
err := k8sClient.Get(ctx, types.NamespacedName{Name: cr.GetName(), Namespace: cr.GetNamespace()}, createdCR)
9191
return apierrors.IsNotFound(err)
@@ -163,10 +163,10 @@ var _ = Describe("IpAddress Controller", Ordered, func() {
163163
mockTenancyTenancyTenantsList,
164164
},
165165
false, false, ExpectedIpAddressFailedStatus),
166-
Entry("Create IpAddress CR, restoration hash missmatch",
166+
Entry("Create IpAddress CR, restoration hash mismatch",
167167
defaultIpAddressCreatedByClaim(true),
168168
[]func(*mock_interfaces.MockIpamInterface, chan error){
169-
mockIpAddressListWithHashFilterMissmatch,
169+
mockIpAddressListWithHashFilterMismatch,
170170
},
171171
[]func(*mock_interfaces.MockTenancyInterface, chan error){
172172
mockTenancyTenancyTenantsList,

internal/controller/iprange_controller.go

+22-12
Original file line numberDiff line numberDiff line change
@@ -143,27 +143,37 @@ func (r *IpRangeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
143143

144144
netboxIpRangeModel, err := r.NetboxClient.ReserveOrUpdateIpRange(ipRangeModel)
145145
if err != nil {
146-
if errors.Is(err, api.ErrRestorationHashMissmatch) && o.Status.IpRangeId == 0 {
147-
// if there is a restoration has missmatch and the IpRangeId status field is not set,
148-
// delete the ip range so it can be recreated by the ip range claim controller
149-
logger.Info("restoration hash missmatch, deleting ip range custom resource", "ip-range-start", o.Spec.StartAddress, "ip-range-end", o.Spec.EndAddress)
150-
err = r.Client.Delete(ctx, o)
151-
if err != nil {
152-
if err := r.logErrorSetConditionAndCreateEvent(ctx, o, netboxv1.ConditionIpRangeReadyFalse,
146+
if errors.Is(err, api.ErrRestorationHashMismatch) {
147+
if o.Status.IpRangeId == 0 {
148+
// if there is a restoration hash mismatch and the IpRangeId status field is not set,
149+
// delete the ip range so it can be recreated by the ip range claim controller
150+
// this will only affect resources that are created by a claim controller (and have a restoration hash custom field
151+
logger.Info("restoration hash mismatch, deleting ip range custom resource", "ip-range-start", o.Spec.StartAddress, "ip-range-end", o.Spec.EndAddress)
152+
err = r.Client.Delete(ctx, o)
153+
if err != nil {
154+
if err = r.logErrorSetConditionAndCreateEvent(ctx, o, netboxv1.ConditionIpRangeReadyFalse,
155+
corev1.EventTypeWarning, "", err); err != nil {
156+
return ctrl.Result{}, err
157+
}
158+
return ctrl.Result{Requeue: true}, nil
159+
}
160+
return ctrl.Result{}, nil
161+
} else {
162+
if err = r.logErrorSetConditionAndCreateEvent(ctx, o, netboxv1.ConditionIpRangeReadyFalse,
153163
corev1.EventTypeWarning, "", err); err != nil {
154164
return ctrl.Result{}, err
155165
}
166+
return ctrl.Result{Requeue: true}, nil
156167
}
157-
return ctrl.Result{}, nil
158168
}
159169

160-
if loggingErr := r.logErrorSetConditionAndCreateEvent(ctx, o, netboxv1.ConditionIpRangeReadyFalse,
161-
corev1.EventTypeWarning, fmt.Sprintf("%s-%s ", o.Spec.StartAddress, o.Spec.EndAddress), err); loggingErr != nil {
162-
return ctrl.Result{}, fmt.Errorf("logging error: %w. Original error from ReserveOrUpdateIpRange: %w", loggingErr, err)
170+
if err = r.logErrorSetConditionAndCreateEvent(ctx, o, netboxv1.ConditionIpRangeReadyFalse,
171+
corev1.EventTypeWarning, fmt.Sprintf("%s-%s ", o.Spec.StartAddress, o.Spec.EndAddress), err); err != nil {
172+
return ctrl.Result{}, err
163173
}
164174

165175
// The decision to not return the error message (just logging it) is to not trigger printing the stacktrace on api errors
166-
return ctrl.Result{}, nil
176+
return ctrl.Result{Requeue: true}, nil
167177
}
168178

169179
// 3. unlock lease of parent prefix

internal/controller/iprangeclaim_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ func (r *IpRangeClaimReconciler) restoreOrAssignIpRangeAndSetCondition(ctx conte
322322
availableIpRanges, err := r.NetboxClient.GetAvailableIpAddressesByIpRange(ipRangeModel.Id)
323323
if len(availableIpRanges.Payload) != o.Spec.Size {
324324
ll.Unlock()
325-
err = r.logErrorSetConditionAndCreateEvent(ctx, o, netboxv1.ConditionIpRangeAssignedFalseSizeMissmatch, corev1.EventTypeWarning, "", err)
325+
err = r.logErrorSetConditionAndCreateEvent(ctx, o, netboxv1.ConditionIpRangeAssignedFalseSizeMismatch, corev1.EventTypeWarning, "", err)
326326
if err != nil {
327327
return nil, ctrl.Result{}, err
328328
}

internal/controller/netbox_testdata_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var customFieldsCR = map[string]string{"example_field": "example value"}
5757
var customFieldsWithHashCR = map[string]string{"example_field": "example value", "netboxOperatorRestorationHash": restorationHash}
5858

5959
var customFieldsWithHash = map[string]interface{}{"example_field": "example value", "netboxOperatorRestorationHash": restorationHash}
60-
var customFieldsWithHashMissmatch = map[string]interface{}{"example_field": "example value", "netboxOperatorRestorationHash": "different hash"}
60+
var customFieldsWithHashMismatch = map[string]interface{}{"example_field": "example value", "netboxOperatorRestorationHash": "different hash"}
6161

6262
var netboxLabel = "Status"
6363
var value = "active"

internal/controller/prefix_controller.go

+26-14
Original file line numberDiff line numberDiff line change
@@ -184,25 +184,37 @@ func (r *PrefixReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
184184

185185
netboxPrefixModel, err := r.NetboxClient.ReserveOrUpdatePrefix(prefixModel)
186186
if err != nil {
187-
if errors.Is(err, api.ErrRestorationHashMissmatch) && prefix.Status.PrefixId == 0 {
188-
// if there is a restoration has missmatch and the PrefixId status field is not set,
189-
// delete the prefix so it can be recreated by the prefix claim controller
190-
logger.Info("restoration hash missmatch, deleting prefix custom resource", "prefix", prefix.Spec.Prefix)
191-
err = r.Client.Delete(ctx, prefix)
192-
if err != nil {
193-
updateStatusErr := r.SetConditionAndCreateEvent(ctx, prefix, netboxv1.ConditionIpaddressReadyFalse,
194-
corev1.EventTypeWarning, err.Error())
195-
return ctrl.Result{}, fmt.Errorf("failed to update prefix status: %w, "+
196-
"after deletion of prefix cr failed: %w", updateStatusErr, err)
187+
if errors.Is(err, api.ErrRestorationHashMismatch) {
188+
if prefix.Status.PrefixId == 0 {
189+
// if there is a restoration hash mismatch and the PrefixId status field is not set,
190+
// delete the prefix so it can be recreated by the prefix claim controller
191+
// this will only affect resources that are created by a claim controller (and have a restoration hash custom field
192+
logger.Info("restoration hash mismatch, deleting prefix custom resource", "prefix", prefix.Spec.Prefix)
193+
err = r.Client.Delete(ctx, prefix)
194+
if err != nil {
195+
if updateStatusErr := r.SetConditionAndCreateEvent(ctx, prefix, netboxv1.ConditionPrefixReadyFalse,
196+
corev1.EventTypeWarning, err.Error()); updateStatusErr != nil {
197+
return ctrl.Result{}, fmt.Errorf("failed to update prefix status: %w, "+
198+
"after deletion of prefix cr failed: %w", updateStatusErr, err)
199+
}
200+
return ctrl.Result{Requeue: true}, nil
201+
}
202+
return ctrl.Result{}, nil
203+
} else {
204+
if updateStatusErr := r.SetConditionAndCreateEvent(ctx, prefix, netboxv1.ConditionPrefixReadyFalse,
205+
corev1.EventTypeWarning, err.Error()); updateStatusErr != nil {
206+
return ctrl.Result{}, fmt.Errorf("failed to update prefix status: %w, "+
207+
"after deletion of prefix cr failed: %w", updateStatusErr, err)
208+
}
209+
return ctrl.Result{Requeue: true}, nil
197210
}
198-
return ctrl.Result{}, nil
199211
}
200-
if updateStatusErr := r.SetConditionAndCreateEvent(ctx, prefix, netboxv1.ConditionIpaddressReadyFalse,
201-
corev1.EventTypeWarning, prefix.Spec.Prefix); updateStatusErr != nil {
212+
if updateStatusErr := r.SetConditionAndCreateEvent(ctx, prefix, netboxv1.ConditionPrefixReadyFalse,
213+
corev1.EventTypeWarning, err.Error()); updateStatusErr != nil {
202214
return ctrl.Result{}, fmt.Errorf("failed to update prefix status: %w, "+
203215
"after reservation of prefix netbox failed: %w", updateStatusErr, err)
204216
}
205-
return ctrl.Result{}, nil
217+
return ctrl.Result{Requeue: true}, nil
206218
}
207219

208220
/* 3. unlock lease of parent prefix */

pkg/netbox/api/errors.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ var (
2323
ErrParentPrefixNotFound = errors.New("parent prefix not found")
2424
ErrWrongMatchingPrefixSubnetFormat = errors.New("wrong matchingPrefix subnet format")
2525
ErrInvalidIpFamily = errors.New("invalid IP Family")
26-
ErrRestorationHashMissmatch = errors.New("restoration hash missmatch")
26+
ErrRestorationHashMismatch = errors.New("restoration hash mismatch")
2727
)

pkg/netbox/api/ip_address.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (r *NetboxClient) ReserveOrUpdateIpAddress(ipAddress *models.IPAddress) (*n
7070
//update ip address since it does exist and the restoration hash matches
7171
return r.UpdateIpAddress(ipToUpdate.ID, desiredIPAddress)
7272
}
73-
return nil, fmt.Errorf("%w, assigned ip address %s", ErrRestorationHashMissmatch, ipAddress.IpAddress)
73+
return nil, fmt.Errorf("%w, assigned ip address %s", ErrRestorationHashMismatch, ipAddress.IpAddress)
7474
}
7575
}
7676

pkg/netbox/api/ip_address_test.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ func TestIPAddress(t *testing.T) {
6262
}
6363
}
6464

65+
expectedHash := "fioaf9289rjfhaeuih"
66+
6567
customFields := map[string]interface{}{
66-
config.GetOperatorConfig().NetboxRestorationHashFieldName: "fioaf9289rjfhaeuih",
68+
config.GetOperatorConfig().NetboxRestorationHashFieldName: expectedHash,
6769
}
6870

6971
// example output IP address
@@ -331,12 +333,12 @@ func TestIPAddress(t *testing.T) {
331333
Ipam: mockIPAddress,
332334
}
333335

334-
ipAddressModel := ipAddressModel("fioaf9289rjfhaeuih")
336+
ipAddressModel := ipAddressModel(expectedHash)
335337
_, err := client.ReserveOrUpdateIpAddress(ipAddressModel)
336338
AssertNil(t, err)
337339
})
338340

339-
t.Run("Check ReserveOrUpdate with hash missmatch", func(t *testing.T) {
341+
t.Run("Check ReserveOrUpdate with hash mismatch", func(t *testing.T) {
340342
inputList := ipam.NewIpamIPAddressesListParams().WithAddress(&ipAddress)
341343
outputList := &ipam.IpamIPAddressesListOK{
342344
Payload: &ipam.IpamIPAddressesListOKBody{
@@ -358,6 +360,6 @@ func TestIPAddress(t *testing.T) {
358360

359361
ipAddressModel := ipAddressModel("iwfohs7v82fe9w0")
360362
_, err := client.ReserveOrUpdateIpAddress(ipAddressModel)
361-
AssertError(t, err, "restoration hash missmatch, assigned ip address 10.112.140.0")
363+
AssertError(t, err, "restoration hash mismatch, assigned ip address 10.112.140.0")
362364
})
363365
}

pkg/netbox/api/ip_range.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (r *NetboxClient) ReserveOrUpdateIpRange(ipRange *models.IpRange) (*netboxM
7373
//update ip address since it does exist and the restoration hash matches
7474
return r.UpdateIpRange(ipRangeToUpdate.ID, desiredIpRange)
7575
}
76-
return nil, fmt.Errorf("%w, assigned ip range %s-%s", ErrRestorationHashMissmatch, ipRange.StartAddress, ipRange.EndAddress)
76+
return nil, fmt.Errorf("%w, assigned ip range %s-%s", ErrRestorationHashMismatch, ipRange.StartAddress, ipRange.EndAddress)
7777
}
7878
}
7979

pkg/netbox/api/ip_range_test.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,14 @@ func TestIpRange(t *testing.T) {
184184
assert.Equal(t, expectedIPRange().Tenant.Slug, actual.Tenant.Slug)
185185
})
186186

187-
t.Run("ReserveOrUpdate, restoration hash missmatch", func(t *testing.T) {
187+
t.Run("ReserveOrUpdate, restoration hash mismatch", func(t *testing.T) {
188188

189189
// ip range mock input
190190
listInput := ipam.NewIpamIPRangesListParams().
191191
WithStartAddress(&startAddress).
192192
WithEndAddress(&endAddress)
193193

194+
wrongHash := "89hqvs0ud89qhdi"
194195
// ip range mock output
195196
listOutput := &ipam.IpamIPRangesListOK{
196197
Payload: &ipam.IpamIPRangesListOKBody{
@@ -200,7 +201,7 @@ func TestIpRange(t *testing.T) {
200201
StartAddress: &startAddress,
201202
EndAddress: &endAddress,
202203
CustomFields: map[string]interface{}{
203-
config.GetOperatorConfig().NetboxRestorationHashFieldName: "different hash",
204+
config.GetOperatorConfig().NetboxRestorationHashFieldName: wrongHash,
204205
},
205206
Comments: expectedIPRange().Comments,
206207
Description: expectedIPRange().Description,
@@ -217,18 +218,19 @@ func TestIpRange(t *testing.T) {
217218
Ipam: mockIpam,
218219
}
219220

221+
expectedHash := "ffjrep8b29fdaikb"
220222
_, err := client.ReserveOrUpdateIpRange(&models.IpRange{
221223
StartAddress: startAddress,
222224
EndAddress: endAddress,
223225
Metadata: &models.NetboxMetadata{
224226
Custom: map[string]string{
225-
config.GetOperatorConfig().NetboxRestorationHashFieldName: "hash",
227+
config.GetOperatorConfig().NetboxRestorationHashFieldName: expectedHash,
226228
},
227229
},
228230
})
229231

230232
// assert error return
231-
AssertError(t, err, "restoration hash missmatch, assigned ip range 10.112.140.1-10.112.140.3")
233+
AssertError(t, err, "restoration hash mismatch, assigned ip range 10.112.140.1-10.112.140.3")
232234
})
233235

234236
t.Run("ReserveOrUpdate, update existing ip range", func(t *testing.T) {

pkg/netbox/api/prefix.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (r *NetboxClient) ReserveOrUpdatePrefix(prefix *models.Prefix) (*netboxMode
8383
//update ip address since it does exist and the restoration hash matches
8484
return r.UpdatePrefix(prefixToUpdate.ID, desiredPrefix)
8585
}
86-
return nil, fmt.Errorf("%w, assigned prefix %s", ErrRestorationHashMissmatch, prefix.Prefix)
86+
return nil, fmt.Errorf("%w, assigned prefix %s", ErrRestorationHashMismatch, prefix.Prefix)
8787
}
8888
}
8989

pkg/netbox/api/prefix_test.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -482,19 +482,20 @@ func TestPrefix_ReserveOrUpdate(t *testing.T) {
482482
assert.Nil(t, err)
483483
})
484484

485-
t.Run("restoration hash missmatch", func(t *testing.T) {
485+
t.Run("restoration hash mismatch", func(t *testing.T) {
486486
ctrl := gomock.NewController(t)
487487
defer ctrl.Finish()
488488
mockIpam := mock_interfaces.NewMockIpamInterface(ctrl)
489489

490+
wrongHash := "89327r7fhui"
490491
//prefix mock output
491492
prefixListOutput := &ipam.IpamPrefixesListOK{
492493
Payload: &ipam.IpamPrefixesListOKBody{
493494
Results: []*netboxModels.Prefix{
494495
{
495496
ID: prefixId,
496497
CustomFields: map[string]interface{}{
497-
config.GetOperatorConfig().NetboxRestorationHashFieldName: "hash",
498+
config.GetOperatorConfig().NetboxRestorationHashFieldName: wrongHash,
498499
},
499500
Display: prefix,
500501
Prefix: &prefix,
@@ -509,16 +510,17 @@ func TestPrefix_ReserveOrUpdate(t *testing.T) {
509510
Ipam: mockIpam,
510511
}
511512

513+
expectedHash := "jfioaw0e9gh"
512514
prefixModel := models.Prefix{
513515
Prefix: prefix,
514516
Metadata: &models.NetboxMetadata{
515-
Custom: map[string]string{config.GetOperatorConfig().NetboxRestorationHashFieldName: "hash-not-matching"},
517+
Custom: map[string]string{config.GetOperatorConfig().NetboxRestorationHashFieldName: expectedHash},
516518
},
517519
}
518520

519521
_, err := netboxClient.ReserveOrUpdatePrefix(&prefixModel)
520522
// skip assertion on retured values as the payload of IpamPrefixesCreate() is returened
521523
// without manipulation by the code
522-
AssertError(t, err, "restoration hash missmatch, assigned prefix 10.112.140.0/24")
524+
AssertError(t, err, "restoration hash mismatch, assigned prefix 10.112.140.0/24")
523525
})
524526
}

0 commit comments

Comments
 (0)