mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-07-24 15:55:17 -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
3 changed files with 35 additions and 18 deletions
|
@ -41,6 +41,7 @@ type Client struct {
|
||||||
roleAssignmentsAPI
|
roleAssignmentsAPI
|
||||||
applicationInsightsAPI
|
applicationInsightsAPI
|
||||||
|
|
||||||
|
pollFrequency time.Duration
|
||||||
adReplicationLagCheckInterval time.Duration
|
adReplicationLagCheckInterval time.Duration
|
||||||
adReplicationLagCheckMaxRetries int
|
adReplicationLagCheckMaxRetries int
|
||||||
|
|
||||||
|
@ -136,6 +137,7 @@ func NewFromDefault(subscriptionID, tenantID string) (*Client, error) {
|
||||||
tenantID: tenantID,
|
tenantID: tenantID,
|
||||||
workers: cloudtypes.Instances{},
|
workers: cloudtypes.Instances{},
|
||||||
controlPlanes: cloudtypes.Instances{},
|
controlPlanes: cloudtypes.Instances{},
|
||||||
|
pollFrequency: time.Second * 5,
|
||||||
adReplicationLagCheckInterval: adReplicationLagCheckInterval,
|
adReplicationLagCheckInterval: adReplicationLagCheckInterval,
|
||||||
adReplicationLagCheckMaxRetries: adReplicationLagCheckMaxRetries,
|
adReplicationLagCheckMaxRetries: adReplicationLagCheckMaxRetries,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
|
@ -3,8 +3,9 @@ package client
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"sync"
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
|
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
|
"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,
|
LoadBalancerBackendAddressPool: azure.BackendAddressPoolWorkerName + "-" + c.uid,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.createScaleSet(ctx, createWorkerInput); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
c.workerScaleSet = createWorkerInput.Name
|
|
||||||
|
|
||||||
// Create control plane scale set
|
// Create control plane scale set
|
||||||
createControlPlaneInput := CreateScaleSetInput{
|
createControlPlaneInput := CreateScaleSetInput{
|
||||||
Name: "constellation-scale-set-controlplanes-" + c.uid,
|
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,
|
LoadBalancerBackendAddressPool: azure.BackendAddressPoolControlPlaneName + "-" + c.uid,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.createScaleSet(ctx, createControlPlaneInput); err != nil {
|
var wg sync.WaitGroup
|
||||||
return err
|
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
|
// Get worker IPs
|
||||||
|
c.workerScaleSet = createWorkerInput.Name
|
||||||
instances, err := c.getInstanceIPs(ctx, createWorkerInput.Name, createWorkerInput.Count)
|
instances, err := c.getInstanceIPs(ctx, createWorkerInput.Name, createWorkerInput.Count)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -145,7 +161,7 @@ func (c *Client) createInstanceVM(ctx context.Context, input azure.VMInstance) (
|
||||||
}
|
}
|
||||||
|
|
||||||
vm, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
vm, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||||
Frequency: 30 * time.Second,
|
Frequency: c.pollFrequency,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cloudtypes.Instance{}, err
|
return cloudtypes.Instance{}, err
|
||||||
|
@ -205,7 +221,7 @@ func (c *Client) createScaleSet(ctx context.Context, input CreateScaleSetInput)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
_, err = poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||||
Frequency: 30 * time.Second,
|
Frequency: c.pollFrequency,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -295,7 +311,7 @@ func (c *Client) TerminateResourceGroup(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
if _, err = poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||||
Frequency: 30 * time.Second,
|
Frequency: c.pollFrequency,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
|
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
|
||||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||||
|
@ -70,7 +69,7 @@ func (c *Client) CreateVirtualNetwork(ctx context.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
resp, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
resp, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||||
Frequency: 30 * time.Second,
|
Frequency: c.pollFrequency,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -113,7 +112,7 @@ func (c *Client) CreateSecurityGroup(ctx context.Context, input NetworkSecurityG
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
pollerResp, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
pollerResp, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||||
Frequency: 30 * time.Second,
|
Frequency: c.pollFrequency,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -154,7 +153,7 @@ func (c *Client) createNIC(ctx context.Context, name, publicIPAddressID string)
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
pollerResp, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
pollerResp, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||||
Frequency: 30 * time.Second,
|
Frequency: c.pollFrequency,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
|
@ -185,7 +184,7 @@ func (c *Client) createPublicIPAddress(ctx context.Context, name string) (*armne
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
pollerResp, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
pollerResp, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||||
Frequency: 30 * time.Second,
|
Frequency: c.pollFrequency,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -230,7 +229,7 @@ func (c *Client) CreateExternalLoadBalancer(ctx context.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
_, err = poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||||
Frequency: 30 * time.Second,
|
Frequency: c.pollFrequency,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue