Skip to content

Commit 3811fa0

Browse files
committed
clusterapi provider interface: PublicGatherEndpoint
Updates the BootstrapHasPublicIP function in the provider interface from returning a simple bool to an enum value in order to account for the different endpoints the installer connects to during bootstrap log gathering in public clusters. The function is renamed to PublicGatherEndpoint. Presently, BootstrapHasPublicIP is only used to determine if the installer should wait for an External IP address to be present in the machine status (in case it is needed for gather) before declaring a machine ready. That code is updated to account for the enum, but the logic is unchanged.
1 parent fe126ca commit 3811fa0

File tree

10 files changed

+48
-30
lines changed

10 files changed

+48
-30
lines changed

pkg/infrastructure/aws/clusterapi/aws.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ type Provider struct {
4646
// Name gives the name of the provider, AWS.
4747
func (*Provider) Name() string { return awstypes.Name }
4848

49-
// BootstrapHasPublicIP indicates that machine ready checks
50-
// should wait for an ExternalIP in the status.
51-
func (*Provider) BootstrapHasPublicIP() bool { return true }
49+
// PublicGatherEndpoint indicates that machine ready checks should wait for an ExternalIP
50+
// in the status and use that when gathering bootstrap log bundles.
51+
func (*Provider) PublicGatherEndpoint() clusterapi.GatherEndpoint { return clusterapi.ExternalIP }
5252

5353
// PreProvision creates the IAM roles used by all nodes in the cluster.
5454
func (*Provider) PreProvision(ctx context.Context, in clusterapi.PreProvisionInput) error {

pkg/infrastructure/azure/azure.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ func (p *Provider) Name() string {
6767
return aztypes.Name
6868
}
6969

70-
// BootstrapHasPublicIP indicates that an ExternalIP is not
71-
// required in the machine ready checks.
72-
func (*Provider) BootstrapHasPublicIP() bool { return false }
70+
// PublicGatherEndpoint indicates that machine ready checks should NOT wait for an ExternalIP
71+
// in the status and should use the API load balancer when gathering bootstrap log bundles.
72+
func (*Provider) PublicGatherEndpoint() clusterapi.GatherEndpoint { return clusterapi.APILoadBalancer }
7373

7474
// PreProvision is called before provisioning using CAPI controllers has begun.
7575
func (p *Provider) PreProvision(ctx context.Context, in clusterapi.PreProvisionInput) error {

pkg/infrastructure/clusterapi/clusterapi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func (i *InfraProvider) Provision(ctx context.Context, dir string, parents asset
303303
{
304304
untilTime := time.Now().Add(provisionTimeout)
305305
timezone, _ := untilTime.Zone()
306-
reqBootstrapPubIP := installConfig.Config.Publish == types.ExternalPublishingStrategy && i.impl.BootstrapHasPublicIP()
306+
reqBootstrapPubIP := installConfig.Config.Publish == types.ExternalPublishingStrategy && i.impl.PublicGatherEndpoint() == ExternalIP
307307
logrus.Infof("Waiting up to %v (until %v %s) for machines %v to provision...", provisionTimeout, untilTime.Format(time.Kitchen), timezone, machineNames)
308308
if err := wait.PollUntilContextTimeout(ctx, 15*time.Second, provisionTimeout, true,
309309
func(ctx context.Context) (bool, error) {

pkg/infrastructure/clusterapi/types.go

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ type Provider interface {
2020
// Name provides the name for the cloud platform.
2121
Name() string
2222

23-
// BootstrapHasPublicIP indicates whether a public IP address
24-
// is expected on the bootstrap node in a public cluster.
25-
// When BootstrapHasPublicIP returns true, the machine ready checks
26-
// wait for an ExternalIP address to be populated in the machine status.
27-
BootstrapHasPublicIP() bool
23+
// PublicGatherEndpoint returns how the cloud platform expects the installer
24+
// to connect to the bootstrap node for log gathering. CAPI providers are not
25+
// consistent in how public IP addresses are represented in the machine status.
26+
// Furthermore, Azure cannot attach a public IP to the bootstrap node, so SSH
27+
// must be performed through the API load balancer.
28+
// When a platform returns ExternalIP, the installer will require an ExternalIP
29+
// to be present in the status, before it declares the machine ready.
30+
PublicGatherEndpoint() GatherEndpoint
2831
}
2932

3033
// PreProvider defines the PreProvision hook, which is called prior to
@@ -126,3 +129,18 @@ type Timeouts interface {
126129
// When waiting for the machines to provision.
127130
ProvisionTimeout() time.Duration
128131
}
132+
133+
// GatherEndpoint represents the valid values for connecting to the bootstrap nude
134+
// in a public cluster to gather logs.
135+
type GatherEndpoint string
136+
137+
const (
138+
// ExternalIP indicates that the machine status will include an ExternalIP that can be used for gather.
139+
ExternalIP GatherEndpoint = "ExternalIP"
140+
141+
// InternalIP indicates that the machine status will only include InternalIPs.
142+
InternalIP GatherEndpoint = "InternalIP"
143+
144+
// APILoadBalancer indicates that gather bootstrap should connect to the API load balancer.
145+
APILoadBalancer GatherEndpoint = "APILoadBalancer"
146+
)

pkg/infrastructure/gcp/clusterapi/clusterapi.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ func (p Provider) Name() string {
3737
return gcptypes.Name
3838
}
3939

40-
// BootstrapHasPublicIP indicates that machine ready checks
41-
// should wait for an ExternalIP in the status.
42-
func (Provider) BootstrapHasPublicIP() bool { return true }
40+
// PublicGatherEndpoint indicates that machine ready checks should wait for an ExternalIP
41+
// in the status and use that when gathering bootstrap log bundles.
42+
func (Provider) PublicGatherEndpoint() clusterapi.GatherEndpoint { return clusterapi.ExternalIP }
4343

4444
// PreProvision is called before provisioning using CAPI controllers has initiated.
4545
// GCP resources that are not created by CAPG (and are required for other stages of the install) are

pkg/infrastructure/ibmcloud/clusterapi/clusterapi.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ func (p Provider) Name() string {
1818
return ibmcloudtypes.Name
1919
}
2020

21-
// BootstrapHasPublicIP indicates that an ExternalIP is not
22-
// required in the machine ready checks.
23-
func (Provider) BootstrapHasPublicIP() bool { return false }
21+
// PublicGatherEndpoint indicates that machine ready checks should NOT wait for an ExternalIP
22+
// in the status when declaring machines ready.
23+
func (Provider) PublicGatherEndpoint() clusterapi.GatherEndpoint { return clusterapi.InternalIP }
2424

2525
// PreProvision creates the IBM Cloud objects required prior to running capibmcloud.
2626
func (p Provider) PreProvision(ctx context.Context, in clusterapi.PreProvisionInput) error {

pkg/infrastructure/nutanix/clusterapi/clusterapi.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ func (p Provider) Name() string {
2626
return nutanixtypes.Name
2727
}
2828

29-
// BootstrapHasPublicIP indicates that an ExternalIP is not
30-
// required in the machine ready checks.
31-
func (Provider) BootstrapHasPublicIP() bool { return false }
29+
// PublicGatherEndpoint indicates that machine ready checks should NOT wait for an ExternalIP
30+
// in the status when declaring machines ready.
31+
func (Provider) PublicGatherEndpoint() infracapi.GatherEndpoint { return infracapi.InternalIP }
3232

3333
// PreProvision creates the resources required prior to running capi nutanix controller.
3434
func (p Provider) PreProvision(ctx context.Context, in infracapi.PreProvisionInput) error {

pkg/infrastructure/openstack/clusterapi/clusterapi.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ func (p Provider) Name() string {
3131
return openstack.Name
3232
}
3333

34-
// BootstrapHasPublicIP indicates that an ExternalIP is not
35-
// required in the machine ready checks.
36-
func (Provider) BootstrapHasPublicIP() bool { return false }
34+
// PublicGatherEndpoint indicates that machine ready checks should NOT wait for an ExternalIP
35+
// in the status when declaring machines ready.
36+
func (Provider) PublicGatherEndpoint() clusterapi.GatherEndpoint { return clusterapi.InternalIP }
3737

3838
var _ clusterapi.PreProvider = Provider{}
3939

pkg/infrastructure/powervs/clusterapi/powervs.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ func (p Provider) Name() string {
3939
return powervstypes.Name
4040
}
4141

42-
// BootstrapHasPublicIP indicates that an ExternalIP is not
43-
// required in the machine ready checks.
44-
func (Provider) BootstrapHasPublicIP() bool { return false }
42+
// PublicGatherEndpoint indicates that machine ready checks should NOT wait for an ExternalIP
43+
// in the status when declaring machines ready.
44+
func (Provider) PublicGatherEndpoint() clusterapi.GatherEndpoint { return clusterapi.InternalIP }
4545

4646
func leftInContext(ctx context.Context) time.Duration {
4747
deadline, ok := ctx.Deadline()

pkg/infrastructure/vsphere/clusterapi/clusterapi.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ func (p Provider) Name() string {
2828
return vsphere.Name
2929
}
3030

31-
// BootstrapHasPublicIP indicates that an ExternalIP is not
32-
// required in the machine ready checks.
33-
func (Provider) BootstrapHasPublicIP() bool { return false }
31+
// PublicGatherEndpoint indicates that machine ready checks should NOT wait for an ExternalIP
32+
// in the status when declaring machines ready.
33+
func (Provider) PublicGatherEndpoint() clusterapi.GatherEndpoint { return clusterapi.InternalIP }
3434

3535
func initializeFoldersAndTemplates(ctx context.Context, cachedImage string, failureDomain vsphere.FailureDomain, session *session.Session, diskType vsphere.DiskType, clusterID, tagID string) error {
3636
finder := session.Finder

0 commit comments

Comments
 (0)