diff --git a/.golangci.yaml b/.golangci.yaml index ce60dd32..5eebfad2 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -94,6 +94,9 @@ linters: - linters: - nolintlint text: "should be written without leading space as `//nolint" # don't require machine-readable nolint directives (i.e. with no leading space) + - linters: + - staticcheck + text: "SA1019:.*OpenStack-only; not used for STACKIT." paths: - zz_generated\..*\.go$ diff --git a/hack/api-reference/api.md b/hack/api-reference/api.md index f68b9104..9125b487 100644 --- a/hack/api-reference/api.md +++ b/hack/api-reference/api.md @@ -889,6 +889,8 @@ boolean

FloatingPoolStatus contains information about the floating pool. + +Deprecated: OpenStack-only; not used for STACKIT.

@@ -908,7 +910,7 @@ string @@ -919,7 +921,7 @@ string @@ -952,7 +954,8 @@ string @@ -964,7 +967,7 @@ string @@ -1562,7 +1565,7 @@ string @@ -1573,7 +1576,7 @@ string @@ -1646,7 +1649,7 @@ Networks holds information about the Kubernetes and infrastructure networks. @@ -1692,7 +1695,7 @@ string @@ -1882,6 +1885,8 @@ string

RouterStatus contains information about a generated Router or resources attached to an existing Router. + +Deprecated: OpenStack-only; not used for STACKIT.

-

ID is the floating pool id.

+

ID is the floating pool id.
Deprecated: OpenStack-only; not used for STACKIT.

-

Name is the floating pool name.

+

Name is the floating pool name.
Deprecated: OpenStack-only; not used for STACKIT.

-

FloatingPoolName contains the FloatingPoolName name in which LoadBalancer FIPs should be created.

+(Optional) +

FloatingPoolName contains the FloatingPoolName name in which LoadBalancer FIPs should be created.
Deprecated: OpenStack-only; not used for STACKIT.

(Optional) -

FloatingPoolSubnetName contains the fixed name of subnet or matching name pattern for subnet
in the Floating IP Pool where the router should be attached to.

+

FloatingPoolSubnetName contains the fixed name of subnet or matching name pattern for subnet
in the Floating IP Pool where the router should be attached to.
Deprecated: OpenStack-only; not used for STACKIT.

-

FloatingPool contains information about the floating pool.

+

FloatingPool contains information about the floating pool.
Deprecated: OpenStack-only; not used for STACKIT.

-

Router contains information about the Router and related resources.

+

Router contains information about the Router and related resources.
Deprecated: OpenStack-only; not used for STACKIT.

(Optional) -

Router indicates whether to use an existing router or create a new one.

+

Router indicates whether to use an existing router or create a new one.
Deprecated: OpenStack-only; not used for STACKIT.

(Optional) -

SubnetID is the ID of an existing subnet.

+

SubnetID is the ID of an existing subnet.
Deprecated: OpenStack-only; not used for STACKIT.

@@ -1901,7 +1906,7 @@ string @@ -1912,7 +1917,7 @@ string @@ -1923,7 +1928,7 @@ string array @@ -2132,6 +2137,8 @@ boolean

ShareNetworkStatus contains information about a generated ShareNetwork + +Deprecated: OpenStack-only; not used for STACKIT.

-

ID is the Router id.

+

ID is the Router id.
Deprecated: OpenStack-only; not used for STACKIT.

-

IP is the router ip.
Deprecated: use ExternalFixedIPs instead.

+

IP is the router ip.
Deprecated: use ExternalFixedIPs instead. OpenStack-only; not used for STACKIT.

-

ExternalFixedIPs is the list of the router's assigned external fixed IPs.

+

ExternalFixedIPs is the list of the router's assigned external fixed IPs.
Deprecated: OpenStack-only; not used for STACKIT.

@@ -2151,7 +2158,7 @@ string @@ -2162,7 +2169,7 @@ string @@ -2351,6 +2358,8 @@ string

Subnet is an OpenStack subnet related to a Network. + +Deprecated: OpenStack-only; not used for STACKIT.

-

ID is the Network id.

+

ID is the Network id.
Deprecated: OpenStack-only; not used for STACKIT.

-

Name is the Network name.

+

Name is the Network name.
Deprecated: OpenStack-only; not used for STACKIT.

@@ -2370,7 +2379,7 @@ Subnet is an OpenStack subnet related to a Network. @@ -2381,7 +2390,7 @@ string @@ -2393,7 +2402,7 @@ string diff --git a/pkg/apis/stackit/v1alpha1/types_infrastructure.go b/pkg/apis/stackit/v1alpha1/types_infrastructure.go index 6d7647c8..46176737 100644 --- a/pkg/apis/stackit/v1alpha1/types_infrastructure.go +++ b/pkg/apis/stackit/v1alpha1/types_infrastructure.go @@ -15,9 +15,14 @@ import ( type InfrastructureConfig struct { metav1.TypeMeta `json:",inline"` // FloatingPoolName contains the FloatingPoolName name in which LoadBalancer FIPs should be created. + // + // Deprecated: OpenStack-only; not used for STACKIT. + // +optional FloatingPoolName string `json:"floatingPoolName"` // FloatingPoolSubnetName contains the fixed name of subnet or matching name pattern for subnet // in the Floating IP Pool where the router should be attached to. + // + // Deprecated: OpenStack-only; not used for STACKIT. // +optional FloatingPoolSubnetName *string `json:"floatingPoolSubnetName,omitempty"` // Networks is the OpenStack specific network configuration @@ -27,6 +32,8 @@ type InfrastructureConfig struct { // Networks holds information about the Kubernetes and infrastructure networks. type Networks struct { // Router indicates whether to use an existing router or create a new one. + // + // Deprecated: OpenStack-only; not used for STACKIT. // +optional Router *Router `json:"router,omitempty"` // Worker is a CIDRs of a worker subnet (private) to create (used for the VMs). @@ -39,6 +46,8 @@ type Networks struct { // +optional ID *string `json:"id,omitempty"` // SubnetID is the ID of an existing subnet. + // + // Deprecated: OpenStack-only; not used for STACKIT. // +optional SubnetID *string `json:"subnetId,omitempty"` // ShareNetwork holds information about the share network (used for shared file systems like NFS) @@ -91,8 +100,12 @@ type NetworkStatus struct { // Name is the Network name. Name string `json:"name"` // FloatingPool contains information about the floating pool. + // + // Deprecated: OpenStack-only; not used for STACKIT. FloatingPool FloatingPoolStatus `json:"floatingPool"` // Router contains information about the Router and related resources. + // + // Deprecated: OpenStack-only; not used for STACKIT. Router RouterStatus `json:"router"` // DNSServer contains the networks configured dnsServers // +optional @@ -109,30 +122,48 @@ type NetworkStatus struct { } // RouterStatus contains information about a generated Router or resources attached to an existing Router. +// +// Deprecated: OpenStack-only; not used for STACKIT. type RouterStatus struct { // ID is the Router id. + // + // Deprecated: OpenStack-only; not used for STACKIT. ID string `json:"id"` // IP is the router ip. // - // Deprecated: use ExternalFixedIPs instead. + // Deprecated: use ExternalFixedIPs instead. OpenStack-only; not used for STACKIT. IP string `json:"ip"` // ExternalFixedIPs is the list of the router's assigned external fixed IPs. + // + // Deprecated: OpenStack-only; not used for STACKIT. ExternalFixedIPs []string `json:"externalFixedIP"` } // FloatingPoolStatus contains information about the floating pool. +// +// Deprecated: OpenStack-only; not used for STACKIT. type FloatingPoolStatus struct { // ID is the floating pool id. + // + // Deprecated: OpenStack-only; not used for STACKIT. ID string `json:"id"` // Name is the floating pool name. + // + // Deprecated: OpenStack-only; not used for STACKIT. Name string `json:"name"` } // ShareNetworkStatus contains information about a generated ShareNetwork +// +// Deprecated: OpenStack-only; not used for STACKIT. type ShareNetworkStatus struct { // ID is the Network id. + // + // Deprecated: OpenStack-only; not used for STACKIT. ID string `json:"id"` // Name is the Network name. + // + // Deprecated: OpenStack-only; not used for STACKIT. Name string `json:"name"` } @@ -145,13 +176,21 @@ const ( ) // Subnet is an OpenStack subnet related to a Network. +// +// Deprecated: OpenStack-only; not used for STACKIT. type Subnet struct { // Purpose is a logical description of the subnet. + // + // Deprecated: OpenStack-only; not used for STACKIT. Purpose Purpose `json:"purpose"` // ID is the subnet id. + // + // Deprecated: OpenStack-only; not used for STACKIT. ID string `json:"id"` // DNSNameservers specifies the DNS nameservers for the subnet. // Nil if DNSNameservers could not be queried. + // + // Deprecated: OpenStack-only; not used for STACKIT. // +optional DNSNameservers *[]string `json:"dnsNameservers,omitempty"` } diff --git a/pkg/apis/stackit/validation/cloudprofile.go b/pkg/apis/stackit/validation/cloudprofile.go index e5306ab1..1dc1e636 100644 --- a/pkg/apis/stackit/validation/cloudprofile.go +++ b/pkg/apis/stackit/validation/cloudprofile.go @@ -30,7 +30,6 @@ func ValidateCloudProfileConfig(cloudProfile *stackitv1alpha1.CloudProfileConfig floatingPoolPath := fldPath.Child("constraints", "floatingPools") combinationFound := sets.NewString() - //nolint:staticcheck // SA1019: needed for migration purposes for i, pool := range cloudProfile.Constraints.FloatingPools { idxPath := floatingPoolPath.Index(i) if len(pool.Name) == 0 { @@ -71,7 +70,6 @@ func ValidateCloudProfileConfig(cloudProfile *stackitv1alpha1.CloudProfileConfig } allErrs = append(allErrs, validateMachineImageMapping(machineImages, cloudProfile, capabilityDefinitions, field.NewPath("spec").Child("machineImages"))...) - //nolint:staticcheck // SA1019: needed for migration purposes if ca := cloudProfile.KeyStoneCACert; ca != nil && len(*ca) > 0 { _, err := utils.DecodeCertificate([]byte(*ca)) if err != nil { @@ -80,7 +78,6 @@ func ValidateCloudProfileConfig(cloudProfile *stackitv1alpha1.CloudProfileConfig } regionsFound := sets.NewString() - //nolint:staticcheck // SA1019: needed for migration purposes for i, val := range cloudProfile.KeyStoneURLs { idxPath := fldPath.Child("keyStoneURLs").Index(i) @@ -111,13 +108,11 @@ func ValidateCloudProfileConfig(cloudProfile *stackitv1alpha1.CloudProfileConfig } } - //nolint:staticcheck // SA1019: needed for migration purposes if cloudProfile.DHCPDomain != nil && len(*cloudProfile.DHCPDomain) == 0 { allErrs = append(allErrs, field.Required(fldPath.Child("dhcpDomain"), "must provide a dhcp domain when the key is specified")) } serverGroupPath := fldPath.Child("serverGroupPolicies") - //nolint:staticcheck // SA1019: needed for migration purposes for i, policy := range cloudProfile.ServerGroupPolicies { idxPath := serverGroupPath.Index(i) diff --git a/pkg/apis/stackit/validation/cloudprofile_test.go b/pkg/apis/stackit/validation/cloudprofile_test.go index 27311879..3f875814 100644 --- a/pkg/apis/stackit/validation/cloudprofile_test.go +++ b/pkg/apis/stackit/validation/cloudprofile_test.go @@ -93,7 +93,6 @@ var _ = Describe("CloudProfileConfig validation", func() { Context("floating pools constraints", func() { It("should forbid unsupported pools", func() { - //nolint:staticcheck // SA1019: needed for migration purposes cloudProfileConfig.Constraints.FloatingPools = []stackitv1alpha1.FloatingPool{ { Name: "", @@ -117,7 +116,6 @@ var _ = Describe("CloudProfileConfig validation", func() { }) It("should forbid duplicates regions and domains in pools", func() { - //nolint:staticcheck // SA1019: needed for migration purposes cloudProfileConfig.Constraints.FloatingPools = []stackitv1alpha1.FloatingPool{ { Name: "foo", @@ -170,9 +168,7 @@ var _ = Describe("CloudProfileConfig validation", func() { Context("keystone url validation", func() { It("should forbid keystone urls with missing keys", func() { - //nolint:staticcheck // SA1019: needed for migration purposes cloudProfileConfig.KeyStoneURL = "" - //nolint:staticcheck // SA1019: needed for migration purposes cloudProfileConfig.KeyStoneURLs = []stackitv1alpha1.KeyStoneURL{{}} errorList := ValidateCloudProfileConfig(cloudProfileConfig, machineImages, capabilityDefinitions, fldPath) @@ -187,9 +183,7 @@ var _ = Describe("CloudProfileConfig validation", func() { }) It("should forbid duplicate regions for keystone urls", func() { - //nolint:staticcheck // SA1019: needed for migration purposes cloudProfileConfig.KeyStoneURL = "" - //nolint:staticcheck // SA1019: needed for migration purposes cloudProfileConfig.KeyStoneURLs = []stackitv1alpha1.KeyStoneURL{ { Region: "foo", @@ -211,7 +205,6 @@ var _ = Describe("CloudProfileConfig validation", func() { }) It("should forbid invalid keystone CA Certs", func() { - //nolint:staticcheck // SA1019: needed for migration purposes cloudProfileConfig.KeyStoneCACert = new("foo") errorList := ValidateCloudProfileConfig(cloudProfileConfig, machineImages, capabilityDefinitions, fldPath) @@ -237,7 +230,6 @@ var _ = Describe("CloudProfileConfig validation", func() { Context("dhcp domain validation", func() { It("should forbid not specifying a value when the key is present", func() { - //nolint:staticcheck // SA1019: needed for migration purposes cloudProfileConfig.DHCPDomain = new("") errorList := ValidateCloudProfileConfig(cloudProfileConfig, machineImages, capabilityDefinitions, fldPath) @@ -552,7 +544,6 @@ var _ = Describe("CloudProfileConfig validation", func() { Context("server group policy validation", func() { It("should forbid empty server group policy", func() { - //nolint:staticcheck // SA1019: needed for migration purposes cloudProfileConfig.ServerGroupPolicies = []string{ "affinity", "", diff --git a/pkg/apis/stackit/validation/infrastructure.go b/pkg/apis/stackit/validation/infrastructure.go index a09175aa..ef8dd016 100644 --- a/pkg/apis/stackit/validation/infrastructure.go +++ b/pkg/apis/stackit/validation/infrastructure.go @@ -21,12 +21,12 @@ func ValidateInfrastructureConfig(infra *stackitv1alpha1.InfrastructureConfig, n // check InfrastructureConfig.networks.worker(s) is a valid cidr and not be set if a network id is provided. var workerCIDR cidrvalidation.CIDR - //nolint:staticcheck // SA1019: needed for migration purposes + //nolint:staticcheck // SA1019: deprecated will be removed later if infra.Networks.Worker != "" { - //nolint:staticcheck // SA1019: needed for migration purposes + //nolint:staticcheck // SA1019: deprecated will be removed later workerCIDR = cidrvalidation.NewCIDR(infra.Networks.Worker, networksPath.Child("worker")) allErrs = append(allErrs, cidrvalidation.ValidateCIDRParse(workerCIDR)...) - //nolint:staticcheck // SA1019: needed for migration purposes + //nolint:staticcheck // SA1019: deprecated will be removed later allErrs = append(allErrs, cidrvalidation.ValidateCIDRIsCanonical(networksPath.Child("worker"), infra.Networks.Worker)...) if infra.Networks.ID != nil { allErrs = append(allErrs, field.Forbidden(networksPath.Child("worker"), "cant be set if a network id is provided")) diff --git a/pkg/cmd/config.go b/pkg/cmd/config.go index 91fea546..66fdca24 100644 --- a/pkg/cmd/config.go +++ b/pkg/cmd/config.go @@ -69,11 +69,11 @@ func (c *Config) ApplyETCDStorage(etcdStorage *config.ETCDStorage) { // ApplyRegistryCaches sets the given Registry Cache configurations. func (c *Config) ApplyRegistryCaches(regCaches *[]config.RegistryCacheConfiguration) { - //nolint:staticcheck // SA1019: needed for migration purposes + //nolint:staticcheck // SA1019: deprecated will be removed later if len(c.Config.RegistryCaches) == 0 { return } - //nolint:staticcheck // SA1019: needed for migration purposes + //nolint:staticcheck // SA1019: deprecated will be removed later *regCaches = c.Config.RegistryCaches } diff --git a/pkg/controller/controlplane/valuesprovider.go b/pkg/controller/controlplane/valuesprovider.go index 49d006d3..5f156446 100644 --- a/pkg/controller/controlplane/valuesprovider.go +++ b/pkg/controller/controlplane/valuesprovider.go @@ -660,9 +660,7 @@ func getConfigChartValues( values["applicationCredentialName"] = osCredentials.ApplicationCredentialName values["applicationCredentialSecret"] = osCredentials.ApplicationCredentialSecret values["region"] = cp.Spec.Region - //nolint:staticcheck // SA1019: needed for migration purposes values["requestTimeout"] = cloudProfileConfig.RequestTimeout - //nolint:staticcheck // SA1019: needed for migration purposes values["ignoreVolumeAZ"] = cloudProfileConfig.IgnoreVolumeAZ != nil && *cloudProfileConfig.IgnoreVolumeAZ // detect internal network. // See https://github.com/kubernetes/cloud-provider-openstack/blob/v1.22.1/docs/openstack-cloud-controller-manager/using-openstack-cloud-controller-manager.md#networking @@ -1285,8 +1283,7 @@ func (vp *valuesProvider) getControlPlaneShootChartCSIValues(ctx context.Context values := map[string]any{ "enabled": getCSIDriver(cpConfig) == stackitv1alpha1.OPENSTACK, "rescanBlockStorageOnResize": cloudProfileConfig.RescanBlockStorageOnResize != nil && *cloudProfileConfig.RescanBlockStorageOnResize, - //nolint:staticcheck // SA1019: needed for migration purposes - "nodeVolumeAttachLimit": cloudProfileConfig.NodeVolumeAttachLimit, + "nodeVolumeAttachLimit": cloudProfileConfig.NodeVolumeAttachLimit, } if userAgentHeader != nil { diff --git a/pkg/controller/infrastructure/openstack/infraflow/context.go b/pkg/controller/infrastructure/openstack/infraflow/context.go index 1a06e228..b6a280d7 100644 --- a/pkg/controller/infrastructure/openstack/infraflow/context.go +++ b/pkg/controller/infrastructure/openstack/infraflow/context.go @@ -163,8 +163,8 @@ func NewFlowContext(ctx context.Context, opts Opts) (*FlowContext, error) { } func (fctx *FlowContext) persistState(ctx context.Context) error { - // status is nil such that there's no need to pass the nodesCIDR - return infrainternal.PatchProviderStatusAndState(ctx, fctx.client, fctx.infra, nil, nil, fctx.computeInfrastructureState()) + // status is nil such that there's no need to pass the nodesCIDR and egressCIDRs + return infrainternal.PatchProviderStatusAndState(ctx, fctx.client, fctx.infra, nil, nil, nil, fctx.computeInfrastructureState()) } func (fctx *FlowContext) computeInfrastructureState() *runtime.RawExtension { @@ -192,9 +192,7 @@ func (fctx *FlowContext) computeInfrastructureStatus() *stackitv1alpha1.Infrastr status.Networks.Router.ID = ptr.Deref(fctx.state.Get(IdentifierRouter), "") status.Networks.Router.ExternalFixedIPs = fctx.state.GetObject(IdentifierEgressCIDRs).([]string) - // backwards compatibility change for the deprecated field if len(status.Networks.Router.ExternalFixedIPs) > 0 { - //nolint:staticcheck // SA1019: needed for migration purposes status.Networks.Router.IP = status.Networks.Router.ExternalFixedIPs[0] } @@ -205,7 +203,6 @@ func (fctx *FlowContext) computeInfrastructureStatus() *stackitv1alpha1.Infrastr } if v := fctx.state.Get(IdentifierSubnet); v != nil { - //nolint:staticcheck // SA1019: Keep support for OpenStack mcm until we completely drop it status.Networks.Subnets = []stackitv1alpha1.Subnet{ { Purpose: stackitv1alpha1.PurposeNodes, diff --git a/pkg/controller/infrastructure/openstack/infraflow/reconcile.go b/pkg/controller/infrastructure/openstack/infraflow/reconcile.go index abe75b65..fc892cd3 100644 --- a/pkg/controller/infrastructure/openstack/infraflow/reconcile.go +++ b/pkg/controller/infrastructure/openstack/infraflow/reconcile.go @@ -24,6 +24,7 @@ import ( infrainternal "github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/internal/infrastructure" "github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/openstack/client" stackitclient "github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/stackit/client" + "github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/utils" ) const ( @@ -43,7 +44,12 @@ func (fctx *FlowContext) Reconcile(ctx context.Context) error { state := fctx.computeInfrastructureState() status := fctx.computeInfrastructureStatus() - return infrainternal.PatchProviderStatusAndState(ctx, fctx.client, fctx.infra, status, fctx.nodesCIDR, state) + var egressCIDRs []string + if status != nil { + egressCIDRs = utils.ComputeEgressCIDRs(status.Networks.Router.ExternalFixedIPs) + } + + return infrainternal.PatchProviderStatusAndState(ctx, fctx.client, fctx.infra, status, fctx.nodesCIDR, egressCIDRs, state) } func (fctx *FlowContext) buildReconcileGraph() *flow.Graph { @@ -162,8 +168,7 @@ func (fctx *FlowContext) ensureNewRouter(ctx context.Context, externalNetworkID desired := &access.Router{ Name: fctx.defaultRouterName(), ExternalNetworkID: externalNetworkID, - //nolint:staticcheck // SA1019: needed for migration purposes - EnableSNAT: fctx.cloudProfileConfig.UseSNAT, + EnableSNAT: fctx.cloudProfileConfig.UseSNAT, } current, err := fctx.findExistingRouter(ctx) if err != nil { @@ -210,7 +215,6 @@ func (fctx *FlowContext) findFloatingPoolSubnetName() *string { } // Second: Check if the CloudProfile contains a default floating subnet and use it. - //nolint:staticcheck // SA1019: needed for migration purposes if floatingPool, err := helper.FindFloatingPool(fctx.cloudProfileConfig.Constraints.FloatingPools, fctx.config.FloatingPoolName, fctx.infra.Spec.Region, nil); err == nil && floatingPool.DefaultFloatingSubnet != nil { return floatingPool.DefaultFloatingSubnet } diff --git a/pkg/controller/infrastructure/openstack/infraflow/utils.go b/pkg/controller/infrastructure/openstack/infraflow/utils.go index 4c177152..dbf94fd3 100644 --- a/pkg/controller/infrastructure/openstack/infraflow/utils.go +++ b/pkg/controller/infrastructure/openstack/infraflow/utils.go @@ -59,7 +59,7 @@ func (fctx *FlowContext) defaultSecurityGroupName() string { } func (fctx *FlowContext) workerCIDR() string { - //nolint:staticcheck // SA1019: needed for migration purposes + //nolint:staticcheck // SA1019: deprecated will be removed later s := fctx.config.Networks.Worker if workers := fctx.config.Networks.Workers; workers != "" { s = workers diff --git a/pkg/controller/infrastructure/stackit/infraflow/context.go b/pkg/controller/infrastructure/stackit/infraflow/context.go index d66d0c64..557aeb47 100644 --- a/pkg/controller/infrastructure/stackit/infraflow/context.go +++ b/pkg/controller/infrastructure/stackit/infraflow/context.go @@ -25,10 +25,6 @@ import ( const ( - // NameFloatingNetwork is the key for the floating network name - NameFloatingNetwork = "FloatingNetworkName" - // IdentifierFloatingNetwork is the key for the floating network id - IdentifierFloatingNetwork = "FloatingNetwork" // IdentifierNetwork is the key for the network id IdentifierNetwork = "Network" // NameNetwork is the name of the network @@ -41,8 +37,6 @@ const ( NameSecGroup = "SecurityGroupName" // IdentifierSubnet is the key for the subnet id IdentifierSubnet = "Subnet" - // IdentifierEgressCIDRs is the key for the slice containing egress CIDRs strings. - IdentifierEgressCIDRs = "EgressCIDRs" // NameKeyPair is the key for the name of the EC2 key pair resource NameKeyPair = "KeyPair" ) @@ -77,6 +71,7 @@ type FlowContext struct { networking osclient.Networking isSNAShoot bool nodesCIDR *string + egressCIDRs []string dnsNameservers *[]string stackitLB stackitclient.LoadBalancingClient stackitALB stackitclient.ApplicationLoadBalancingClient @@ -156,8 +151,8 @@ func NewFlowContext(ctx context.Context, opts Opts) (*FlowContext, error) { } func (fctx *FlowContext) persistState(ctx context.Context) error { - // status is nil such that there's no need to pass the nodesCIDR - return infrainternal.PatchProviderStatusAndState(ctx, fctx.client, fctx.infra, nil, nil, fctx.computeInfrastructureState()) + // status is nil such that there's no need to pass the nodesCIDR and egressCIDRs + return infrainternal.PatchProviderStatusAndState(ctx, fctx.client, fctx.infra, nil, nil, nil, fctx.computeInfrastructureState()) } func (fctx *FlowContext) computeInfrastructureStatus() *stackitv1alpha1.InfrastructureStatus { @@ -165,19 +160,9 @@ func (fctx *FlowContext) computeInfrastructureStatus() *stackitv1alpha1.Infrastr TypeMeta: infrainternal.StatusTypeMeta, } - status.Networks.FloatingPool.ID = ptr.Deref(fctx.state.Get(IdentifierFloatingNetwork), "") - status.Networks.FloatingPool.Name = ptr.Deref(fctx.state.Get(NameFloatingNetwork), "") - status.Networks.ID = ptr.Deref(fctx.state.Get(IdentifierNetwork), "") status.Networks.Name = ptr.Deref(fctx.state.Get(NameNetwork), "") - status.Networks.Router.ExternalFixedIPs = fctx.state.GetObject(IdentifierEgressCIDRs).([]string) - // backwards compatibility change for the deprecated field - if len(status.Networks.Router.ExternalFixedIPs) > 0 { - //nolint:staticcheck // SA1019: needed for migration purposes - status.Networks.Router.IP = status.Networks.Router.ExternalFixedIPs[0] - } - status.Node.KeyName = ptr.Deref(fctx.state.Get(NameKeyPair), "") if fctx.dnsNameservers != nil { @@ -186,7 +171,6 @@ func (fctx *FlowContext) computeInfrastructureStatus() *stackitv1alpha1.Infrastr // TODO: Remove once migrated fully to IaaS API if v := fctx.state.Get(IdentifierSubnet); v != nil { - //nolint:staticcheck // SA1019: Will be removed once OpenStack mcm support is dropped. status.Networks.Subnets = []stackitv1alpha1.Subnet{ { Purpose: stackitv1alpha1.PurposeNodes, diff --git a/pkg/controller/infrastructure/stackit/infraflow/reconcile.go b/pkg/controller/infrastructure/stackit/infraflow/reconcile.go index 9d84de35..88048193 100644 --- a/pkg/controller/infrastructure/stackit/infraflow/reconcile.go +++ b/pkg/controller/infrastructure/stackit/infraflow/reconcile.go @@ -16,6 +16,7 @@ import ( infrainternal "github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/internal/infrastructure" "github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/stackit" "github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/stackit/client" + "github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/utils" ) const ( @@ -33,22 +34,15 @@ func (fctx *FlowContext) Reconcile(ctx context.Context) error { state := fctx.computeInfrastructureState() status := fctx.computeInfrastructureStatus() - return infrainternal.PatchProviderStatusAndState(ctx, fctx.client, fctx.infra, status, fctx.nodesCIDR, state) + return infrainternal.PatchProviderStatusAndState(ctx, fctx.client, fctx.infra, status, fctx.nodesCIDR, fctx.egressCIDRs, state) } func (fctx *FlowContext) buildReconcileGraph() *flow.Graph { g := flow.NewGraph("STACKIT infrastructure reconciliation") - ensureExternalNetwork := fctx.AddTask(g, "ensure external network", - fctx.ensureExternalNetwork, - shared.Timeout(defaultTimeout), - shared.DoIf(fctx.hasOpenStackCredentials), - ) - ensureNetwork := fctx.AddTask(g, "ensure isolated network", fctx.ensureNetwork, - shared.Timeout(defaultTimeout), - shared.Dependencies(ensureExternalNetwork)) + shared.Timeout(defaultTimeout)) _ = fctx.AddTask(g, "ensure openstack subnet id", fctx.ensureOpenStackSubnetID, @@ -82,19 +76,6 @@ func (fctx *FlowContext) buildReconcileGraph() *flow.Graph { return g } -func (fctx *FlowContext) ensureExternalNetwork(ctx context.Context) error { - externalNetwork, err := fctx.networking.GetExternalNetworkByName(ctx, fctx.config.FloatingPoolName) - if err != nil { - return err - } - if externalNetwork == nil { - return fmt.Errorf("external network for floating pool name %s not found", fctx.config.FloatingPoolName) - } - fctx.state.Set(IdentifierFloatingNetwork, externalNetwork.ID) - fctx.state.Set(NameFloatingNetwork, externalNetwork.Name) - return nil -} - func (fctx *FlowContext) ensureConfiguredNetwork(ctx context.Context) error { networkID := *fctx.config.Networks.ID network, err := fctx.iaasClient.GetNetworkById(ctx, networkID) @@ -420,7 +401,6 @@ func (fctx *FlowContext) ensureIsolatedNetwork(ctx context.Context) error { } func (fctx *FlowContext) ensureEgressIP(ctx context.Context) error { - var result []string networkID := fctx.state.Get(IdentifierNetwork) network, err := fctx.iaasClient.GetNetworkById(ctx, *networkID) if err != nil { @@ -432,8 +412,7 @@ func (fctx *FlowContext) ensureEgressIP(ctx context.Context) error { } routerIP, ok := network.Ipv4.GetPublicIpOk() if ok && routerIP != nil { - result = append(result, *routerIP) - fctx.state.SetObject(IdentifierEgressCIDRs, result) + fctx.egressCIDRs = utils.ComputeEgressCIDRs([]string{*routerIP}) return nil } return fmt.Errorf("egress IP not found for network: %s", network.GetId()) diff --git a/pkg/controller/infrastructure/stackit/infraflow/utils.go b/pkg/controller/infrastructure/stackit/infraflow/utils.go index 5f287c6b..8d87c823 100644 --- a/pkg/controller/infrastructure/stackit/infraflow/utils.go +++ b/pkg/controller/infrastructure/stackit/infraflow/utils.go @@ -11,7 +11,7 @@ import ( var ErrorMultipleMatches = fmt.Errorf("error multiple matches") func (fctx *FlowContext) workerCIDR() string { - //nolint:staticcheck // SA1019: needed for migration purposes + //nolint:staticcheck // SA1019: deprecated will be removed later s := fctx.config.Networks.Worker if workers := fctx.config.Networks.Workers; workers != "" { s = workers diff --git a/pkg/controller/worker/machines.go b/pkg/controller/worker/machines.go index c81ba5fb..b51ebde8 100644 --- a/pkg/controller/worker/machines.go +++ b/pkg/controller/worker/machines.go @@ -96,7 +96,6 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error { var subnet *stackitv1alpha1.Subnet // There is no subnet resource in the IaaS API. The machine-controller-manager-provider-stackit do not require this field. if !feature.UseStackitMachineControllerManager(w.cluster) { - //nolint:staticcheck // SA1019: Will be removed once we drop OpenStack API support subnet, err = helper.FindSubnetByPurpose(infrastructureStatus.Networks.Subnets, stackitv1alpha1.PurposeNodes) if err != nil { return err @@ -146,7 +145,6 @@ func (w *workerDelegate) generateMachineConfig(ctx context.Context) error { } machineLabels := map[string]string{} - //nolint:staticcheck for _, pair := range workerConfig.MachineLabels { machineLabels[pair.Name] = pair.Value } @@ -311,7 +309,6 @@ func (w *workerDelegate) generateWorkerPoolHash(pool extensionsv1alpha1.WorkerPo var additionalHashData []string var pairs []string - //nolint:staticcheck for _, pair := range workerConfig.MachineLabels { if pair.TriggerRollingOnUpdate { pairs = append(pairs, pair.Name+"="+pair.Value) diff --git a/pkg/internal/infrastructure/infrastucture.go b/pkg/internal/infrastructure/infrastucture.go index d2e79047..ee31aea3 100644 --- a/pkg/internal/infrastructure/infrastucture.go +++ b/pkg/internal/infrastructure/infrastucture.go @@ -24,7 +24,6 @@ import ( stackitv1alpha1 "github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/apis/stackit/v1alpha1" openstackclient "github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/openstack/client" - "github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/utils" ) const ( @@ -148,7 +147,7 @@ func WorkersCIDR(config *stackitv1alpha1.InfrastructureConfig) string { workersCIDR := config.Networks.Workers // Backwards compatibility - remove this code in a future version. if workersCIDR == "" { - //nolint:staticcheck // SA1019: needed for migration purposes + //nolint:staticcheck // SA1019: deprecated will be removed later workersCIDR = config.Networks.Worker } @@ -162,13 +161,14 @@ func PatchProviderStatusAndState( infra *extensionsv1alpha1.Infrastructure, status *stackitv1alpha1.InfrastructureStatus, nodesCIDR *string, + egressCIDRs []string, state *runtime.RawExtension, ) error { patch := client.MergeFrom(infra.DeepCopy()) if status != nil { infra.Status.ProviderStatus = &runtime.RawExtension{Object: status} infra.Status.NodesCIDR = nodesCIDR - infra.Status.EgressCIDRs = utils.ComputeEgressCIDRs(status.Networks.Router.ExternalFixedIPs) + infra.Status.EgressCIDRs = egressCIDRs } if state != nil { diff --git a/pkg/webhook/cloudprovider/ensurer.go b/pkg/webhook/cloudprovider/ensurer.go index 413bc5f5..7bcdac28 100644 --- a/pkg/webhook/cloudprovider/ensurer.go +++ b/pkg/webhook/cloudprovider/ensurer.go @@ -62,17 +62,14 @@ func (e *ensurer) EnsureCloudProviderSecret( // If no KeyStone configuration is present at all, skip KeyStone-related fields. // This is valid for STACKIT-only shoots that don't require OpenStack credentials. - //nolint:staticcheck // SA1019: needed for migration purposes if len(config.KeyStoneURLs) == 0 && len(config.KeyStoneURL) == 0 { return nil } - //nolint:staticcheck // SA1019: needed for migration purposes keyStoneURL, err := helper.FindKeyStoneURL(config.KeyStoneURLs, config.KeyStoneURL, cluster.Shoot.Spec.Region) if err != nil { return fmt.Errorf("could not find KeyStoneUrl: %v", err) } - //nolint:staticcheck // SA1019: needed for migration purposes keyStoneCABundle := helper.FindKeyStoneCACert(config.KeyStoneURLs, config.KeyStoneCACert, cluster.Shoot.Spec.Region) if new.Data == nil { @@ -85,7 +82,6 @@ func (e *ensurer) EnsureCloudProviderSecret( // remove key from user delete(new.Data, types.Insecure) - //nolint:staticcheck // SA1019: needed for migration purposes if config.KeyStoneForceInsecure { new.Data[types.Insecure] = []byte("true") } diff --git a/pkg/webhook/controlplane/ensurer.go b/pkg/webhook/controlplane/ensurer.go index 5eedad7a..5e5b8a04 100644 --- a/pkg/webhook/controlplane/ensurer.go +++ b/pkg/webhook/controlplane/ensurer.go @@ -409,6 +409,5 @@ func getResolveConfOptions(cloudProfileConfig *stackitv1alpha1.CloudProfileConfi if cloudProfileConfig == nil { return nil } - //nolint:staticcheck // SA1019: needed for migration purposes return cloudProfileConfig.ResolvConfOptions } diff --git a/test/integration/infrastructure/stackit/infrastructure_test.go b/test/integration/infrastructure/stackit/infrastructure_test.go index a4abb720..e5ac976f 100644 --- a/test/integration/infrastructure/stackit/infrastructure_test.go +++ b/test/integration/infrastructure/stackit/infrastructure_test.go @@ -640,17 +640,6 @@ func verifyCreation(infraStatus extensionsv1alpha1.InfrastructureStatus, provide net, err := iaasClient.GetNetworkById(ctx, providerStatus.Networks.ID) Expect(err).NotTo(HaveOccurred()) - var externalFixedIPs []string - ip, ok := net.Ipv4.GetPublicIpOk() - if ok && ip != nil { - externalFixedIPs = append(externalFixedIPs, *ip) - } - - // verify router ip in status - Expect(ip).NotTo(BeNil()) - Expect(*ip).NotTo(BeEmpty()) - Expect(providerStatus.Networks.Router.ExternalFixedIPs).To(ContainElements(externalFixedIPs)) - // network is created Expect(err).NotTo(HaveOccurred()) Expect(net).NotTo(BeNil()) @@ -672,7 +661,11 @@ func verifyCreation(infraStatus extensionsv1alpha1.InfrastructureStatus, provide infrastructureIdentifier.keyPair = new(keyPair.GetName()) // verify egressCIDRs - Expect(infraStatus.EgressCIDRs).To(ContainElements(utils.ComputeEgressCIDRs(providerStatus.Networks.Router.ExternalFixedIPs))) + ip, ok := net.Ipv4.GetPublicIpOk() + Expect(ok).To(BeTrue()) + Expect(ip).NotTo(BeNil()) + Expect(*ip).NotTo(BeEmpty()) + Expect(infraStatus.EgressCIDRs).To(ContainElements(utils.ComputeEgressCIDRs([]string{*ip}))) return infrastructureIdentifier, providerStatus }
-

Purpose is a logical description of the subnet.

+

Purpose is a logical description of the subnet.
Deprecated: OpenStack-only; not used for STACKIT.

-

ID is the subnet id.

+

ID is the subnet id.
Deprecated: OpenStack-only; not used for STACKIT.

(Optional) -

DNSNameservers specifies the DNS nameservers for the subnet.
Nil if DNSNameservers could not be queried.

+

DNSNameservers specifies the DNS nameservers for the subnet.
Nil if DNSNameservers could not be queried.
Deprecated: OpenStack-only; not used for STACKIT.