Skip to content

Commit 459d49a

Browse files
committed
chore: Add/adjust some logging
1 parent 4ea00b2 commit 459d49a

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

pkg/cloud/metadata.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (c *client) metadataInstanceID(ctx context.Context) string {
2525

2626
// Try a NODE_ID environment variable
2727
if envNodeID := os.Getenv("NODE_ID"); envNodeID != "" {
28-
logger.V(4).Info("Found CloudStack VM ID from envvar NODE_ID", "nodeID", envNodeID)
28+
logger.Info("Found CloudStack VM ID from envvar NODE_ID", "nodeID", envNodeID)
2929

3030
return envNodeID
3131
}
@@ -38,7 +38,7 @@ func (c *client) metadataInstanceID(ctx context.Context) string {
3838
if err != nil {
3939
logger.Error(err, "Cannot read cloud-init instance data")
4040
} else if ciData.V1.InstanceID != "" {
41-
logger.V(4).Info("Found CloudStack VM ID from cloud-init", "nodeID", ciData.V1.InstanceID)
41+
logger.Info("Found CloudStack VM ID from cloud-init", "nodeID", ciData.V1.InstanceID)
4242

4343
return ciData.V1.InstanceID
4444
}
@@ -57,7 +57,7 @@ func (c *client) metadataInstanceID(ctx context.Context) string {
5757
if err != nil {
5858
logger.Error(err, "Cannot read ignition metadata")
5959
} else if instanceID != "" {
60-
logger.V(4).Info("Found CloudStack VM ID from ignition", "nodeID", instanceID)
60+
logger.Info("Found CloudStack VM ID from ignition", "nodeID", instanceID)
6161

6262
return instanceID
6363
}
@@ -68,7 +68,7 @@ func (c *client) metadataInstanceID(ctx context.Context) string {
6868
logger.Error(err, "Cannot read file "+ignitionMetadataFilePath)
6969
}
7070

71-
logger.V(4).Info("CloudStack VM ID not found in meta-data")
71+
logger.Info("CloudStack VM ID not found in meta-data")
7272

7373
return ""
7474
}

pkg/cloud/node.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
package cloud
22

3-
import "context"
3+
import (
4+
"context"
5+
6+
"k8s.io/klog/v2"
7+
)
48

59
func (c *client) GetNodeInfo(ctx context.Context, vmName string) (*VM, error) {
6-
// First, try to read the instance ID from meta-data (cloud-init)
10+
logger := klog.FromContext(ctx)
11+
12+
// First, try to read the instance ID from meta-data.
713
if id := c.metadataInstanceID(ctx); id != "" {
814
// Instance ID found using metadata
15+
logger.V(4).Info("Looking up node info using VM ID found in metadata", "nodeID", id)
916

1017
// Use CloudStack API to get VM info
1118
return c.GetVMByID(ctx, id)
1219
}
1320

14-
// VM ID was not found using metadata.
15-
// Use VM name instead
21+
// VM ID was not found using metadata, fall back to using VM name instead.
22+
logger.V(4).Info("Looking up node info using VM name", "nodeName", vmName)
23+
1624
return c.getVMByName(ctx, vmName)
1725
}

0 commit comments

Comments
 (0)