Skip to content
This repository was archived by the owner on Jun 23, 2020. It is now read-only.

Commit 7542f78

Browse files
committed
Handle nil as some of the fields
1 parent c832ef7 commit 7542f78

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/oci/client/oci.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,15 @@ func (c *client) findInstanceByNodeNameIsVnic(cache *cache.OCICache, nodeName st
251251
return c.network.GetVnic(ctx, vnicRequest)
252252
}()
253253
if err != nil {
254-
log.Printf("Error getting Vnic for attachment: %s(%v)", *attachment.Id, err)
254+
log.Printf("Error getting Vnic for attachment: %s(%v)", attachment, err)
255255
continue
256256
}
257257
vnic = &vnicResponse.Vnic
258258
cache.SetVnic(*attachment.VnicId, vnic)
259259
}
260-
if *vnic.PublicIp == nodeName ||
261-
(*vnic.HostnameLabel != "" && strings.HasPrefix(nodeName, *vnic.HostnameLabel)) {
260+
log.Printf("Checking vnic:%s", *vnic)
261+
if (vnic.PublicIp != nil && *vnic.PublicIp == nodeName) ||
262+
(vnic.HostnameLabel != nil && (*vnic.HostnameLabel != "" && strings.HasPrefix(nodeName, *vnic.HostnameLabel))) {
262263
instanceRequest := core.GetInstanceRequest{
263264
InstanceId: attachment.InstanceId,
264265
}
@@ -268,7 +269,7 @@ func (c *client) findInstanceByNodeNameIsVnic(cache *cache.OCICache, nodeName st
268269
return c.compute.GetInstance(ctx, instanceRequest)
269270
}()
270271
if err != nil {
271-
log.Printf("Error getting instance for attachment: %s", *attachment.InstanceId)
272+
log.Printf("Error getting instance for attachment: %s", attachment)
272273
return nil, err
273274
}
274275
instance := instanceResponse.Instance
@@ -344,6 +345,7 @@ func getCacheDirectory() string {
344345
// GetInstanceByNodeName retrieves the corresponding core.Instance or a
345346
// SearchError if no instance matching the node name is found.
346347
func (c *client) GetInstanceByNodeName(nodeName string) (*core.Instance, error) {
348+
log.Printf("GetInstanceByNodeName:%s", nodeName)
347349
ociCache, err := cache.Open(fmt.Sprintf("%s/%s", getCacheDirectory(), "nodenamecache.json"))
348350
if err != nil {
349351
return nil, err

0 commit comments

Comments
 (0)