From 53034c81513f0e9b6ca300dbe3189262eb2df506 Mon Sep 17 00:00:00 2001 From: Serge Logvinov Date: Thu, 16 May 2024 14:21:53 +0300 Subject: [PATCH] chore: clean flag 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 --- docs/config.md | 4 ---- hack/ccm-config.yaml | 1 - pkg/talos/cloud_config.go | 2 -- pkg/talos/instances.go | 17 ++++++----------- pkg/talos/instances_test.go | 1 - 5 files changed, 6 insertions(+), 19 deletions(-) diff --git a/docs/config.md b/docs/config.md index 72692ac..3b3e7fe 100644 --- a/docs/config.md +++ b/docs/config.md @@ -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: diff --git a/hack/ccm-config.yaml b/hack/ccm-config.yaml index 73b0bc3..aa5f9c1 100644 --- a/hack/ccm-config.yaml +++ b/hack/ccm-config.yaml @@ -1,6 +1,5 @@ global: approveNodeCSR: true - skipForeignNode: false # endpoints: # - 1.2.3.4 # - 4.3.2.1 diff --git a/pkg/talos/cloud_config.go b/pkg/talos/cloud_config.go index bf3c3ef..52ecae2 100644 --- a/pkg/talos/cloud_config.go +++ b/pkg/talos/cloud_config.go @@ -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"` } diff --git a/pkg/talos/instances.go b/pkg/talos/instances.go index d8f2ffb..6433700 100644 --- a/pkg/talos/instances.go +++ b/pkg/talos/instances.go @@ -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) @@ -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 { @@ -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) diff --git a/pkg/talos/instances_test.go b/pkg/talos/instances_test.go index 316167b..e691249 100644 --- a/pkg/talos/instances_test.go +++ b/pkg/talos/instances_test.go @@ -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)