fix: wait for network and retry in platform get config funcs
Wait for the network before trying to access the metadata service. Retry the calls when appropriate (most platforms use `download.Download` function which does proper retries). Co-authored-by: Noel Georgi <git@frezbo.dev> Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
This commit is contained in:
parent
3d7566ec74
commit
dcbcf5a93c
@ -201,7 +201,7 @@ RUN gofumpt -w ./
|
||||
|
||||
FROM go-generate AS gen-proto-go
|
||||
WORKDIR /src/
|
||||
RUN structprotogen github.com/siderolabs/talos/pkg/machinery/... /api/resource/definitions/
|
||||
RUN --mount=type=cache,target=/.cache structprotogen github.com/siderolabs/talos/pkg/machinery/... /api/resource/definitions/
|
||||
|
||||
# compile protobuf service definitions
|
||||
FROM build AS generate-build
|
||||
|
@ -20,9 +20,11 @@ import (
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/cosi-project/runtime/pkg/state"
|
||||
"github.com/siderolabs/go-procfs/procfs"
|
||||
"github.com/siderolabs/go-retry/retry"
|
||||
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/errors"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils"
|
||||
"github.com/siderolabs/talos/pkg/machinery/resources/network"
|
||||
runtimeres "github.com/siderolabs/talos/pkg/machinery/resources/runtime"
|
||||
)
|
||||
@ -101,17 +103,15 @@ func (a *AWS) Name() string {
|
||||
|
||||
// Configuration implements the runtime.Platform interface.
|
||||
func (a *AWS) Configuration(ctx context.Context, r state.State) ([]byte, error) {
|
||||
if err := netutils.Wait(ctx, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Printf("fetching machine config from AWS")
|
||||
|
||||
userdata, err := a.metadataClient.GetUserDataWithContext(ctx)
|
||||
userdata, err := netutils.RetryFetch(ctx, a.fetchConfiguration)
|
||||
if err != nil {
|
||||
if awsErr, ok := err.(awserr.RequestFailure); ok {
|
||||
if awsErr.StatusCode() == http.StatusNotFound {
|
||||
return nil, errors.ErrNoConfigSource
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("failed to fetch EC2 userdata: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if strings.TrimSpace(userdata) == "" {
|
||||
@ -121,6 +121,21 @@ func (a *AWS) Configuration(ctx context.Context, r state.State) ([]byte, error)
|
||||
return []byte(userdata), nil
|
||||
}
|
||||
|
||||
func (a *AWS) fetchConfiguration(ctx context.Context) (string, error) {
|
||||
userdata, err := a.metadataClient.GetUserDataWithContext(ctx)
|
||||
if err != nil {
|
||||
if awsErr, ok := err.(awserr.RequestFailure); ok {
|
||||
if awsErr.StatusCode() == http.StatusNotFound {
|
||||
return "", errors.ErrNoConfigSource
|
||||
}
|
||||
}
|
||||
|
||||
return "", retry.ExpectedErrorf("failed to fetch EC2 userdata: %w", err)
|
||||
}
|
||||
|
||||
return userdata, nil
|
||||
}
|
||||
|
||||
// Mode implements the runtime.Platform interface.
|
||||
func (a *AWS) Mode() runtime.Mode {
|
||||
return runtime.ModeCloud
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/errors"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils"
|
||||
"github.com/siderolabs/talos/pkg/download"
|
||||
"github.com/siderolabs/talos/pkg/machinery/resources/network"
|
||||
runtimeres "github.com/siderolabs/talos/pkg/machinery/resources/runtime"
|
||||
@ -169,8 +170,12 @@ func (a *Azure) ParseLoadBalancerIP(lbConfig LoadBalancerMetadata, exIP []netip.
|
||||
// Configuration implements the platform.Platform interface.
|
||||
func (a *Azure) Configuration(ctx context.Context, r state.State) ([]byte, error) {
|
||||
defer func() {
|
||||
if err := netutils.Wait(ctx, r); err != nil {
|
||||
log.Printf("failed to wait for network, err: %s", err)
|
||||
}
|
||||
|
||||
if err := linuxAgent(ctx); err != nil {
|
||||
log.Printf("failed to update instance status, err: %s", err.Error())
|
||||
log.Printf("failed to update instance status, err: %s", err)
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -17,7 +17,8 @@ import (
|
||||
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/errors"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/utils"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/address"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils"
|
||||
"github.com/siderolabs/talos/pkg/download"
|
||||
"github.com/siderolabs/talos/pkg/machinery/nethelpers"
|
||||
"github.com/siderolabs/talos/pkg/machinery/resources/network"
|
||||
@ -75,7 +76,7 @@ func (d *DigitalOcean) ParseMetadata(metadata *MetadataConfig) (*runtime.Platfor
|
||||
|
||||
for _, iface := range metadata.Interfaces["public"] {
|
||||
if iface.IPv4 != nil {
|
||||
ifAddr, err := utils.IPPrefixFrom(iface.IPv4.IPAddress, iface.IPv4.Netmask)
|
||||
ifAddr, err := address.IPPrefixFrom(iface.IPv4.IPAddress, iface.IPv4.Netmask)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse ip address: %w", err)
|
||||
}
|
||||
@ -131,7 +132,7 @@ func (d *DigitalOcean) ParseMetadata(metadata *MetadataConfig) (*runtime.Platfor
|
||||
}
|
||||
|
||||
if iface.IPv6 != nil {
|
||||
ifAddr, err := utils.IPPrefixFrom(iface.IPv6.IPAddress, strconv.Itoa(iface.IPv6.CIDR))
|
||||
ifAddr, err := address.IPPrefixFrom(iface.IPv6.IPAddress, strconv.Itoa(iface.IPv6.CIDR))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse ip address: %w", err)
|
||||
}
|
||||
@ -172,7 +173,7 @@ func (d *DigitalOcean) ParseMetadata(metadata *MetadataConfig) (*runtime.Platfor
|
||||
}
|
||||
|
||||
if iface.AnchorIPv4 != nil {
|
||||
ifAddr, err := utils.IPPrefixFrom(iface.AnchorIPv4.IPAddress, iface.AnchorIPv4.Netmask)
|
||||
ifAddr, err := address.IPPrefixFrom(iface.AnchorIPv4.IPAddress, iface.AnchorIPv4.Netmask)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse ip address: %w", err)
|
||||
}
|
||||
@ -200,7 +201,7 @@ func (d *DigitalOcean) ParseMetadata(metadata *MetadataConfig) (*runtime.Platfor
|
||||
})
|
||||
|
||||
if iface.IPv4 != nil {
|
||||
ifAddr, err := utils.IPPrefixFrom(iface.IPv4.IPAddress, iface.IPv4.Netmask)
|
||||
ifAddr, err := address.IPPrefixFrom(iface.IPv4.IPAddress, iface.IPv4.Netmask)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse ip address: %w", err)
|
||||
}
|
||||
@ -237,6 +238,10 @@ func (d *DigitalOcean) ParseMetadata(metadata *MetadataConfig) (*runtime.Platfor
|
||||
|
||||
// Configuration implements the platform.Platform interface.
|
||||
func (d *DigitalOcean) Configuration(ctx context.Context, r state.State) ([]byte, error) {
|
||||
if err := netutils.Wait(ctx, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Printf("fetching machine config from: %q", DigitalOceanUserDataEndpoint)
|
||||
|
||||
return download.Download(ctx, DigitalOceanUserDataEndpoint,
|
||||
|
@ -26,6 +26,7 @@ import (
|
||||
networkctrl "github.com/siderolabs/talos/internal/app/machined/pkg/controllers/network"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/errors"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils"
|
||||
"github.com/siderolabs/talos/pkg/download"
|
||||
"github.com/siderolabs/talos/pkg/machinery/constants"
|
||||
"github.com/siderolabs/talos/pkg/machinery/nethelpers"
|
||||
@ -88,6 +89,10 @@ func (p *EquinixMetal) Name() string {
|
||||
|
||||
// Configuration implements the platform.Platform interface.
|
||||
func (p *EquinixMetal) Configuration(ctx context.Context, r state.State) ([]byte, error) {
|
||||
if err := netutils.Wait(ctx, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Printf("fetching machine config from: %q", EquinixMetalUserDataEndpoint)
|
||||
|
||||
return download.Download(ctx, EquinixMetalUserDataEndpoint,
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/errors"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils"
|
||||
"github.com/siderolabs/talos/pkg/download"
|
||||
"github.com/siderolabs/talos/pkg/machinery/resources/network"
|
||||
runtimeres "github.com/siderolabs/talos/pkg/machinery/resources/runtime"
|
||||
@ -67,6 +68,10 @@ func (e *Exoscale) Name() string {
|
||||
|
||||
// Configuration implements the runtime.Platform interface.
|
||||
func (e *Exoscale) Configuration(ctx context.Context, r state.State) ([]byte, error) {
|
||||
if err := netutils.Wait(ctx, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Printf("fetching machine config from %q", ExoscaleUserDataEndpoint)
|
||||
|
||||
return download.Download(ctx, ExoscaleUserDataEndpoint,
|
||||
|
@ -16,9 +16,11 @@ import (
|
||||
"cloud.google.com/go/compute/metadata"
|
||||
"github.com/cosi-project/runtime/pkg/state"
|
||||
"github.com/siderolabs/go-procfs/procfs"
|
||||
"github.com/siderolabs/go-retry/retry"
|
||||
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/errors"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils"
|
||||
"github.com/siderolabs/talos/pkg/machinery/nethelpers"
|
||||
"github.com/siderolabs/talos/pkg/machinery/resources/network"
|
||||
runtimeres "github.com/siderolabs/talos/pkg/machinery/resources/runtime"
|
||||
@ -158,12 +160,14 @@ func (g *GCP) ParseMetadata(metadata *MetadataConfig, interfaces []NetworkInterf
|
||||
|
||||
// Configuration implements the platform.Platform interface.
|
||||
func (g *GCP) Configuration(ctx context.Context, r state.State) ([]byte, error) {
|
||||
userdata, err := metadata.InstanceAttributeValue("user-data")
|
||||
if err != nil {
|
||||
if _, ok := err.(metadata.NotDefinedError); ok {
|
||||
return nil, errors.ErrNoConfigSource
|
||||
}
|
||||
if err := netutils.Wait(ctx, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Printf("fetching machine config from AWS")
|
||||
|
||||
userdata, err := netutils.RetryFetch(ctx, g.fetchConfiguration)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -174,6 +178,19 @@ func (g *GCP) Configuration(ctx context.Context, r state.State) ([]byte, error)
|
||||
return []byte(userdata), nil
|
||||
}
|
||||
|
||||
func (g *GCP) fetchConfiguration(_ context.Context) (string, error) {
|
||||
userdata, err := metadata.InstanceAttributeValue("user-data")
|
||||
if err != nil {
|
||||
if _, ok := err.(metadata.NotDefinedError); ok {
|
||||
return "", errors.ErrNoConfigSource
|
||||
}
|
||||
|
||||
return "", retry.ExpectedError(err)
|
||||
}
|
||||
|
||||
return userdata, nil
|
||||
}
|
||||
|
||||
// Mode implements the platform.Platform interface.
|
||||
func (g *GCP) Mode() runtime.Mode {
|
||||
return runtime.ModeCloud
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/errors"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils"
|
||||
"github.com/siderolabs/talos/pkg/download"
|
||||
"github.com/siderolabs/talos/pkg/machinery/nethelpers"
|
||||
"github.com/siderolabs/talos/pkg/machinery/resources/network"
|
||||
@ -147,6 +148,10 @@ func (h *Hcloud) ParseMetadata(unmarshalledNetworkConfig *NetworkConfig, metadat
|
||||
|
||||
// Configuration implements the runtime.Platform interface.
|
||||
func (h *Hcloud) Configuration(ctx context.Context, r state.State) ([]byte, error) {
|
||||
if err := netutils.Wait(ctx, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Printf("fetching machine config from: %q", HCloudUserDataEndpoint)
|
||||
|
||||
return download.Download(ctx, HCloudUserDataEndpoint,
|
||||
|
@ -2,8 +2,8 @@
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
// Package utils provides utility functions for the platform package.
|
||||
package utils
|
||||
// Package address provides utility functions for address parsing.
|
||||
package address
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -0,0 +1,54 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
// Package netutils provides network-related helpers for platform implementation.
|
||||
package netutils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/cosi-project/runtime/pkg/state"
|
||||
"github.com/siderolabs/go-retry/retry"
|
||||
|
||||
"github.com/siderolabs/talos/pkg/machinery/constants"
|
||||
"github.com/siderolabs/talos/pkg/machinery/resources/network"
|
||||
)
|
||||
|
||||
// Wait for the network to be ready to interact with platform metadata services.
|
||||
func Wait(ctx context.Context, r state.State) error {
|
||||
log.Printf("waiting for network to be ready")
|
||||
|
||||
if err := network.NewReadyCondition(r, network.AddressReady).Wait(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RetryFetch retries fetching from metadata service.
|
||||
func RetryFetch(ctx context.Context, f func(ctx context.Context) (string, error)) (string, error) {
|
||||
var (
|
||||
userdata string
|
||||
err error
|
||||
)
|
||||
|
||||
err = retry.Exponential(
|
||||
constants.ConfigLoadTimeout,
|
||||
retry.WithUnits(time.Second),
|
||||
retry.WithJitter(time.Second),
|
||||
retry.WithErrorLogging(true),
|
||||
).RetryWithContext(
|
||||
ctx, func(ctx context.Context) error {
|
||||
userdata, err = f(ctx)
|
||||
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return userdata, err
|
||||
}
|
@ -20,6 +20,7 @@ import (
|
||||
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/errors"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils"
|
||||
"github.com/siderolabs/talos/pkg/download"
|
||||
"github.com/siderolabs/talos/pkg/machinery/constants"
|
||||
runtimeres "github.com/siderolabs/talos/pkg/machinery/resources/runtime"
|
||||
@ -63,6 +64,10 @@ func (m *Metal) Configuration(ctx context.Context, r state.State) ([]byte, error
|
||||
case constants.MetalConfigISOLabel:
|
||||
return readConfigFromISO()
|
||||
default:
|
||||
if err := netutils.Wait(ctx, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return download.Download(ctx, *option, download.WithEndpointFunc(getURL))
|
||||
}
|
||||
}
|
||||
|
@ -69,6 +69,10 @@ func setup(ctx context.Context, t *testing.T, st state.State, mockUUID, mockSeri
|
||||
linkStatusSpec.TypedSpec().HardwareAddr = nethelpers.HardwareAddr(parsedMockMAC)
|
||||
linkStatusSpec.TypedSpec().LinkState = true
|
||||
assert.NoError(t, createOrUpdate(ctx, st, linkStatusSpec))
|
||||
|
||||
netStatus := network.NewStatus(network.NamespaceName, network.StatusID)
|
||||
netStatus.TypedSpec().AddressReady = true
|
||||
assert.NoError(t, createOrUpdate(ctx, st, netStatus))
|
||||
}
|
||||
|
||||
func TestPopulateURLParameters(t *testing.T) {
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/cosi-project/runtime/pkg/state"
|
||||
"github.com/siderolabs/go-blockdevice/blockdevice/filesystem"
|
||||
"github.com/siderolabs/go-blockdevice/blockdevice/probe"
|
||||
"golang.org/x/sys/unix"
|
||||
@ -23,6 +24,7 @@ import (
|
||||
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/errors"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils"
|
||||
"github.com/siderolabs/talos/internal/pkg/smbios"
|
||||
"github.com/siderolabs/talos/pkg/download"
|
||||
"github.com/siderolabs/talos/pkg/machinery/nethelpers"
|
||||
@ -100,9 +102,13 @@ type MetadataConfig struct {
|
||||
Zone string `yaml:"zone,omitempty"`
|
||||
}
|
||||
|
||||
func (n *Nocloud) configFromNetwork(ctx context.Context, metaBaseURL string) (metaConfig []byte, networkConfig []byte, machineConfig []byte, err error) {
|
||||
func (n *Nocloud) configFromNetwork(ctx context.Context, metaBaseURL string, r state.State) (metaConfig []byte, networkConfig []byte, machineConfig []byte, err error) {
|
||||
log.Printf("fetching meta config from: %q", metaBaseURL+configMetaDataPath)
|
||||
|
||||
if err = netutils.Wait(ctx, r); err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
metaConfig, err = download.Download(ctx, metaBaseURL+configMetaDataPath)
|
||||
if err != nil {
|
||||
metaConfig = nil
|
||||
@ -184,7 +190,7 @@ func (n *Nocloud) configFromCD() (metaConfig []byte, networkConfig []byte, machi
|
||||
}
|
||||
|
||||
//nolint:gocyclo
|
||||
func (n *Nocloud) acquireConfig(ctx context.Context) (metadataConfigDl, metadataNetworkConfigDl, machineConfigDl []byte, metadata *MetadataConfig, err error) {
|
||||
func (n *Nocloud) acquireConfig(ctx context.Context, r state.State) (metadataConfigDl, metadataNetworkConfigDl, machineConfigDl []byte, metadata *MetadataConfig, err error) {
|
||||
s, err := smbios.GetSMBIOSInfo()
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, err
|
||||
@ -222,7 +228,7 @@ func (n *Nocloud) acquireConfig(ctx context.Context) (metadataConfigDl, metadata
|
||||
}
|
||||
|
||||
if networkSource && metaBaseURL != "" {
|
||||
metadataConfigDl, metadataNetworkConfigDl, machineConfigDl, err = n.configFromNetwork(ctx, metaBaseURL)
|
||||
metadataConfigDl, metadataNetworkConfigDl, machineConfigDl, err = n.configFromNetwork(ctx, metaBaseURL, r)
|
||||
} else {
|
||||
metadataConfigDl, metadataNetworkConfigDl, machineConfigDl, err = n.configFromCD()
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ func (n *Nocloud) ParseMetadata(unmarshalledNetworkConfig *NetworkConfig, metada
|
||||
|
||||
// Configuration implements the runtime.Platform interface.
|
||||
func (n *Nocloud) Configuration(ctx context.Context, r state.State) ([]byte, error) {
|
||||
_, _, machineConfigDl, _, err := n.acquireConfig(ctx) //nolint:dogsled
|
||||
_, _, machineConfigDl, _, err := n.acquireConfig(ctx, r) //nolint:dogsled
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -99,8 +99,8 @@ func (n *Nocloud) KernelArgs() procfs.Parameters {
|
||||
// NetworkConfiguration implements the runtime.Platform interface.
|
||||
//
|
||||
//nolint:gocyclo
|
||||
func (n *Nocloud) NetworkConfiguration(ctx context.Context, _ state.State, ch chan<- *runtime.PlatformNetworkConfig) error {
|
||||
metadataConfigDl, metadataNetworkConfigDl, _, metadata, err := n.acquireConfig(ctx)
|
||||
func (n *Nocloud) NetworkConfiguration(ctx context.Context, r state.State, ch chan<- *runtime.PlatformNetworkConfig) error {
|
||||
metadataConfigDl, metadataNetworkConfigDl, _, metadata, err := n.acquireConfig(ctx, r)
|
||||
if stderrors.Is(err, errors.ErrNoConfigSource) {
|
||||
err = nil
|
||||
}
|
||||
|
@ -23,7 +23,8 @@ import (
|
||||
networkadapter "github.com/siderolabs/talos/internal/app/machined/pkg/adapters/network"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/errors"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/utils"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/address"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils"
|
||||
"github.com/siderolabs/talos/pkg/machinery/nethelpers"
|
||||
"github.com/siderolabs/talos/pkg/machinery/resources/network"
|
||||
runtimeres "github.com/siderolabs/talos/pkg/machinery/resources/runtime"
|
||||
@ -224,7 +225,7 @@ func (o *Openstack) ParseMetadata(
|
||||
}
|
||||
|
||||
if ntwrk.Address != "" {
|
||||
ipPrefix, err := utils.IPPrefixFrom(ntwrk.Address, ntwrk.Netmask)
|
||||
ipPrefix, err := address.IPPrefixFrom(ntwrk.Address, ntwrk.Netmask)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse ip address: %w", err)
|
||||
}
|
||||
@ -274,7 +275,7 @@ func (o *Openstack) ParseMetadata(
|
||||
return nil, fmt.Errorf("failed to parse route gateway: %w", err)
|
||||
}
|
||||
|
||||
dest, err := utils.IPPrefixFrom(route.Network, route.Netmask)
|
||||
dest, err := address.IPPrefixFrom(route.Network, route.Netmask)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse route network: %w", err)
|
||||
}
|
||||
@ -318,6 +319,10 @@ func (o *Openstack) ParseMetadata(
|
||||
func (o *Openstack) Configuration(ctx context.Context, r state.State) (machineConfig []byte, err error) {
|
||||
_, _, machineConfig, err = o.configFromCD()
|
||||
if err != nil {
|
||||
if err = netutils.Wait(ctx, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, _, machineConfig, err = o.configFromNetwork(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -19,6 +19,7 @@ import (
|
||||
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/errors"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils"
|
||||
"github.com/siderolabs/talos/pkg/download"
|
||||
"github.com/siderolabs/talos/pkg/machinery/resources/network"
|
||||
runtimeres "github.com/siderolabs/talos/pkg/machinery/resources/runtime"
|
||||
@ -107,6 +108,10 @@ func (o *Oracle) ParseMetadata(interfaceAddresses []NetworkConfig, metadata *Met
|
||||
|
||||
// Configuration implements the platform.Platform interface.
|
||||
func (o *Oracle) Configuration(ctx context.Context, r state.State) ([]byte, error) {
|
||||
if err := netutils.Wait(ctx, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Printf("fetching machine config from: %q", OracleUserDataEndpoint)
|
||||
|
||||
machineConfigDl, err := download.Download(ctx, OracleUserDataEndpoint,
|
||||
|
@ -19,6 +19,7 @@ import (
|
||||
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/errors"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils"
|
||||
"github.com/siderolabs/talos/pkg/download"
|
||||
"github.com/siderolabs/talos/pkg/machinery/nethelpers"
|
||||
"github.com/siderolabs/talos/pkg/machinery/resources/network"
|
||||
@ -162,6 +163,10 @@ func (s *Scaleway) ParseMetadata(metadata *instance.Metadata) (*runtime.Platform
|
||||
//
|
||||
//nolint:stylecheck
|
||||
func (s *Scaleway) Configuration(ctx context.Context, r state.State) ([]byte, error) {
|
||||
if err := netutils.Wait(ctx, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Printf("fetching machine config from %q", ScalewayUserDataEndpoint)
|
||||
|
||||
return download.Download(ctx, ScalewayUserDataEndpoint,
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/errors"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils"
|
||||
"github.com/siderolabs/talos/pkg/download"
|
||||
"github.com/siderolabs/talos/pkg/machinery/nethelpers"
|
||||
"github.com/siderolabs/talos/pkg/machinery/resources/network"
|
||||
@ -176,6 +177,10 @@ func (u *UpCloud) ParseMetadata(metadata *MetadataConfig) (*runtime.PlatformNetw
|
||||
|
||||
// Configuration implements the runtime.Platform interface.
|
||||
func (u *UpCloud) Configuration(ctx context.Context, r state.State) ([]byte, error) {
|
||||
if err := netutils.Wait(ctx, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Printf("fetching machine config from: %q", UpCloudUserDataEndpoint)
|
||||
|
||||
return download.Download(ctx, UpCloudUserDataEndpoint,
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/errors"
|
||||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils"
|
||||
"github.com/siderolabs/talos/pkg/download"
|
||||
"github.com/siderolabs/talos/pkg/machinery/nethelpers"
|
||||
"github.com/siderolabs/talos/pkg/machinery/resources/network"
|
||||
@ -157,6 +158,10 @@ func (v *Vultr) ParseMetadata(metadata *metadata.MetaData) (*runtime.PlatformNet
|
||||
//
|
||||
//nolint:stylecheck
|
||||
func (v *Vultr) Configuration(ctx context.Context, r state.State) ([]byte, error) {
|
||||
if err := netutils.Wait(ctx, r); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Printf("fetching machine config from: %q", VultrUserDataEndpoint)
|
||||
|
||||
return download.Download(ctx, VultrUserDataEndpoint,
|
||||
|
@ -448,7 +448,7 @@ func LoadConfig(seq runtime.Sequence, data interface{}) (runtime.TaskExecutionFu
|
||||
download := func() error {
|
||||
var b []byte
|
||||
|
||||
fetchCtx, ctxCancel := context.WithTimeout(ctx, 70*time.Second)
|
||||
fetchCtx, ctxCancel := context.WithTimeout(ctx, constants.ConfigLoadTimeout)
|
||||
defer ctxCancel()
|
||||
|
||||
b, e := fetchConfig(fetchCtx, r)
|
||||
|
@ -582,6 +582,9 @@ const (
|
||||
// DefaultDNSDomain is the default DNS domain.
|
||||
DefaultDNSDomain = "cluster.local"
|
||||
|
||||
// ConfigLoadTimeout is the timeout to wait for the config to be loaded from an external source.
|
||||
ConfigLoadTimeout = 3 * time.Minute
|
||||
|
||||
// BootTimeout is the timeout to run all services.
|
||||
BootTimeout = 70 * time.Minute
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user