chore(source/node): added resouce labels for nodes (#5509)

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
This commit is contained in:
Ivan Ka 2025-06-09 12:12:23 +01:00 committed by GitHub
parent 3e0c509f1d
commit 28cac12dbe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 4 deletions

View File

@ -1460,6 +1460,11 @@ func testIngressEndpoints(t *testing.T) {
require.NoError(t, err)
}
validateEndpoints(t, res, ti.expected)
// TODO; when all resources have the resource label, we could add this check to the validateEndpoints function.
for _, ep := range res {
require.Contains(t, ep.Labels, endpoint.ResourceLabelKey)
}
})
}
}

View File

@ -102,7 +102,7 @@ func (ns *nodeSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, erro
// create endpoints for all nodes
for _, node := range nodes {
// Check controller annotation to see if we are responsible.
// Check the controller annotation to see if we are responsible.
if controller, ok := node.Annotations[controllerAnnotationKey]; ok && controller != controllerAnnotationValue {
log.Debugf("Skipping node %s because controller value does not match, found: %s, required: %s",
node.Name, controller, controllerAnnotationValue)
@ -149,6 +149,8 @@ func (ns *nodeSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, erro
for _, addr := range addrs {
ep := endpoint.NewEndpointWithTTL(dns, suitableType(addr), ttl)
ep.WithLabel(endpoint.ResourceLabelKey, fmt.Sprintf("node/%s", node.Name))
log.Debugf("adding endpoint %s target %s", ep, addr)
key := endpoint.EndpointKey{
DNSName: ep.DNSName,

View File

@ -573,6 +573,11 @@ func testNodeEndpointsWithIPv6(t *testing.T) {
// Validate returned endpoints against desired endpoints.
validateEndpoints(t, endpoints, tc.expected)
// TODO; when all resources have the resource label, we could add this check to the validateEndpoints function.
for _, ep := range endpoints {
require.Contains(t, ep.Labels, endpoint.ResourceLabelKey)
}
}
}
@ -605,9 +610,8 @@ func TestResourceLabelIsSetForEachNodeEndpoint(t *testing.T) {
got, err := client.Endpoints(t.Context())
require.NoError(t, err)
for _, ep := range got {
// TODO: node source should always set the resource label key. currently not supported by the node source.
assert.Empty(t, ep.Labels, "Labels should not be empty for endpoint %s", ep.DNSName)
assert.NotContains(t, ep.Labels, endpoint.ResourceLabelKey)
assert.NotEmpty(t, ep.Labels, "Labels should not be empty for endpoint %s", ep.DNSName)
assert.Contains(t, ep.Labels, endpoint.ResourceLabelKey)
}
}