Skip to content

Conversation

@rahulbabu95
Copy link
Member

@rahulbabu95 rahulbabu95 commented Jan 9, 2026

Issue #, if available:
#9456
https://github.com/aws/eks-anywhere-internal/issues/2712

Description of changes:

Summary

Adds HardwareAffinity field to TinkerbellMachineConfig for advanced hardware selection using Kubernetes-style label selectors with required and preferred terms. This aligns with CAPT's HardwareAffinity feature.

Changes

  • Add HardwareAffinity, HardwareAffinityTerm, and WeightedHardwareAffinityTerm types
  • Support required (hard constraints) and preferred (soft constraints with weights 1-100) affinity terms
  • Support matchLabels and matchExpressions (In, NotIn, Exists, DoesNotExist operators)
  • Validate mutual exclusivity between HardwareSelector and HardwareAffinity
  • Both HardwareSelector and HardwareAffinity are now mutable - changes only affect new machine provisioning; existing machines keep their assigned hardware (aligns with CAPT's ownership model via labels on Hardware objects)
  • Update hardware validation assertions and template generation

Example

spec:
  hardwareAffinity:
    required:
      - labelSelector:
          matchLabels:
            type: control-plane
          matchExpressions:
            - key: vendor
              operator: In
              values: [HP, Dell]
    preferred:
      - weight: 100
        hardwareAffinityTerm:
          labelSelector:
            matchLabels:
              rack: rack1

Testing (if applicable):
Unit tests for validation, webhook, and hardware matching
Manual E2E testing: create, scale, K8s upgrade, affinity modification, selector↔affinity switching

Documentation added/planned (if applicable):

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@eks-distro-bot eks-distro-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 9, 2026
@codecov
Copy link

codecov bot commented Jan 9, 2026

Codecov Report

❌ Patch coverage is 78.87324% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.63%. Comparing base (dc0984a) to head (3832722).

Files with missing lines Patch % Lines
pkg/providers/tinkerbell/assert.go 57.14% 9 Missing and 12 partials ⚠️
pkg/providers/tinkerbell/reconciler/reconciler.go 50.00% 2 Missing and 2 partials ⚠️
pkg/providers/tinkerbell/upgrade.go 50.00% 2 Missing and 2 partials ⚠️
pkg/providers/tinkerbell/template.go 66.66% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (78.87%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10472      +/-   ##
==========================================
+ Coverage   69.58%   69.63%   +0.05%     
==========================================
  Files         670      670              
  Lines       40699    40767      +68     
==========================================
+ Hits        28320    28389      +69     
+ Misses      10668    10667       -1     
  Partials     1711     1711              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rahulbabu95 rahulbabu95 force-pushed the feat/tink-hardware-affinity branch 2 times, most recently from 58cdf3b to f112e29 Compare January 9, 2026 03:32
@eks-distro-bot eks-distro-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 9, 2026
@rahulbabu95
Copy link
Member Author

Codecov note: Uncovered lines shown (etcd-related in template.go, requirements.Add error paths) are pre-existing gaps appearing in diff context, not new code from this PR. Mocking internal go json to test the error scenario from requirements.Add seems too much and very little gain as happy paths are already covered. New HardwareAffinity validation and selector logic has full test coverage.

@rahulbabu95
Copy link
Member Author

/retest-required

1 similar comment
@rahulbabu95
Copy link
Member Author

/retest-required

@rahulbabu95 rahulbabu95 force-pushed the feat/tink-hardware-affinity branch from f112e29 to 2234564 Compare January 20, 2026 20:10
@rajeshvenkata
Copy link
Member

/lgtm
/approve

@eks-distro-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rajeshvenkata

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

This adds a new HardwareAffinity field that provides advanced hardware selection
using Kubernetes-style label selectors with required and preferred affinity terms.

Key changes:
- Add HardwareAffinity, HardwareAffinityTerm, WeightedHardwareAffinityTerm types
- Support required terms (OR'd together) and preferred terms (weighted scoring)
- Support matchLabels and matchExpressions in label selectors
- Add validation for mutual exclusivity with HardwareSelector
- Add validation for weight range (1-100) and operator types
- Make HardwareSelector and HardwareAffinity mutable (changes affect new machines only)
- Update template generation for control plane, worker, and etcd nodes
- Update hardware validation assertions and reconciler

The HardwareAffinity field is mutually exclusive with the existing HardwareSelector.
Both fields are now mutable - changes only affect new machine provisioning as
existing machines keep their assigned hardware via CAPT's ownership labels.
@rahulbabu95 rahulbabu95 force-pushed the feat/tink-hardware-affinity branch from 2234564 to 3832722 Compare January 21, 2026 20:46
@eks-distro-bot
Copy link
Collaborator

New changes are detected. LGTM label has been removed.

@rahulbabu95
Copy link
Member Author

/test eks-anywhere-presubmit

@aws aws deleted a comment from eks-distro-bot Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved area/docs Documentation documentation size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants