Skip to content

Commit ea6fc28

Browse files
committed
update docs and add comments
1 parent 5fc8398 commit ea6fc28

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

cloud/linode/node_controller.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type nodeController struct {
5151
nodeLastAdded map[string]time.Time
5252
}
5353

54+
// k8sNodeCache stores node related info as registered in k8s
5455
type k8sNodeCache struct {
5556
sync.RWMutex
5657
nodes map[string]*v1.Node
@@ -89,6 +90,7 @@ func (c *k8sNodeCache) updateCache(kubeclient kubernetes.Interface) {
8990
c.lastUpdate = time.Now()
9091
}
9192

93+
// addNodeToCache stores the specified node in k8s node cache
9294
func (c *k8sNodeCache) addNodeToCache(node *v1.Node) {
9395
c.Lock()
9496
defer c.Unlock()
@@ -131,6 +133,7 @@ func (c *k8sNodeCache) getProviderID(nodeName string) (string, bool) {
131133
return "", false
132134
}
133135

136+
// newK8sNodeCache returns new k8s node cache instance
134137
func newK8sNodeCache() *k8sNodeCache {
135138
timeout := defaultK8sNodeCacheTTL
136139
if raw, ok := os.LookupEnv("K8S_NODECACHE_TTL"); ok {
@@ -285,9 +288,7 @@ func (s *nodeController) handleNode(ctx context.Context, node *v1.Node) error {
285288

286289
expectedPrivateIP := ""
287290
// linode API response for linode will contain only one private ip
288-
// if any private ip is configured. If it changes in future or linode
289-
// supports other subnets with nodebalancer, this logic needs to be updated.
290-
// https://www.linode.com/docs/api/linode-instances/#linode-view
291+
// if any private ip is configured.
291292
for _, addr := range linode.IPv4 {
292293
if isPrivate(addr) {
293294
expectedPrivateIP = addr.String()
@@ -329,7 +330,9 @@ func (s *nodeController) handleNode(ctx context.Context, node *v1.Node) error {
329330
return err
330331
}
331332

332-
registeredK8sNodeCache.addNodeToCache(updatedNode)
333+
if updatedNode != nil {
334+
registeredK8sNodeCache.addNodeToCache(updatedNode)
335+
}
333336
s.SetLastMetadataUpdate(node.Name)
334337

335338
return nil

docs/configuration/environment.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The CCM can be configured using environment variables and flags. Environment var
1212
|----------|---------|-------------|
1313
| `LINODE_INSTANCE_CACHE_TTL` | `15` | Default timeout of instance cache in seconds |
1414
| `LINODE_ROUTES_CACHE_TTL_SECONDS` | `60` | Default timeout of route cache in seconds |
15+
| `LINODE_METADATA_TTL` | `300` | Default linode metadata timeout in seconds |
16+
| `K8S_NODECACHE_TTL` | `300` | Default timeout of k8s node cache in seconds |
1517

1618
### API Configuration
1719

0 commit comments

Comments
 (0)