@@ -159,6 +159,19 @@ func (r *PrefixReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
159159		return  ctrl.Result {}, fmt .Errorf ("failed at update prefix status: %w, " + "after reservation of prefix in netbox failed: %w" , updateStatusErr , err )
160160	}
161161
162+ 	/* 3. unlock lease of parent prefix */ 
163+ 	if  ll  !=  nil  {
164+ 		ll .Unlock ()
165+ 	}
166+ 
167+ 	/* 4. update status fields */ 
168+ 	prefix .Status .PrefixId  =  netboxPrefixModel .ID 
169+ 	prefix .Status .PrefixUrl  =  config .GetBaseUrl () +  "/ipam/prefixes/"  +  strconv .FormatInt (netboxPrefixModel .ID , 10 )
170+ 	err  =  r .Client .Status ().Update (ctx , prefix )
171+ 	if  err  !=  nil  {
172+ 		return  ctrl.Result {}, err 
173+ 	}
174+ 
162175	// update lastPrefixMetadata annotation 
163176	if  annotations  ==  nil  {
164177		annotations  =  make (map [string ]string )
@@ -199,14 +212,6 @@ func (r *PrefixReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
199212
200213	debugLogger .Info (fmt .Sprintf ("reserved prefix in netbox, prefix: %s" , prefix .Spec .Prefix ))
201214
202- 	/* 3. unlock lease of parent prefix */ 
203- 	if  ll  !=  nil  {
204- 		ll .Unlock ()
205- 	}
206- 
207- 	/* 4. update status conditions */ 
208- 	prefix .Status .PrefixId  =  netboxPrefixModel .ID 
209- 	prefix .Status .PrefixUrl  =  config .GetBaseUrl () +  "/ipam/prefixes/"  +  strconv .FormatInt (netboxPrefixModel .ID , 10 )
210215	if  err  =  r .SetConditionAndCreateEvent (ctx , prefix , netboxv1 .ConditionPrefixReadyTrue , corev1 .EventTypeNormal , "" ); err  !=  nil  {
211216		return  ctrl.Result {}, err 
212217	}
0 commit comments