Skip to content

Commit 072de6e

Browse files
Merge pull request #1173 from dtantsur/vmedia-limit
Exclude hosts with virtual media from PROVISIONING_LIMIT
2 parents 212297e + 57a4af3 commit 072de6e

3 files changed

Lines changed: 40 additions & 3 deletions

File tree

docs/configuration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ client certificate SAN validation.
3939
Operator. Default is the number of CPUs, but no less than 2 and no more than 8.
4040

4141
`PROVISIONING_LIMIT` -- The desired maximum number of hosts that could be (de)provisioned
42-
simultaneously by the Operator. The Operator will try to enforce this limit,
42+
simultaneously by the Operator. The limit does not apply to hosts that use
43+
virtual media for provisioning. The Operator will try to enforce this limit,
4344
but overflows could happen in case of slow provisioners and / or higher number of
4445
concurrent reconciles. For such reasons, it is highly recommended to keep
4546
BMO_CONCURRENCY value lower than the requested PROVISIONING_LIMIT. Default is 20.

pkg/provisioner/ironic/ironic.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,6 +1919,16 @@ func (p *ironicProvisioner) IsReady() (result bool, err error) {
19191919
}
19201920

19211921
func (p *ironicProvisioner) HasCapacity() (result bool, err error) {
1922+
bmcAccess, err := p.bmcAccess()
1923+
if err != nil {
1924+
return false, err // shouldn't actually happen so late in the process
1925+
}
1926+
1927+
// If the current host uses virtual media, do not limit it. Virtual
1928+
// media deployments may work without DHCP and can share the same image.
1929+
if bmcAccess.SupportsISOPreprovisioningImage() {
1930+
return true, nil
1931+
}
19221932

19231933
hosts, err := p.loadBusyHosts()
19241934
if err != nil {
@@ -1938,7 +1948,7 @@ func (p *ironicProvisioner) loadBusyHosts() (hosts map[string]struct{}, err erro
19381948

19391949
hosts = make(map[string]struct{})
19401950
pager := nodes.List(p.client, nodes.ListOpts{
1941-
Fields: []string{"uuid,name,provision_state,driver_internal_info,target_provision_state"},
1951+
Fields: []string{"uuid,name,provision_state,boot_interface"},
19421952
})
19431953

19441954
page, err := pager.AllPages()
@@ -1958,7 +1968,11 @@ func (p *ironicProvisioner) loadBusyHosts() (hosts map[string]struct{}, err erro
19581968
nodes.Inspecting, nodes.InspectWait,
19591969
nodes.Deploying, nodes.DeployWait,
19601970
nodes.Deleting:
1961-
hosts[node.Name] = struct{}{}
1971+
// FIXME(dtantsur): this is a bit silly, but we don't have an easy way
1972+
// to reconstruct AccessDetails from a DriverInfo.
1973+
if !strings.Contains(node.BootInterface, "virtual-media") {
1974+
hosts[node.Name] = struct{}{}
1975+
}
19621976
}
19631977
}
19641978

pkg/provisioner/ironic/provisioncapacity_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ func TestHasCapacity(t *testing.T) {
2424
provisioningLimit int
2525
nodeStates []nodes.ProvisionState
2626
hostName string
27+
bootInterface string
28+
bmcAddress string
2729

2830
expectedHasCapacity bool
2931
expectedError string
@@ -55,6 +57,22 @@ func TestHasCapacity(t *testing.T) {
5557
provisioningLimit: 1,
5658
nodeStates: []nodes.ProvisionState{nodes.Active, nodes.AdoptFail, nodes.Adopting, nodes.Available, nodes.CleanFail},
5759

60+
expectedHasCapacity: true,
61+
},
62+
{
63+
name: "enough-capacity-due-virtual-media",
64+
provisioningLimit: 1,
65+
nodeStates: states,
66+
bmcAddress: "redfish-virtualmedia://example.com/redfish/v1/Systems/1",
67+
68+
expectedHasCapacity: true,
69+
},
70+
{
71+
name: "enough-capacity-due-other-virtual-media",
72+
provisioningLimit: 1,
73+
nodeStates: states,
74+
bootInterface: "redfish-virtual-media",
75+
5876
expectedHasCapacity: true,
5977
},
6078
}
@@ -67,6 +85,7 @@ func TestHasCapacity(t *testing.T) {
6785
allNodes = append(allNodes, nodes.Node{
6886
Name: fmt.Sprintf("myns%snode-%d", nameSeparator, n),
6987
ProvisionState: string(state),
88+
BootInterface: tc.bootInterface,
7089
})
7190
}
7291

@@ -78,6 +97,9 @@ func TestHasCapacity(t *testing.T) {
7897

7998
host := makeHost()
8099
host.Name = tc.hostName
100+
if tc.bmcAddress != "" {
101+
host.Spec.BMC.Address = tc.bmcAddress
102+
}
81103

82104
auth := clients.AuthConfig{Type: clients.NoAuth}
83105

0 commit comments

Comments
 (0)