mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
AB#2251 Parallel Azure scale set creation (#318)
* Parallel Azure scale set creation Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
f5fe4fe885
commit
8895693ae2
@ -41,6 +41,7 @@ type Client struct {
|
||||
roleAssignmentsAPI
|
||||
applicationInsightsAPI
|
||||
|
||||
pollFrequency time.Duration
|
||||
adReplicationLagCheckInterval time.Duration
|
||||
adReplicationLagCheckMaxRetries int
|
||||
|
||||
@ -136,6 +137,7 @@ func NewFromDefault(subscriptionID, tenantID string) (*Client, error) {
|
||||
tenantID: tenantID,
|
||||
workers: cloudtypes.Instances{},
|
||||
controlPlanes: cloudtypes.Instances{},
|
||||
pollFrequency: time.Second * 5,
|
||||
adReplicationLagCheckInterval: adReplicationLagCheckInterval,
|
||||
adReplicationLagCheckMaxRetries: adReplicationLagCheckMaxRetries,
|
||||
}, nil
|
||||
|
@ -3,8 +3,9 @@ package client
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
"sync"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
|
||||
@ -26,12 +27,6 @@ func (c *Client) CreateInstances(ctx context.Context, input CreateInstancesInput
|
||||
LoadBalancerBackendAddressPool: azure.BackendAddressPoolWorkerName + "-" + c.uid,
|
||||
}
|
||||
|
||||
if err := c.createScaleSet(ctx, createWorkerInput); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.workerScaleSet = createWorkerInput.Name
|
||||
|
||||
// Create control plane scale set
|
||||
createControlPlaneInput := CreateScaleSetInput{
|
||||
Name: "constellation-scale-set-controlplanes-" + c.uid,
|
||||
@ -45,11 +40,32 @@ func (c *Client) CreateInstances(ctx context.Context, input CreateInstancesInput
|
||||
LoadBalancerBackendAddressPool: azure.BackendAddressPoolControlPlaneName + "-" + c.uid,
|
||||
}
|
||||
|
||||
if err := c.createScaleSet(ctx, createControlPlaneInput); err != nil {
|
||||
return err
|
||||
var wg sync.WaitGroup
|
||||
var controlPlaneErr, workerErr error
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
workerErr = c.createScaleSet(ctx, createWorkerInput)
|
||||
}()
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
controlPlaneErr = c.createScaleSet(ctx, createControlPlaneInput)
|
||||
}()
|
||||
|
||||
wg.Wait()
|
||||
if controlPlaneErr != nil {
|
||||
return fmt.Errorf("creating control-plane scaleset: %w", controlPlaneErr)
|
||||
}
|
||||
if workerErr != nil {
|
||||
return fmt.Errorf("creating worker scaleset: %w", workerErr)
|
||||
}
|
||||
|
||||
// TODO: Remove getInstanceIPs calls after init has been refactored to not use node IPs
|
||||
// Get worker IPs
|
||||
c.workerScaleSet = createWorkerInput.Name
|
||||
instances, err := c.getInstanceIPs(ctx, createWorkerInput.Name, createWorkerInput.Count)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -145,7 +161,7 @@ func (c *Client) createInstanceVM(ctx context.Context, input azure.VMInstance) (
|
||||
}
|
||||
|
||||
vm, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||
Frequency: 30 * time.Second,
|
||||
Frequency: c.pollFrequency,
|
||||
})
|
||||
if err != nil {
|
||||
return cloudtypes.Instance{}, err
|
||||
@ -205,7 +221,7 @@ func (c *Client) createScaleSet(ctx context.Context, input CreateScaleSetInput)
|
||||
}
|
||||
|
||||
_, err = poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||
Frequency: 30 * time.Second,
|
||||
Frequency: c.pollFrequency,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@ -295,7 +311,7 @@ func (c *Client) TerminateResourceGroup(ctx context.Context) error {
|
||||
}
|
||||
|
||||
if _, err = poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||
Frequency: 30 * time.Second,
|
||||
Frequency: c.pollFrequency,
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||
@ -70,7 +69,7 @@ func (c *Client) CreateVirtualNetwork(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
resp, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||
Frequency: 30 * time.Second,
|
||||
Frequency: c.pollFrequency,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@ -113,7 +112,7 @@ func (c *Client) CreateSecurityGroup(ctx context.Context, input NetworkSecurityG
|
||||
return err
|
||||
}
|
||||
pollerResp, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||
Frequency: 30 * time.Second,
|
||||
Frequency: c.pollFrequency,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@ -154,7 +153,7 @@ func (c *Client) createNIC(ctx context.Context, name, publicIPAddressID string)
|
||||
return "", "", err
|
||||
}
|
||||
pollerResp, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||
Frequency: 30 * time.Second,
|
||||
Frequency: c.pollFrequency,
|
||||
})
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
@ -185,7 +184,7 @@ func (c *Client) createPublicIPAddress(ctx context.Context, name string) (*armne
|
||||
return nil, err
|
||||
}
|
||||
pollerResp, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||
Frequency: 30 * time.Second,
|
||||
Frequency: c.pollFrequency,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -230,7 +229,7 @@ func (c *Client) CreateExternalLoadBalancer(ctx context.Context) error {
|
||||
}
|
||||
|
||||
_, err = poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||
Frequency: 30 * time.Second,
|
||||
Frequency: c.pollFrequency,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user