diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/oracle/metadata.go b/internal/app/machined/pkg/runtime/v1alpha1/platform/oracle/metadata.go index 299345d470..1842227e6c 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/oracle/metadata.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/oracle/metadata.go @@ -21,6 +21,9 @@ const ( OracleUserDataEndpoint = "http://169.254.169.254/opc/v2/instance/metadata/user_data" // OracleNetworkEndpoint is the local network metadata endpoint inside of Oracle Cloud. OracleNetworkEndpoint = "http://169.254.169.254/opc/v2/vnics/" + + oracleResolverServer = "169.254.169.254" + oracleTimeServer = "169.254.169.254" ) // MetadataConfig represents a metadata Oracle instance. diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/oracle/oracle.go b/internal/app/machined/pkg/runtime/v1alpha1/platform/oracle/oracle.go index e10dc3dc89..af7e388421 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/oracle/oracle.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/oracle/oracle.go @@ -11,6 +11,7 @@ import ( "encoding/json" "fmt" "log" + "net/netip" "strings" "github.com/cosi-project/runtime/pkg/state" @@ -73,17 +74,29 @@ func (o *Oracle) ParseMetadata(interfaceAddresses []NetworkConfig, metadata *Met } } + dns, _ := netip.ParseAddr(oracleResolverServer) //nolint:errcheck + + networkConfig.Resolvers = append(networkConfig.Resolvers, network.ResolverSpecSpec{ + DNSServers: []netip.Addr{dns}, + ConfigLayer: network.ConfigPlatform, + }) + + networkConfig.TimeServers = append(networkConfig.TimeServers, network.TimeServerSpecSpec{ + NTPServers: []string{oracleTimeServer}, + ConfigLayer: network.ConfigPlatform, + }) + zone := metadata.AvailabilityDomain if idx := strings.LastIndex(zone, ":"); idx != -1 { - zone = zone[:idx] + zone = zone[idx+1:] } networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{ Platform: o.Name(), Hostname: metadata.Hostname, - Region: strings.ToLower(metadata.Region), - Zone: strings.ToLower(zone), + Region: metadata.Region, + Zone: zone, InstanceType: metadata.Shape, InstanceID: metadata.ID, ProviderID: fmt.Sprintf("oci://%s", metadata.ID), diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/oracle/testdata/expected.yaml b/internal/app/machined/pkg/runtime/v1alpha1/platform/oracle/testdata/expected.yaml index 7ab777957e..5ba4cff851 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/oracle/testdata/expected.yaml +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/oracle/testdata/expected.yaml @@ -5,8 +5,14 @@ hostnames: - hostname: talos domainname: "" layer: platform -resolvers: [] -timeServers: [] +resolvers: + - dnsServers: + - 169.254.169.254 + layer: platform +timeServers: + - timeServers: + - 169.254.169.254 + layer: platform operators: - operator: dhcp6 linkName: eth0 @@ -19,7 +25,7 @@ metadata: platform: oracle hostname: talos region: phx - zone: emir + zone: PHX-AD-1 instanceType: VM.Standard.E3.Flex instanceId: ocid1.instance.oc1.phx.exampleuniqueID providerId: oci://ocid1.instance.oc1.phx.exampleuniqueID