Skip to content

Commit

Permalink
chore: clean flag
Browse files Browse the repository at this point in the history
Since the introduction of transformation rules, this logic is no longer necessary.
The skipForeignNode flag was undocumented before, making its removal straightforward.

Signed-off-by: Serge Logvinov <[email protected]>
  • Loading branch information
sergelogvinov committed May 16, 2024
1 parent 9dde8aa commit 53034c8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 19 deletions.
4 changes: 0 additions & 4 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ global:
# Parameter is optional, by default is "false"
approveNodeCSR: true

# Skip non-Talos nodes after initialisation
# Parameter is optional, by default is "false"
skipForeignNode: false

# The list of endpoints to connect to the Talos API (control-plane)
# Parameter is optional, by default the controller will discover the control-plane endpoint
endpoints:
Expand Down
1 change: 0 additions & 1 deletion hack/ccm-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
global:
approveNodeCSR: true
skipForeignNode: false
# endpoints:
# - 1.2.3.4
# - 4.3.2.1
Expand Down
2 changes: 0 additions & 2 deletions pkg/talos/cloud_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ type cloudConfigGlobal struct {
ClusterName string `yaml:"clusterName,omitempty"`
// Talos API endpoints.
Endpoints []string `yaml:"endpoints,omitempty"`
// Do not update foreign initialized node.
SkipForeignNode bool `yaml:"skipForeignNode,omitempty"`
// Prefer IPv6.
PreferIPv6 bool `yaml:"preferIPv6,omitempty"`
}
Expand Down
17 changes: 6 additions & 11 deletions pkg/talos/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ func (i *instances) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloud
return nil, fmt.Errorf("error transforming node: %w", err)
}

if nodeSpec == nil {
nodeSpec = &transformer.NodeSpec{}
}

mc = metrics.NewMetricContext("addresses")

ifaces, err := i.c.getNodeIfaces(ctx, nodeIP)
Expand All @@ -119,16 +123,7 @@ func (i *instances) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloud
addresses = append(addresses, v1.NodeAddress{Type: v1.NodeInternalDNS, Address: meta.Hostname})
}

// Foreign node, update network only.
if i.c.config.Global.SkipForeignNode && !strings.HasPrefix(node.Spec.ProviderID, ProviderName) {
klog.V(4).Infof("instances.InstanceMetadata() node %s has foreign providerID: %s, skipped", node.Name, node.Spec.ProviderID)

return &cloudprovider.InstanceMetadata{
NodeAddresses: addresses,
}, nil
}

if nodeSpec != nil && nodeSpec.Annotations != nil {
if nodeSpec.Annotations != nil {
klog.V(4).Infof("instances.InstanceMetadata() node %s has annotations: %+v", node.Name, nodeSpec.Annotations)

if err := syncNodeAnnotations(ctx, i.c, node, nodeSpec.Annotations); err != nil {
Expand All @@ -138,7 +133,7 @@ func (i *instances) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloud

nodeLabels := setTalosNodeLabels(i.c, meta)

if nodeSpec != nil && nodeSpec.Labels != nil {
if nodeSpec.Labels != nil {
klog.V(4).Infof("instances.InstanceMetadata() node %s has labels: %+v", node.Name, nodeSpec.Labels)

maps.Copy(nodeLabels, nodeSpec.Labels)
Expand Down
1 change: 0 additions & 1 deletion pkg/talos/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func TestInstanceMetadata(t *testing.T) {
t.Setenv("TALOSCONFIG", "../../hack/talosconfig")

cfg := cloudConfig{}
cfg.Global.SkipForeignNode = true

ctx := context.Background()
client, err := newClient(ctx, &cfg)
Expand Down

0 comments on commit 53034c8

Please sign in to comment.