Skip to content

Commit 35954c5

Browse files
committed
Request microversion 1.109 for health API support
The Health field on Ironic nodes requires API microversion 1.109 or later. Without requesting this version, Ironic omits the field from responses and health is permanently reported as Unknown. - Add HasHealthAPI() feature check for microversion >= 1.109 - Update ChooseMicroversion() to negotiate 1.109 when available - Guard GetHealth() to skip the getNode() call when Ironic is too old - Suppress ErrNeedsRegistration log noise in GetHealth() since it is expected before host registration Signed-off-by: Jacob Anders <jacob-anders-dev@proton.me> Assisted-by: Claude (claude-4.6-opus-high-thinking) (cherry picked from commit 751c99a58201f39ba937ff19cfe79b8d5f0718ac)
1 parent 3bed435 commit 35954c5

4 files changed

Lines changed: 36 additions & 8 deletions

File tree

pkg/provisioner/ironic/clients/features.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ func (af AvailableFeatures) Log(logger logr.Logger) {
4545
"maxVersion", fmt.Sprintf("1.%d", af.MaxVersion),
4646
"chosenVersion", af.ChooseMicroversion(),
4747
"virtualMediaGET", af.HasVirtualMediaGetAPI(),
48-
"disablePowerOff", af.HasDisablePowerOff())
48+
"disablePowerOff", af.HasDisablePowerOff(),
49+
"healthAPI", af.HasHealthAPI())
4950
}
5051

5152
func (af AvailableFeatures) HasVirtualMediaGetAPI() bool {
@@ -56,7 +57,15 @@ func (af AvailableFeatures) HasDisablePowerOff() bool {
5657
return af.MaxVersion >= 95 //nolint:mnd
5758
}
5859

60+
func (af AvailableFeatures) HasHealthAPI() bool {
61+
return af.MaxVersion >= 109 //nolint:mnd
62+
}
63+
5964
func (af AvailableFeatures) ChooseMicroversion() string {
65+
if af.HasHealthAPI() {
66+
return "1.109"
67+
}
68+
6069
if af.HasDisablePowerOff() {
6170
return "1.95"
6271
}

pkg/provisioner/ironic/clients/features_test.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
)
77

88
func TestAvailableFeatures_ChooseMicroversion(t *testing.T) {
9-
microVersion := "1.95"
109
type fields struct {
1110
MaxVersion int
1211
}
@@ -16,25 +15,39 @@ func TestAvailableFeatures_ChooseMicroversion(t *testing.T) {
1615
want string
1716
}{
1817
{
19-
name: fmt.Sprintf("MaxVersion < %d return microversion %s", 89, baselineVersionString),
18+
name: fmt.Sprintf("MaxVersion < %d return microversion %s", baseline, baselineVersionString),
2019
feature: fields{
2120
MaxVersion: 50,
2221
},
2322
want: baselineVersionString,
2423
},
2524
{
26-
name: fmt.Sprintf("MaxVersion = %d return %s", 89, microVersion),
25+
name: "MaxVersion = 95 return 1.95",
2726
feature: fields{
2827
MaxVersion: 95,
2928
},
30-
want: microVersion,
29+
want: "1.95",
3130
},
3231
{
33-
name: fmt.Sprintf("MaxVersion > %d return %s", 89, microVersion),
32+
name: "MaxVersion between 95 and 109 return 1.95",
3433
feature: fields{
3534
MaxVersion: 100,
3635
},
37-
want: microVersion,
36+
want: "1.95",
37+
},
38+
{
39+
name: "MaxVersion = 109 return 1.109",
40+
feature: fields{
41+
MaxVersion: 109,
42+
},
43+
want: "1.109",
44+
},
45+
{
46+
name: "MaxVersion > 109 return 1.109",
47+
feature: fields{
48+
MaxVersion: 120,
49+
},
50+
want: "1.109",
3851
},
3952
}
4053
for _, tt := range tests {

pkg/provisioner/ironic/ironic.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2002,9 +2002,14 @@ func (p *ironicProvisioner) HasPowerFailure(ctx context.Context) bool {
20022002
// request to Ironic on every reconcile. Consider passing the node object through
20032003
// computeConditions or caching it per reconcile cycle to avoid redundant calls.
20042004
func (p *ironicProvisioner) GetHealth(ctx context.Context) string {
2005+
if !p.availableFeatures.HasHealthAPI() {
2006+
return ""
2007+
}
20052008
node, err := p.getNode(ctx)
20062009
if err != nil {
2007-
p.log.Error(err, "ignored error while checking health status")
2010+
if !errors.Is(err, provisioner.ErrNeedsRegistration) {
2011+
p.log.Error(err, "ignored error while checking health status")
2012+
}
20082013
return ""
20092014
}
20102015
return node.Health

pkg/provisioner/ironic/power_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ func TestGetHealth(t *testing.T) {
519519
auth := clients.AuthConfig{Type: clients.NoAuth}
520520
prov, err := newProvisionerWithSettings(host, bmc.Credentials{}, nullEventPublisher, tc.ironic.Endpoint(), auth)
521521
require.NoError(t, err)
522+
prov.availableFeatures = clients.AvailableFeatures{MaxVersion: 109}
522523

523524
health := prov.GetHealth(t.Context())
524525
assert.Equal(t, tc.expectedHealth, health)

0 commit comments

Comments
 (0)