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

Commit dc1a7e7

Browse files
authored
Merge pull request #62 from oracle/gb/fix-publicip-nil
Handle nil as some of the fields
2 parents c832ef7 + 067a67b commit dc1a7e7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pkg/oci/client/oci.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,14 @@ 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+
if (vnic.PublicIp != nil && *vnic.PublicIp == nodeName) ||
261+
(vnic.HostnameLabel != nil && (*vnic.HostnameLabel != "" && strings.HasPrefix(nodeName, *vnic.HostnameLabel))) {
262262
instanceRequest := core.GetInstanceRequest{
263263
InstanceId: attachment.InstanceId,
264264
}
@@ -268,7 +268,7 @@ func (c *client) findInstanceByNodeNameIsVnic(cache *cache.OCICache, nodeName st
268268
return c.compute.GetInstance(ctx, instanceRequest)
269269
}()
270270
if err != nil {
271-
log.Printf("Error getting instance for attachment: %s", *attachment.InstanceId)
271+
log.Printf("Error getting instance for attachment: %s", attachment)
272272
return nil, err
273273
}
274274
instance := instanceResponse.Instance
@@ -344,6 +344,7 @@ func getCacheDirectory() string {
344344
// GetInstanceByNodeName retrieves the corresponding core.Instance or a
345345
// SearchError if no instance matching the node name is found.
346346
func (c *client) GetInstanceByNodeName(nodeName string) (*core.Instance, error) {
347+
log.Printf("GetInstanceByNodeName:%s", nodeName)
347348
ociCache, err := cache.Open(fmt.Sprintf("%s/%s", getCacheDirectory(), "nodenamecache.json"))
348349
if err != nil {
349350
return nil, err

0 commit comments

Comments
 (0)