@@ -23,6 +23,7 @@ import (
2323
2424	"github.com/go-logr/logr" 
2525	"github.com/google/uuid" 
26+ 	"github.com/packethost/packngo" 
2627	"github.com/pkg/errors" 
2728
2829	apierrors "k8s.io/apimachinery/pkg/api/errors" 
@@ -180,9 +181,17 @@ func (r *PacketMachineReconciler) reconcile(ctx context.Context, machineScope *s
180181		return  ctrl.Result {}, nil 
181182	}
182183
183- 	dev , err  :=  r .PacketClient .GetDevice (machineScope .GetInstanceID ())
184- 	if  err  !=  nil  {
185- 		return  ctrl.Result {}, err 
184+ 	providerID  :=  machineScope .GetInstanceID ()
185+ 	var  (
186+ 		dev  * packngo.Device 
187+ 		err  error 
188+ 	)
189+ 	// if we have no provider ID, then we are creating 
190+ 	if  providerID  !=  ""  {
191+ 		dev , err  =  r .PacketClient .GetDevice (providerID )
192+ 		if  err  !=  nil  {
193+ 			return  ctrl.Result {}, err 
194+ 		}
186195	}
187196	if  dev  ==  nil  {
188197		// generate a unique UID that will survive pivot, i.e. is not tied to the cluster itself 
@@ -206,7 +215,8 @@ func (r *PacketMachineReconciler) reconcile(ctx context.Context, machineScope *s
206215		}
207216	}
208217
209- 	machineScope .SetProviderID (fmt .Sprintf ("%s://%s" , providerName , dev .ID ))
218+ 	// we do not need to set this as packet://<id> because SetProviderID() does the formatting for us 
219+ 	machineScope .SetProviderID (dev .ID )
210220	machineScope .SetInstanceStatus (infrastructurev1alpha3 .PacketResourceStatus (dev .State ))
211221
212222	addrs , err  :=  r .PacketClient .GetDeviceAddresses (dev )
0 commit comments