From ded71d1caa1df5914ed2fc01257ebfcdecf0d48d Mon Sep 17 00:00:00 2001 From: Nir Magnezi Date: Tue, 12 Sep 2023 16:45:35 +0300 Subject: [PATCH 1/9] MGMT-14810: Remove Singular VIPs from swagger This is to make sure there are no leftovers in the codebase. Once the cleanup is done, in follow up commits. Those will get added back So the UI won't break for now. --- swagger.yaml | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/swagger.yaml b/swagger.yaml index 4fe28a88fb..59f5a97870 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -4711,19 +4711,11 @@ definitions: description: The IP address pool to use for service IP addresses. You can enter only one IP address pool. If you need to access the services from an external network, configure load balancers and routers to manage the traffic. pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3}\/(?:(?:[0-9])|(?:[1-2][0-9])|(?:3[0-2])))|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,})/(?:(?:[0-9])|(?:[1-9][0-9])|(?:1[0-1][0-9])|(?:12[0-8])))$' default: "172.30.0.0/16" - api_vip: - type: string - pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$' - description: (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. api_vips: type: array description: The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. items: $ref: '#/definitions/api_vip' - ingress_vip: - type: string - pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$' - description: (DEPRECATED) The virtual IP used for cluster ingress traffic. ingress_vips: type: array description: The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. @@ -4889,22 +4881,12 @@ definitions: description: The IP address pool to use for service IP addresses. You can enter only one IP address pool. If you need to access the services from an external network, configure load balancers and routers to manage the traffic. pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3}\/(?:(?:[0-9])|(?:[1-2][0-9])|(?:3[0-2])))|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,})/(?:(?:[0-9])|(?:[1-9][0-9])|(?:1[0-1][0-9])|(?:12[0-8])))$' x-nullable: true - api_vip: - type: string - pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$' - description: (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. - x-nullable: true api_vips: type: array description: The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. items: $ref: '#/definitions/api_vip' x-nullable: true - ingress_vip: - type: string - pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$' - description: (DEPRECATED) The virtual IP used for cluster ingress traffic. - x-nullable: true ingress_vips: type: array description: The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. @@ -5095,10 +5077,6 @@ definitions: type: string description: The IP address pool to use for service IP addresses. You can enter only one IP address pool. If you need to access the services from an external network, configure load balancers and routers to manage the traffic. pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3}\/(?:(?:[0-9])|(?:[1-2][0-9])|(?:3[0-2])))|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,})/(?:(?:[0-9])|(?:[1-9][0-9])|(?:1[0-1][0-9])|(?:12[0-8])))$' - api_vip: - type: string - pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$' - description: (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. api_vips: x-go-custom-tag: gorm:"foreignkey:ClusterID;references:ID" x-nullable: true @@ -5114,10 +5092,6 @@ definitions: type: string description: A CIDR that all hosts belonging to the cluster should have an interfaces with IP address that belongs to this CIDR. The api_vip belongs to this CIDR. pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3}\/(?:(?:[0-9])|(?:[1-2][0-9])|(?:3[0-2])))|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,})/(?:(?:[0-9])|(?:[1-9][0-9])|(?:1[0-1][0-9])|(?:12[0-8])))$' - ingress_vip: - type: string - pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$' - description: (DEPRECATED) The virtual IP used for cluster ingress traffic. ingress_vips: x-go-custom-tag: gorm:"foreignkey:ClusterID;references:ID" x-nullable: true From ad7840ef9762cf34ba9aa7106efe39d95b002747 Mon Sep 17 00:00:00 2001 From: Nir Magnezi Date: Tue, 12 Sep 2023 16:53:22 +0300 Subject: [PATCH 2/9] MGMT-14810: Regenerate --- models/cluster.go | 40 ------------------- models/cluster_create_params.go | 40 ------------------- models/v2_cluster_update_params.go | 40 ------------------- restapi/embedded_spec.go | 64 ------------------------------ 4 files changed, 184 deletions(-) diff --git a/models/cluster.go b/models/cluster.go index f996313bb3..ed4f66367b 100644 --- a/models/cluster.go +++ b/models/cluster.go @@ -30,10 +30,6 @@ type Cluster struct { // Format: uuid AmsSubscriptionID strfmt.UUID `json:"ams_subscription_id,omitempty"` - // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ - APIVip string `json:"api_vip,omitempty"` - // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -147,10 +143,6 @@ type Cluster struct { // reflect the actual cluster they represent Imported *bool `json:"imported,omitempty"` - // (DEPRECATED) The virtual IP used for cluster ingress traffic. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ - IngressVip string `json:"ingress_vip,omitempty"` - // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips" gorm:"foreignkey:ClusterID;references:ID"` @@ -289,10 +281,6 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateAPIVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -361,10 +349,6 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateIngressVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -459,18 +443,6 @@ func (m *Cluster) validateAmsSubscriptionID(formats strfmt.Registry) error { return nil } -func (m *Cluster) validateAPIVip(formats strfmt.Registry) error { - if swag.IsZero(m.APIVip) { // not required - return nil - } - - if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { - return err - } - - return nil -} - func (m *Cluster) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -863,18 +835,6 @@ func (m *Cluster) validateImageInfo(formats strfmt.Registry) error { return nil } -func (m *Cluster) validateIngressVip(formats strfmt.Registry) error { - if swag.IsZero(m.IngressVip) { // not required - return nil - } - - if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { - return err - } - - return nil -} - func (m *Cluster) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/models/cluster_create_params.go b/models/cluster_create_params.go index 432ab0ed9a..3eeade9fcd 100644 --- a/models/cluster_create_params.go +++ b/models/cluster_create_params.go @@ -24,10 +24,6 @@ type ClusterCreateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` - // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ - APIVip string `json:"api_vip,omitempty"` - // The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. APIVips []*APIVip `json:"api_vips"` @@ -76,10 +72,6 @@ type ClusterCreateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` - // (DEPRECATED) The virtual IP used for cluster ingress traffic. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ - IngressVip string `json:"ingress_vip,omitempty"` - // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -143,10 +135,6 @@ type ClusterCreateParams struct { func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { var res []error - if err := m.validateAPIVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -183,10 +171,6 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateIngressVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -233,18 +217,6 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { return nil } -func (m *ClusterCreateParams) validateAPIVip(formats strfmt.Registry) error { - if swag.IsZero(m.APIVip) { // not required - return nil - } - - if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { - return err - } - - return nil -} - func (m *ClusterCreateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -507,18 +479,6 @@ func (m *ClusterCreateParams) validateIgnitionEndpoint(formats strfmt.Registry) return nil } -func (m *ClusterCreateParams) validateIngressVip(formats strfmt.Registry) error { - if swag.IsZero(m.IngressVip) { // not required - return nil - } - - if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { - return err - } - - return nil -} - func (m *ClusterCreateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/models/v2_cluster_update_params.go b/models/v2_cluster_update_params.go index 27bc059850..cf3edc1efc 100644 --- a/models/v2_cluster_update_params.go +++ b/models/v2_cluster_update_params.go @@ -24,10 +24,6 @@ type V2ClusterUpdateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` - // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ - APIVip *string `json:"api_vip,omitempty"` - // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -69,10 +65,6 @@ type V2ClusterUpdateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` - // (DEPRECATED) The virtual IP used for cluster ingress traffic. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ - IngressVip *string `json:"ingress_vip,omitempty"` - // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -131,10 +123,6 @@ type V2ClusterUpdateParams struct { func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { var res []error - if err := m.validateAPIVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -163,10 +151,6 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateIngressVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -209,18 +193,6 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { return nil } -func (m *V2ClusterUpdateParams) validateAPIVip(formats strfmt.Registry) error { - if swag.IsZero(m.APIVip) { // not required - return nil - } - - if err := validate.Pattern("api_vip", "body", *m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { - return err - } - - return nil -} - func (m *V2ClusterUpdateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -387,18 +359,6 @@ func (m *V2ClusterUpdateParams) validateIgnitionEndpoint(formats strfmt.Registry return nil } -func (m *V2ClusterUpdateParams) validateIngressVip(formats strfmt.Registry) error { - if swag.IsZero(m.IngressVip) { // not required - return nil - } - - if err := validate.Pattern("ingress_vip", "body", *m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { - return err - } - - return nil -} - func (m *V2ClusterUpdateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/restapi/embedded_spec.go b/restapi/embedded_spec.go index 54d14e9900..0109b0b18a 100644 --- a/restapi/embedded_spec.go +++ b/restapi/embedded_spec.go @@ -6009,11 +6009,6 @@ func init() { "type": "string", "format": "uuid" }, - "api_vip": { - "description": "(DEPRECATED) The virtual IP used to reach the OpenShift cluster's API.", - "type": "string", - "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$" - }, "api_vip_dns_name": { "description": "The domain name used to reach the OpenShift cluster API.", "type": "string", @@ -6205,11 +6200,6 @@ func init() { "type": "boolean", "default": false }, - "ingress_vip": { - "description": "(DEPRECATED) The virtual IP used for cluster ingress traffic.", - "type": "string", - "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$" - }, "ingress_vips": { "description": "The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", @@ -6443,11 +6433,6 @@ func init() { "type": "string", "x-nullable": true }, - "api_vip": { - "description": "(DEPRECATED) The virtual IP used to reach the OpenShift cluster's API.", - "type": "string", - "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$" - }, "api_vips": { "description": "The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", @@ -6532,11 +6517,6 @@ func init() { "description": "Explicit ignition endpoint overrides the default ignition endpoint.", "$ref": "#/definitions/ignition-endpoint" }, - "ingress_vip": { - "description": "(DEPRECATED) The virtual IP used for cluster ingress traffic.", - "type": "string", - "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$" - }, "ingress_vips": { "description": "The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", @@ -10045,12 +10025,6 @@ func init() { "type": "string", "x-nullable": true }, - "api_vip": { - "description": "(DEPRECATED) The virtual IP used to reach the OpenShift cluster's API.", - "type": "string", - "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$", - "x-nullable": true - }, "api_vip_dns_name": { "description": "The domain name used to reach the OpenShift cluster API.", "type": "string", @@ -10119,12 +10093,6 @@ func init() { "description": "Explicit ignition endpoint overrides the default ignition endpoint.", "$ref": "#/definitions/ignition-endpoint" }, - "ingress_vip": { - "description": "(DEPRECATED) The virtual IP used for cluster ingress traffic.", - "type": "string", - "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$", - "x-nullable": true - }, "ingress_vips": { "description": "The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", @@ -16493,11 +16461,6 @@ func init() { "type": "string", "format": "uuid" }, - "api_vip": { - "description": "(DEPRECATED) The virtual IP used to reach the OpenShift cluster's API.", - "type": "string", - "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$" - }, "api_vip_dns_name": { "description": "The domain name used to reach the OpenShift cluster API.", "type": "string", @@ -16689,11 +16652,6 @@ func init() { "type": "boolean", "default": false }, - "ingress_vip": { - "description": "(DEPRECATED) The virtual IP used for cluster ingress traffic.", - "type": "string", - "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$" - }, "ingress_vips": { "description": "The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", @@ -16927,11 +16885,6 @@ func init() { "type": "string", "x-nullable": true }, - "api_vip": { - "description": "(DEPRECATED) The virtual IP used to reach the OpenShift cluster's API.", - "type": "string", - "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$" - }, "api_vips": { "description": "The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", @@ -17016,11 +16969,6 @@ func init() { "description": "Explicit ignition endpoint overrides the default ignition endpoint.", "$ref": "#/definitions/ignition-endpoint" }, - "ingress_vip": { - "description": "(DEPRECATED) The virtual IP used for cluster ingress traffic.", - "type": "string", - "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$" - }, "ingress_vips": { "description": "The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", @@ -20468,12 +20416,6 @@ func init() { "type": "string", "x-nullable": true }, - "api_vip": { - "description": "(DEPRECATED) The virtual IP used to reach the OpenShift cluster's API.", - "type": "string", - "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$", - "x-nullable": true - }, "api_vip_dns_name": { "description": "The domain name used to reach the OpenShift cluster API.", "type": "string", @@ -20542,12 +20484,6 @@ func init() { "description": "Explicit ignition endpoint overrides the default ignition endpoint.", "$ref": "#/definitions/ignition-endpoint" }, - "ingress_vip": { - "description": "(DEPRECATED) The virtual IP used for cluster ingress traffic.", - "type": "string", - "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$", - "x-nullable": true - }, "ingress_vips": { "description": "The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", From 7a604eb0a131f50452bd95ae9b92373e2ef8d23c Mon Sep 17 00:00:00 2001 From: Nir Magnezi Date: Tue, 19 Sep 2023 12:22:11 +0300 Subject: [PATCH 3/9] MGMT-14810: Remove Singular VIPs from REST-API codebase --- internal/bminventory/inventory.go | 39 +- internal/bminventory/inventory_test.go | 836 ++++-------------- internal/cluster/cluster.go | 20 +- internal/cluster/cluster_test.go | 58 +- internal/cluster/common.go | 45 - internal/cluster/progress_test.go | 4 +- internal/cluster/transition.go | 54 +- internal/cluster/transition_test.go | 160 +--- internal/cluster/validations/validations.go | 108 +-- internal/common/common.go | 10 +- internal/common/common_test.go | 4 +- internal/common/test_configuration.go | 10 - .../clusterdeployments_controller.go | 17 +- .../clusterdeployments_controller_test.go | 96 +- internal/dns/dns.go | 4 +- internal/dns/dns_test.go | 13 +- internal/installcfg/builder/builder_test.go | 8 +- .../20221031103047_multiple_vips.go | 51 +- .../20221031103047_multiple_vips_test.go | 82 -- internal/network/dhcp_param_file.go | 9 +- internal/network/dhcp_param_file_test.go | 4 +- internal/network/machine_network_cidr_test.go | 38 +- internal/network/utils.go | 11 - internal/network/utils_test.go | 4 - internal/operators/odf/validation_test.go | 2 - internal/provider/baremetal/installConfig.go | 2 + internal/provider/nutanix/installConfig.go | 2 + internal/provider/registry/registry_test.go | 24 +- internal/provider/vsphere/installConfig.go | 2 + .../agent_based_installer_client_test.go | 4 - subsystem/cluster_test.go | 399 +-------- subsystem/ipv6_test.go | 2 - subsystem/kubeapi_test.go | 2 +- subsystem/utils_test.go | 8 +- .../assisted-service/models/cluster.go | 40 - .../models/cluster_create_params.go | 40 - .../models/v2_cluster_update_params.go | 40 - 37 files changed, 406 insertions(+), 1846 deletions(-) delete mode 100644 internal/migrations/20221031103047_multiple_vips_test.go diff --git a/internal/bminventory/inventory.go b/internal/bminventory/inventory.go index 0026ad3cc9..0fe2dba3c8 100644 --- a/internal/bminventory/inventory.go +++ b/internal/bminventory/inventory.go @@ -305,14 +305,6 @@ func (b *bareMetalInventory) updatePullSecret(pullSecret string, log logrus.Fiel func (b *bareMetalInventory) setDefaultRegisterClusterParams(ctx context.Context, params installer.V2RegisterClusterParams, id strfmt.UUID) (installer.V2RegisterClusterParams, error) { log := logutil.FromContext(ctx, b.log) - if params.NewClusterParams.APIVip != "" && len(params.NewClusterParams.APIVips) == 0 { - params.NewClusterParams.APIVips = []*models.APIVip{{IP: models.IP(params.NewClusterParams.APIVip), ClusterID: id}} - } - - if params.NewClusterParams.IngressVip != "" && len(params.NewClusterParams.IngressVip) == 0 { - params.NewClusterParams.IngressVips = []*models.IngressVip{{IP: models.IP(params.NewClusterParams.IngressVip), ClusterID: id}} - } - if params.NewClusterParams.ClusterNetworks == nil { params.NewClusterParams.ClusterNetworks = []*models.ClusterNetwork{ {Cidr: models.Subnet(b.Config.DefaultClusterNetworkCidr), HostPrefix: b.Config.DefaultClusterNetworkHostPrefix}, @@ -590,10 +582,8 @@ func (b *bareMetalInventory) RegisterClusterInternal( ID: &id, Href: swag.String(url.String()), Kind: swag.String(models.ClusterKindCluster), - APIVip: params.NewClusterParams.APIVip, APIVips: params.NewClusterParams.APIVips, BaseDNSDomain: params.NewClusterParams.BaseDNSDomain, - IngressVip: params.NewClusterParams.IngressVip, IngressVips: params.NewClusterParams.IngressVips, Name: swag.StringValue(params.NewClusterParams.Name), OpenshiftVersion: *releaseImage.Version, @@ -2140,15 +2130,9 @@ func (b *bareMetalInventory) updateNonDhcpNetworkParams(updates map[string]inter } reqDualStack := network.CheckIfClusterIsDualStack(&targetConfiguration) - if params.ClusterUpdateParams.APIVip != nil { - updates["api_vip"] = *params.ClusterUpdateParams.APIVip - } if params.ClusterUpdateParams.APIVips != nil { targetConfiguration.APIVips = params.ClusterUpdateParams.APIVips } - if params.ClusterUpdateParams.IngressVip != nil { - updates["ingress_vip"] = *params.ClusterUpdateParams.IngressVip - } if params.ClusterUpdateParams.IngressVips != nil { targetConfiguration.IngressVips = params.ClusterUpdateParams.IngressVips } @@ -2234,8 +2218,7 @@ func (b *bareMetalInventory) updateNonDhcpNetworkParams(updates map[string]inter } func (b *bareMetalInventory) updateDhcpNetworkParams(db *gorm.DB, id *strfmt.UUID, updates map[string]interface{}, params installer.V2UpdateClusterParams, primaryMachineCIDR string) error { - if err := validations.ValidateVIPsWereNotSetDhcpMode(swag.StringValue(params.ClusterUpdateParams.APIVip), swag.StringValue(params.ClusterUpdateParams.IngressVip), - params.ClusterUpdateParams.APIVips, params.ClusterUpdateParams.IngressVips); err != nil { + if err := validations.ValidateVIPsWereNotSetDhcpMode(params.ClusterUpdateParams.APIVips, params.ClusterUpdateParams.IngressVips); err != nil { return common.NewApiError(http.StatusBadRequest, err) } // VIPs are always allocated from the first provided machine network. We want to trigger @@ -2247,8 +2230,6 @@ func (b *bareMetalInventory) updateDhcpNetworkParams(db *gorm.DB, id *strfmt.UUI // Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1999297 // Ref.: https://github.com/openshift/assisted-service/pull/2512 if params.ClusterUpdateParams.MachineNetworks != nil && params.ClusterUpdateParams.MachineNetworks[0] != nil && string(params.ClusterUpdateParams.MachineNetworks[0].Cidr) != primaryMachineCIDR { - updates["api_vip"] = "" - updates["ingress_vip"] = "" emptyCluster := common.Cluster{Cluster: models.Cluster{ID: id}} if err := network.UpdateVipsTables(db, &emptyCluster, true, true); err != nil { return err @@ -2372,11 +2353,7 @@ func (b *bareMetalInventory) updateClusterData(_ context.Context, cluster *commo return nil } -func wereClusterVipsUpdated(clusterVip string, paramVip *string, clusterVips []string, paramVips []string) bool { - if paramVip != nil && clusterVip != swag.StringValue(paramVip) { - return true - } - +func wereClusterVipsUpdated(clusterVips []string, paramVips []string) bool { if paramVips == nil { return false } @@ -2402,15 +2379,13 @@ func (b *bareMetalInventory) updateVips(db *gorm.DB, params installer.V2UpdateCl }, } - if wereClusterVipsUpdated(cluster.APIVip, params.ClusterUpdateParams.APIVip, network.GetApiVips(cluster), network.GetApiVips(¶mVips)) { + if wereClusterVipsUpdated(network.GetApiVips(cluster), network.GetApiVips(¶mVips)) { apiVipUpdated = true - cluster.APIVip = swag.StringValue(params.ClusterUpdateParams.APIVip) cluster.APIVips = params.ClusterUpdateParams.APIVips } - if wereClusterVipsUpdated(cluster.IngressVip, params.ClusterUpdateParams.IngressVip, network.GetIngressVips(cluster), network.GetIngressVips(¶mVips)) { + if wereClusterVipsUpdated(network.GetIngressVips(cluster), network.GetIngressVips(¶mVips)) { ingressVipUpdated = true - cluster.IngressVip = swag.StringValue(params.ClusterUpdateParams.IngressVip) cluster.IngressVips = params.ClusterUpdateParams.IngressVips } @@ -2619,8 +2594,6 @@ func (b *bareMetalInventory) updateNetworkParams(params installer.V2UpdateCluste vipDhcpAllocation = swag.BoolValue(params.ClusterUpdateParams.VipDhcpAllocation) updates["vip_dhcp_allocation"] = vipDhcpAllocation updates["machine_network_cidr_updated_at"] = time.Now() - updates["api_vip"] = "" - updates["ingress_vip"] = "" cluster.MachineNetworks = []*models.MachineNetwork{} emptyCluster := common.Cluster{Cluster: models.Cluster{ID: cluster.ID}} if err = network.UpdateVipsTables(db, &emptyCluster, true, true); err != nil { @@ -2663,8 +2636,6 @@ func setCommonUserNetworkManagedParams(db *gorm.DB, id *strfmt.UUID, params *mod return err, false } updates["vip_dhcp_allocation"] = false - updates["api_vip"] = "" - updates["ingress_vip"] = "" emptyCluster := common.Cluster{Cluster: models.Cluster{ID: id}} if err = network.UpdateVipsTables(db, &emptyCluster, true, true); err != nil { return err, false @@ -2693,7 +2664,7 @@ func (b *bareMetalInventory) updateNtpSources(params installer.V2UpdateClusterPa } func validateUserManagedNetworkConflicts(params *models.V2ClusterUpdateParams, log logrus.FieldLogger) error { - if err := validations.ValidateVIPsWereNotSetUserManagedNetworking(swag.StringValue(params.APIVip), swag.StringValue(params.IngressVip), params.APIVips, params.IngressVips, swag.BoolValue(params.VipDhcpAllocation)); err != nil { + if err := validations.ValidateVIPsWereNotSetUserManagedNetworking(params.APIVips, params.IngressVips, swag.BoolValue(params.VipDhcpAllocation)); err != nil { log.WithError(err) return common.NewApiError(http.StatusBadRequest, err) } diff --git a/internal/bminventory/inventory_test.go b/internal/bminventory/inventory_test.go index 2c5e99d7f0..10113fea09 100644 --- a/internal/bminventory/inventory_test.go +++ b/internal/bminventory/inventory_test.go @@ -1036,7 +1036,7 @@ var _ = Describe("v2PostStepReply", func() { }, } Expect(db.Create(&cluster).Error).ToNot(HaveOccurred()) - params := makeStepReply(*clusterId, *hostId, makeResponseWithLeases(common.TestIPv4Networking.APIVip, common.TestIPv4Networking.IngressVip, "lease { hello abc; }", "lease { hello abc; }")) + params := makeStepReply(*clusterId, *hostId, makeResponseWithLeases(string(common.TestIPv4Networking.APIVips[0].IP), string(common.TestIPv4Networking.IngressVips[0].IP), "lease { hello abc; }", "lease { hello abc; }")) mockClusterApi.EXPECT().SetVipsData(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) reply := bm.V2PostStepReply(ctx, params) Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2PostStepReplyNoContent())) @@ -1051,7 +1051,7 @@ var _ = Describe("v2PostStepReply", func() { }, } Expect(db.Create(&cluster).Error).ToNot(HaveOccurred()) - params := makeStepReply(*clusterId, *hostId, makeResponseWithLeases(common.TestIPv4Networking.APIVip, common.TestIPv4Networking.IngressVip, "llease { hello abc; }", "lease { hello abc; }")) + params := makeStepReply(*clusterId, *hostId, makeResponseWithLeases(string(common.TestIPv4Networking.APIVips[0].IP), string(common.TestIPv4Networking.IngressVips[0].IP), "llease { hello abc; }", "lease { hello abc; }")) reply := bm.V2PostStepReply(ctx, params) Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2PostStepReplyInternalServerError())) }) @@ -1065,7 +1065,7 @@ var _ = Describe("v2PostStepReply", func() { }, } Expect(db.Create(&cluster).Error).ToNot(HaveOccurred()) - params := makeStepReply(*clusterId, *hostId, makeResponse(common.TestIPv4Networking.APIVip, common.TestIPv4Networking.IngressVip)) + params := makeStepReply(*clusterId, *hostId, makeResponse(string(common.TestIPv4Networking.APIVips[0].IP), string(common.TestIPv4Networking.IngressVips[0].IP))) mockClusterApi.EXPECT().SetVipsData(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) reply := bm.V2PostStepReply(ctx, params) Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2PostStepReplyNoContent())) @@ -1095,7 +1095,7 @@ var _ = Describe("v2PostStepReply", func() { }, } Expect(db.Create(&cluster).Error).ToNot(HaveOccurred()) - params := makeStepReply(*clusterId, *hostId, makeResponse(common.TestIPv4Networking.APIVip, common.TestIPv4Networking.IngressVip)) + params := makeStepReply(*clusterId, *hostId, makeResponse(string(common.TestIPv4Networking.APIVips[0].IP), string(common.TestIPv4Networking.IngressVips[0].IP))) reply := bm.V2PostStepReply(ctx, params) Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2PostStepReplyInternalServerError())) }) @@ -1109,7 +1109,7 @@ var _ = Describe("v2PostStepReply", func() { }, } Expect(db.Create(&cluster).Error).ToNot(HaveOccurred()) - params := makeStepReply(*clusterId, *hostId, makeResponse(common.TestIPv4Networking.APIVip, "1.2.4.11")) + params := makeStepReply(*clusterId, *hostId, makeResponse(string(common.TestIPv4Networking.APIVips[0].IP), "1.2.4.11")) reply := bm.V2PostStepReply(ctx, params) Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2PostStepReplyInternalServerError())) }) @@ -1119,14 +1119,14 @@ var _ = Describe("v2PostStepReply", func() { ID: clusterId, VipDhcpAllocation: swag.Bool(true), MachineNetworks: common.TestIPv4Networking.MachineNetworks, - APIVip: common.TestIPv4Networking.APIVip, - IngressVip: common.TestIPv4Networking.IngressVip, + APIVips: common.TestIPv4Networking.APIVips, + IngressVips: common.TestIPv4Networking.IngressVips, Status: swag.String(models.ClusterStatusInsufficient), }, } Expect(db.Create(&cluster).Error).ToNot(HaveOccurred()) params := makeStepReply(*clusterId, *hostId, makeResponse( - common.IncrementIPString(common.TestIPv4Networking.APIVip), common.IncrementIPString(common.TestIPv4Networking.IngressVip))) + common.IncrementIPString(string(common.TestIPv4Networking.APIVips[0].IP)), common.IncrementIPString(string(common.TestIPv4Networking.IngressVips[0].IP)))) mockClusterApi.EXPECT().SetVipsData(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) reply := bm.V2PostStepReply(ctx, params) Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2PostStepReplyNoContent())) @@ -1137,15 +1137,16 @@ var _ = Describe("v2PostStepReply", func() { ID: clusterId, VipDhcpAllocation: swag.Bool(true), MachineNetworks: common.TestIPv4Networking.MachineNetworks, - APIVip: common.TestIPv4Networking.APIVip, - IngressVip: common.TestIPv4Networking.IngressVip, + APIVips: common.TestIPv4Networking.APIVips, + IngressVips: common.TestIPv4Networking.IngressVips, Status: swag.String(models.ClusterStatusInstalling), }, } Expect(db.Create(&cluster).Error).ToNot(HaveOccurred()) mockClusterApi.EXPECT().SetVipsData(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(errors.New("Stam")) + params := makeStepReply(*clusterId, *hostId, makeResponse( - common.IncrementIPString(common.TestIPv4Networking.APIVip), common.IncrementIPString(common.TestIPv4Networking.IngressVip))) + common.IncrementIPString(string(common.TestIPv4Networking.APIVips[0].IP)), common.IncrementIPString(string(common.TestIPv4Networking.IngressVips[0].IP)))) reply := bm.V2PostStepReply(ctx, params) Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2PostStepReplyInternalServerError())) }) @@ -1643,8 +1644,8 @@ var _ = Describe("cluster", func() { err := db.Create(&common.Cluster{Cluster: models.Cluster{ ID: &clusterID, OpenshiftVersion: common.TestDefaultConfig.OpenShiftVersion, - APIVip: "10.11.12.13", - IngressVip: "10.11.12.14", + APIVips: []*models.APIVip{{IP: "10.11.12.13"}}, + IngressVips: []*models.IngressVip{{IP: "10.11.12.14"}}, MachineNetworks: []*models.MachineNetwork{{Cidr: "10.11.0.0/16"}}, Platform: &models.Platform{ Type: common.PlatformTypePtr(models.PlatformTypeBaremetal), @@ -1787,8 +1788,8 @@ var _ = Describe("cluster", func() { actual, ok := reply.(*installer.V2GetClusterOK) Expect(ok).To(BeTrue()) Expect(actual.Payload.Hosts).To(HaveLen(3)) - Expect(actual.Payload.APIVip).To(BeEquivalentTo("10.11.12.13")) - Expect(actual.Payload.IngressVip).To(BeEquivalentTo("10.11.12.14")) + Expect(string(actual.Payload.APIVips[0].IP)).To(BeEquivalentTo("10.11.12.13")) + Expect(string(actual.Payload.IngressVips[0].IP)).To(BeEquivalentTo("10.11.12.14")) validateNetworkConfiguration(actual.Payload, nil, nil, &[]*models.MachineNetwork{{Cidr: "10.11.0.0/16"}}) expectedNetworks := sortedNetworks([]*models.HostNetwork{ { @@ -1829,8 +1830,8 @@ var _ = Describe("cluster", func() { actual, ok := reply.(*installer.V2GetClusterOK) Expect(ok).To(BeTrue()) Expect(actual.Payload.Hosts).To(BeEmpty()) - Expect(actual.Payload.APIVip).To(BeEquivalentTo("10.11.12.13")) - Expect(actual.Payload.IngressVip).To(BeEquivalentTo("10.11.12.14")) + Expect(string(actual.Payload.APIVips[0].IP)).To(BeEquivalentTo("10.11.12.13")) + Expect(string(actual.Payload.IngressVips[0].IP)).To(BeEquivalentTo("10.11.12.14")) validateNetworkConfiguration(actual.Payload, nil, nil, &[]*models.MachineNetwork{{Cidr: "10.11.0.0/16"}}) Expect(actual.Payload.HostNetworks).To(BeEmpty()) }) @@ -2066,8 +2067,8 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, }, }) Expect(reply).To(BeAssignableToTypeOf(common.NewApiError(http.StatusConflict, errors.Errorf("error")))) @@ -2195,156 +2196,14 @@ var _ = Describe("cluster", func() { } Context("V2RegisterCluster", func() { + var openshiftVersion string + BeforeEach(func() { + openshiftVersion = "4.12.0" bm.clusterApi = cluster.NewManager(cluster.Config{}, common.GetTestLog().WithField("pkg", "cluster-monitor"), db, commontesting.GetDummyNotificationStream(ctrl), mockEvents, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) }) Context("RegisterCluster - Multiple-VIPs Support", func() { - var openshiftVersion = "4.12.0" - - Context("API and Ingress VIPs Backwards Compatibility", func() { - - It("API VIP and Ingress VIP populated in APIVips and IngressVips", func() { - mockClusterRegisterSuccess(true) - - apiVip := "8.8.8.8" - ingressVip := "8.8.8.9" - reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - Name: swag.String("some-cluster-name"), - OpenshiftVersion: swag.String(openshiftVersion), - PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, - IngressVip: ingressVip, - }, - }) - Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2RegisterClusterCreated())) - cluster := &common.Cluster{Cluster: *reply.(*installer.V2RegisterClusterCreated).Payload} - Expect(cluster.APIVip).To(Equal(apiVip)) - Expect(network.GetApiVipById(cluster, 0)).To(Equal(apiVip)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) - Expect(network.GetIngressVipById(cluster, 0)).To(Equal(ingressVip)) - }) - - It("API VIP match APIVips first element", func() { - mockClusterRegisterSuccess(true) - - apiVip := "8.8.8.8" - apiVips := []*models.APIVip{{IP: models.IP(apiVip)}} - ingressVip := "8.8.8.9" - reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - Name: swag.String("some-cluster-name"), - OpenshiftVersion: swag.String(openshiftVersion), - PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, - APIVips: apiVips, - IngressVip: ingressVip, - }, - }) - Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2RegisterClusterCreated())) - cluster := &common.Cluster{Cluster: *reply.(*installer.V2RegisterClusterCreated).Payload} - Expect(cluster.APIVip).To(Equal(apiVip)) - Expect(cluster.APIVips).To(Equal(apiVips)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) - Expect(network.GetIngressVipById(cluster, 0)).To(Equal(ingressVip)) - }) - - It("Ingress VIP match IngressVips first element", func() { - mockClusterRegisterSuccess(true) - - apiVip := "8.8.8.8" - ingressVip := "8.8.8.9" - ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}} - - reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - Name: swag.String("some-cluster-name"), - OpenshiftVersion: swag.String(openshiftVersion), - PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, - IngressVip: ingressVip, - IngressVips: ingressVips, - }, - }) - Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2RegisterClusterCreated())) - cluster := reply.(*installer.V2RegisterClusterCreated).Payload - Expect(cluster.APIVip).To(Equal(apiVip)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) - Expect(cluster.IngressVips).To(Equal(ingressVips)) - }) - - It("API VIP not matching APIVips first element", func() { - apiVip := "8.8.8.8" - apiVips := []*models.APIVip{{IP: models.IP("8.8.8.7")}} - ingressVip := "8.8.8.9" - err := "apiVIP must be the same as the first element of apiVIPs" - - reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - Name: swag.String("some-cluster-name"), - OpenshiftVersion: swag.String(openshiftVersion), - PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, - APIVips: apiVips, - IngressVip: ingressVip, - }, - }) - verifyApiErrorString(reply, http.StatusBadRequest, err) - }) - - It("Ingress VIP not matching IngressVips first element", func() { - apiVip := "8.8.8.8" - ingressVip := "8.8.8.9" - ingressVips := []*models.IngressVip{{IP: models.IP("8.8.8.7")}} - err := "ingressVIP must be the same as the first element of ingressVIPs" - - reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - Name: swag.String("some-cluster-name"), - OpenshiftVersion: swag.String(openshiftVersion), - PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, - IngressVip: ingressVip, - IngressVips: ingressVips, - }, - }) - verifyApiErrorString(reply, http.StatusBadRequest, err) - }) - - It("Reject APIVips if no APIVip was provided", func() { - apiVips := []*models.APIVip{{IP: models.IP("8.8.8.7")}} - ingressVip := "8.8.8.9" - err := "request must include apiVIP alongside apiVIPs" - reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - Name: swag.String("some-cluster-name"), - OpenshiftVersion: swag.String(openshiftVersion), - PullSecret: swag.String(fakePullSecret), - APIVips: apiVips, - IngressVip: ingressVip, - }, - }) - verifyApiErrorString(reply, http.StatusBadRequest, err) - }) - - It("Reject IngressVips if no IngressVip was provided", func() { - apiVip := "8.8.8.9" - ingressVips := []*models.IngressVip{{IP: models.IP("8.8.8.7")}} - err := "request must include ingressVIP alongside ingressVIPs" - reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - Name: swag.String("some-cluster-name"), - OpenshiftVersion: swag.String(openshiftVersion), - PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, - IngressVips: ingressVips, - }, - }) - verifyApiErrorString(reply, http.StatusBadRequest, err) - }) - - }) It("Two APIVips and Two IngressVips - both IPv4 - negative", func() { apiVip := "8.8.8.7" @@ -2357,9 +2216,7 @@ var _ = Describe("cluster", func() { Name: swag.String("some-cluster-name"), OpenshiftVersion: swag.String(openshiftVersion), PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -2379,17 +2236,13 @@ var _ = Describe("cluster", func() { Name: swag.String("some-cluster-name"), OpenshiftVersion: swag.String(openshiftVersion), PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2RegisterClusterCreated())) cluster := reply.(*installer.V2RegisterClusterCreated).Payload - Expect(cluster.APIVip).To(Equal(apiVip)) Expect(cluster.APIVips).To(Equal(apiVips)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) Expect(cluster.IngressVips).To(Equal(ingressVips)) }) @@ -2404,9 +2257,7 @@ var _ = Describe("cluster", func() { Name: swag.String("some-cluster-name"), OpenshiftVersion: swag.String(openshiftVersion), PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -2424,9 +2275,7 @@ var _ = Describe("cluster", func() { Name: swag.String("some-cluster-name"), OpenshiftVersion: swag.String(openshiftVersion), PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -2445,9 +2294,7 @@ var _ = Describe("cluster", func() { Name: swag.String("some-cluster-name"), OpenshiftVersion: swag.String(openshiftVersion), PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -2466,9 +2313,7 @@ var _ = Describe("cluster", func() { Name: swag.String("some-cluster-name"), OpenshiftVersion: swag.String(openshiftVersion), PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -2487,9 +2332,7 @@ var _ = Describe("cluster", func() { Name: swag.String("some-cluster-name"), OpenshiftVersion: swag.String(openshiftVersion), PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -2508,9 +2351,7 @@ var _ = Describe("cluster", func() { Name: swag.String("some-cluster-name"), OpenshiftVersion: swag.String(openshiftVersion), PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -2529,9 +2370,7 @@ var _ = Describe("cluster", func() { Name: swag.String("some-cluster-name"), OpenshiftVersion: swag.String(openshiftVersion), PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -2550,9 +2389,7 @@ var _ = Describe("cluster", func() { Name: swag.String("some-cluster-name"), OpenshiftVersion: swag.String(openshiftVersion), PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -2570,9 +2407,7 @@ var _ = Describe("cluster", func() { Name: swag.String("some-cluster-name"), OpenshiftVersion: swag.String(openshiftVersion), PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, APIVips: apiVips, - IngressVip: apiVip, IngressVips: ingressVips, }, }) @@ -2580,7 +2415,7 @@ var _ = Describe("cluster", func() { }) Context("forbidden with OCP pre-4.12", func() { - var openshiftVersion = "4.11.0" + openshiftVersion = "4.11.0" It("2 APIVips and 2 IngressVips", func() { apiVip := "8.8.8.7" @@ -2591,51 +2426,9 @@ var _ = Describe("cluster", func() { reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ NewClusterParams: &models.ClusterCreateParams{ Name: swag.String("some-cluster-name"), - OpenshiftVersion: swag.String(openshiftVersion), + OpenshiftVersion: swag.String("4.11.0"), PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, - IngressVips: ingressVips, - }, - }) - verifyApiErrorString(reply, http.StatusBadRequest, err) - }) - - It("2 APIVips and 1 IngressVip", func() { - apiVip := "8.8.8.7" - ingressVip := "8.8.8.1" - apiVips := []*models.APIVip{{IP: models.IP(apiVip)}, {IP: models.IP("2001:db8::1")}} - ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}} - err := "dual-stack VIPs are not supported in OpenShift 4.11.0" - reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - Name: swag.String("some-cluster-name"), - OpenshiftVersion: swag.String(openshiftVersion), - PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, - APIVips: apiVips, - IngressVip: ingressVip, - IngressVips: ingressVips, - }, - }) - verifyApiErrorString(reply, http.StatusBadRequest, err) - }) - - It("1 APIVip and 2 IngressVips", func() { - apiVip := "8.8.8.7" - ingressVip := "8.8.8.1" - apiVips := []*models.APIVip{{IP: models.IP(apiVip)}} - ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}, {IP: models.IP("2001:db8::2")}} - err := "dual-stack VIPs are not supported in OpenShift 4.11.0" - reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - Name: swag.String("some-cluster-name"), - OpenshiftVersion: swag.String(openshiftVersion), - PullSecret: swag.String(fakePullSecret), - APIVip: apiVip, - APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -3141,219 +2934,7 @@ var _ = Describe("cluster", func() { common.DeleteTestDB(db, dbName) }) - Context("API and Ingress VIPs Backwards Compatibility", func() { - - It("API VIP and Ingress VIP populated in APIVips and ingressVips", func() { - mockDetectAndStoreCollidingIPsForCluster(mockClusterApi, 1) - mockClusterApi.EXPECT().VerifyClusterUpdatability(createClusterIdMatcher(cluster)).Return(nil).Times(1) - mockClusterApi.EXPECT().SetConnectivityMajorityGroupsForCluster(gomock.Any(), gomock.Any()).Return(nil).Times(1) - mockClusterApi.EXPECT().RefreshStatus(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil).Times(1) - mockHostApi.EXPECT().RefreshInventory(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(3) - mockHostApi.EXPECT().RefreshStatus(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(3) - mockHostApi.EXPECT().GetStagesByRole(gomock.Any(), gomock.Any()).Return(nil).Times(3) - - apiVip := "1.2.3.100" - ingressVip := "1.2.3.101" - reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ - ClusterID: clusterID, - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), - }, - }) - Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) - cluster = &common.Cluster{Cluster: *reply.(*installer.V2UpdateClusterCreated).Payload} - Expect(cluster.APIVip).To(Equal(apiVip)) - Expect(network.GetApiVipById(cluster, 0)).To(Equal(apiVip)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) - Expect(network.GetIngressVipById(cluster, 0)).To(Equal(ingressVip)) - }) - - It("API VIP match APIVips first element", func() { - mockDetectAndStoreCollidingIPsForCluster(mockClusterApi, 1) - mockClusterApi.EXPECT().VerifyClusterUpdatability(createClusterIdMatcher(cluster)).Return(nil).Times(1) - mockClusterApi.EXPECT().SetConnectivityMajorityGroupsForCluster(gomock.Any(), gomock.Any()).Return(nil).Times(1) - mockClusterApi.EXPECT().RefreshStatus(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil).Times(1) - mockHostApi.EXPECT().RefreshInventory(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(3) - mockHostApi.EXPECT().RefreshStatus(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(3) - mockHostApi.EXPECT().GetStagesByRole(gomock.Any(), gomock.Any()).Return(nil).Times(3) - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) - - apiVip := "1.2.3.100" - apiVips := []*models.APIVip{{IP: models.IP(apiVip)}} - ingressVip := "1.2.3.101" - reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ - ClusterID: clusterID, - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - Name: swag.String("some-cluster-name"), - PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), - APIVips: apiVips, - IngressVip: swag.String(ingressVip), - }, - }) - Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) - cluster = &common.Cluster{Cluster: *reply.(*installer.V2UpdateClusterCreated).Payload} - Expect(cluster.APIVip).To(Equal(apiVip)) - Expect(cluster.APIVips).To(Equal(apiVips)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) - Expect(network.GetIngressVipById(cluster, 0)).To(Equal(ingressVip)) - }) - - It("Ingress VIP match ingressVips first element", func() { - mockDetectAndStoreCollidingIPsForCluster(mockClusterApi, 1) - mockClusterApi.EXPECT().VerifyClusterUpdatability(createClusterIdMatcher(cluster)).Return(nil).Times(1) - mockClusterApi.EXPECT().SetConnectivityMajorityGroupsForCluster(gomock.Any(), gomock.Any()).Return(nil).Times(1) - mockClusterApi.EXPECT().RefreshStatus(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil).Times(1) - mockHostApi.EXPECT().RefreshInventory(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(3) - mockHostApi.EXPECT().RefreshStatus(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(3) - mockHostApi.EXPECT().GetStagesByRole(gomock.Any(), gomock.Any()).Return(nil).Times(3) - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) - - apiVip := "1.2.3.100" - ingressVip := "1.2.3.101" - ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}} - - reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ - ClusterID: clusterID, - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - Name: swag.String("some-cluster-name"), - PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), - IngressVips: ingressVips, - }, - }) - Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) - cluster := reply.(*installer.V2UpdateClusterCreated).Payload - Expect(cluster.APIVip).To(Equal(apiVip)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) - Expect(cluster.IngressVips).To(Equal(ingressVips)) - }) - - It("API VIP not matching APIVips first element", func() { - apiVip := "1.2.3.100" - apiVips := []*models.APIVip{{IP: models.IP("1.2.3.111")}} - ingressVip := "1.2.3.101" - err := "apiVIP must be the same as the first element of apiVIPs" - - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) - - reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ - ClusterID: clusterID, - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - Name: swag.String("some-cluster-name"), - PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), - APIVips: apiVips, - IngressVip: swag.String(ingressVip), - }, - }) - verifyApiErrorString(reply, http.StatusBadRequest, err) - }) - - It("Ingress VIP not matching ingressVips first element", func() { - apiVip := "1.2.3.100" - ingressVip := "1.2.3.101" - ingressVips := []*models.IngressVip{{IP: models.IP("1.2.3.111")}} - err := "ingressVIP must be the same as the first element of ingressVIPs" - - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) - - reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ - ClusterID: clusterID, - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - Name: swag.String("some-cluster-name"), - PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), - IngressVips: ingressVips, - }, - }) - verifyApiErrorString(reply, http.StatusBadRequest, err) - }) - - It("Reject APIVips if no APIVip was provided", func() { - apiVips := []*models.APIVip{{IP: models.IP("1.2.3.111")}} - ingressVip := "1.2.3.101" - err := "request must include apiVIP alongside apiVIPs" - - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) - - reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ - ClusterID: clusterID, - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - Name: swag.String("some-cluster-name"), - PullSecret: swag.String(fakePullSecret), - APIVips: apiVips, - IngressVip: swag.String(ingressVip), - }, - }) - verifyApiErrorString(reply, http.StatusBadRequest, err) - }) - - It("Reject ingressVips if no ingressVip was provided", func() { - apiVip := "1.2.3.100" - ingressVips := []*models.IngressVip{{IP: models.IP("1.2.3.111")}} - err := "request must include ingressVIP alongside ingressVIPs" - - mockSecretValidator.EXPECT().ValidatePullSecret(gomock.Any(), gomock.Any()).Return(nil).Times(1) - - reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ - ClusterID: clusterID, - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - Name: swag.String("some-cluster-name"), - PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), - IngressVips: ingressVips, - }, - }) - verifyApiErrorString(reply, http.StatusBadRequest, err) - }) - - }) - - It("Test VIP cleanup via singular APIVip and IngressVip", func() { - mockDetectAndStoreCollidingIPsForCluster(mockClusterApi, 2) - mockClusterApi.EXPECT().VerifyClusterUpdatability(createClusterIdMatcher(cluster)).Return(nil).Times(2) - mockClusterApi.EXPECT().SetConnectivityMajorityGroupsForCluster(gomock.Any(), gomock.Any()).Return(nil).Times(2) - mockClusterApi.EXPECT().RefreshStatus(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil).Times(2) - mockHostApi.EXPECT().RefreshInventory(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(6) - mockHostApi.EXPECT().RefreshStatus(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(6) - mockHostApi.EXPECT().GetStagesByRole(gomock.Any(), gomock.Any()).Return(nil).Times(6) - - apiVip := "1.2.3.100" - ingressVip := "1.2.3.101" - reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ - ClusterID: clusterID, - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), - }, - }) - Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) - cluster = &common.Cluster{Cluster: *reply.(*installer.V2UpdateClusterCreated).Payload} - Expect(cluster.APIVip).To(Equal(apiVip)) - Expect(network.GetApiVipById(cluster, 0)).To(Equal(apiVip)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) - Expect(network.GetIngressVipById(cluster, 0)).To(Equal(ingressVip)) - - reply = bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ - ClusterID: clusterID, - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(""), - IngressVip: swag.String(""), - }, - }) - Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) - cluster = &common.Cluster{Cluster: *reply.(*installer.V2UpdateClusterCreated).Payload} - Expect(cluster.APIVip).To(Equal("")) - Expect(len(cluster.APIVips)).To(BeZero()) - Expect(cluster.IngressVip).To(Equal("")) - Expect(len(cluster.IngressVips)).To(BeZero()) - }) - - It("Test VIP cleanup via both singular and plural VIP values", func() { + It("Test VIPs cleanup", func() { mockDetectAndStoreCollidingIPsForCluster(mockClusterApi, 2) mockClusterApi.EXPECT().VerifyClusterUpdatability(createClusterIdMatcher(cluster)).Return(nil).Times(2) mockClusterApi.EXPECT().SetConnectivityMajorityGroupsForCluster(gomock.Any(), gomock.Any()).Return(nil).Times(2) @@ -3367,31 +2948,27 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, }, }) Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) cluster = &common.Cluster{Cluster: *reply.(*installer.V2UpdateClusterCreated).Payload} - Expect(cluster.APIVip).To(Equal(apiVip)) + Expect(string(cluster.APIVips[0].IP)).To(Equal(apiVip)) Expect(network.GetApiVipById(cluster, 0)).To(Equal(apiVip)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) + Expect(string(cluster.IngressVips[0].IP)).To(Equal(ingressVip)) Expect(network.GetIngressVipById(cluster, 0)).To(Equal(ingressVip)) reply = bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(""), - IngressVip: swag.String(""), - APIVips: nil, - IngressVips: nil, + APIVips: []*models.APIVip{}, + IngressVips: []*models.IngressVip{}, }, }) Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) cluster = &common.Cluster{Cluster: *reply.(*installer.V2UpdateClusterCreated).Payload} - Expect(cluster.APIVip).To(Equal("")) Expect(len(cluster.APIVips)).To(BeZero()) - Expect(cluster.IngressVip).To(Equal("")) Expect(len(cluster.IngressVips)).To(BeZero()) }) @@ -3409,9 +2986,7 @@ var _ = Describe("cluster", func() { ClusterUpdateParams: &models.V2ClusterUpdateParams{ Name: swag.String("some-cluster-name"), PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(ingressVip), IngressVips: ingressVips, }, }) @@ -3438,17 +3013,13 @@ var _ = Describe("cluster", func() { ClusterUpdateParams: &models.V2ClusterUpdateParams{ Name: swag.String("some-cluster-name"), PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(ingressVip), IngressVips: ingressVips, }, }) Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) cluster := reply.(*installer.V2UpdateClusterCreated).Payload - Expect(cluster.APIVip).To(Equal(apiVip)) Expect(cluster.APIVips).To(Equal(apiVips)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) Expect(cluster.IngressVips).To(Equal(ingressVips)) }) @@ -3466,9 +3037,7 @@ var _ = Describe("cluster", func() { ClusterUpdateParams: &models.V2ClusterUpdateParams{ Name: swag.String("some-cluster-name"), PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(ingressVip), IngressVips: ingressVips, }, }) @@ -3489,9 +3058,7 @@ var _ = Describe("cluster", func() { ClusterUpdateParams: &models.V2ClusterUpdateParams{ Name: swag.String("some-cluster-name"), PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(ingressVip), IngressVips: ingressVips, }, }) @@ -3512,9 +3079,7 @@ var _ = Describe("cluster", func() { ClusterUpdateParams: &models.V2ClusterUpdateParams{ Name: swag.String("some-cluster-name"), PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(ingressVip), IngressVips: ingressVips, }, }) @@ -3535,9 +3100,7 @@ var _ = Describe("cluster", func() { ClusterUpdateParams: &models.V2ClusterUpdateParams{ Name: swag.String("some-cluster-name"), PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(ingressVip), IngressVips: ingressVips, }, }) @@ -3558,9 +3121,7 @@ var _ = Describe("cluster", func() { ClusterUpdateParams: &models.V2ClusterUpdateParams{ Name: swag.String("some-cluster-name"), PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(ingressVip), IngressVips: ingressVips, }, }) @@ -3581,9 +3142,7 @@ var _ = Describe("cluster", func() { ClusterUpdateParams: &models.V2ClusterUpdateParams{ Name: swag.String("some-cluster-name"), PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(ingressVip), IngressVips: ingressVips, }, }) @@ -3604,9 +3163,7 @@ var _ = Describe("cluster", func() { ClusterUpdateParams: &models.V2ClusterUpdateParams{ Name: swag.String("some-cluster-name"), PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(ingressVip), IngressVips: ingressVips, }, }) @@ -3627,9 +3184,7 @@ var _ = Describe("cluster", func() { ClusterUpdateParams: &models.V2ClusterUpdateParams{ Name: swag.String("some-cluster-name"), PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(ingressVip), IngressVips: ingressVips, }, }) @@ -3649,9 +3204,7 @@ var _ = Describe("cluster", func() { ClusterUpdateParams: &models.V2ClusterUpdateParams{ Name: swag.String("some-cluster-name"), PullSecret: swag.String(fakePullSecret), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(apiVip), IngressVips: ingressVips, }, }) @@ -4059,10 +3612,16 @@ var _ = Describe("cluster", func() { }) It("Set Machine CIDR", func() { - Expect(db.Model(&common.Cluster{}).Where("id = ?", clusterID).Updates(map[string]interface{}{ - "api_vip": common.TestIPv4Networking.APIVip, - "ingress_vip": common.TestIPv4Networking.IngressVip, - }).Error).ShouldNot(HaveOccurred()) + err := network.UpdateVipsTables(db, + &common.Cluster{Cluster: models.Cluster{ + ID: &clusterID, + APIVips: common.TestIPv4Networking.APIVips, + IngressVips: common.TestIPv4Networking.IngressVips, + }}, + true, + true, + ) + Expect(err).ShouldNot(HaveOccurred()) mockSuccess(1) @@ -4076,8 +3635,8 @@ var _ = Describe("cluster", func() { Expect(reply).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) actual := reply.(*installer.V2UpdateClusterCreated) Expect(actual.Payload.VipDhcpAllocation).To(Equal(swag.Bool(false))) - Expect(actual.Payload.APIVip).To(Equal("")) - Expect(actual.Payload.IngressVip).To(Equal("")) + Expect(len(actual.Payload.APIVips)).To(BeZero()) + Expect(len(actual.Payload.IngressVips)).To(BeZero()) validateNetworkConfiguration(actual.Payload, nil, nil, &machineNetworks) }) @@ -4106,61 +3665,14 @@ var _ = Describe("cluster", func() { Expect(reply).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) actual := reply.(*installer.V2UpdateClusterCreated) Expect(actual.Payload.VipDhcpAllocation).To(Equal(swag.Bool(false))) - Expect(actual.Payload.APIVip).To(Equal("")) - Expect(actual.Payload.IngressVip).To(Equal("")) + Expect(len(actual.Payload.APIVips)).To(BeZero()) + Expect(len(actual.Payload.IngressVips)).To(BeZero()) validateNetworkConfiguration(actual.Payload, nil, nil, &wrongMachineCidrNetworks) }) }) Context("UserManagedNetworking", func() { - It("handle UserManagedNetworking and Singular VIPs update at the same request", func() { - mockClusterUpdatability(3) - mockDetectAndStoreCollidingIPsForCluster(mockClusterApi, 3) - mockHostApi.EXPECT().RefreshInventory(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() - mockHostApi.EXPECT().RefreshStatus(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() - mockHostApi.EXPECT().GetStagesByRole(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() - mockClusterApi.EXPECT().SetConnectivityMajorityGroupsForCluster(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() - mockClusterApi.EXPECT().RefreshStatus(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes() - mockProviderRegistry.EXPECT().SetPlatformUsages(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() - - apiVip := "10.11.12.15" - ingressVip := "10.11.12.16" - - By("Set User Managed Networking: false + Add APIVip and IngressVip") - reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ - ClusterID: clusterID, - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - UserManagedNetworking: swag.Bool(false), - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), - }, - }) - Expect(reply).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) - - By("Set UserManagedNetworking true + Remove APIVip and IngressVip") - reply = bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ - ClusterID: clusterID, - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - UserManagedNetworking: swag.Bool(true), - APIVip: swag.String(""), - IngressVip: swag.String(""), - }, - }) - Expect(reply).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) - - By("Set User Managed Networking: false + Add APIVip and IngressVip again") - reply = bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ - ClusterID: clusterID, - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - UserManagedNetworking: swag.Bool(false), - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), - }, - }) - Expect(reply).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) - }) - It("handle UserManagedNetworking and VIP arrays update at the same request", func() { mockClusterUpdatability(3) mockDetectAndStoreCollidingIPsForCluster(mockClusterApi, 3) @@ -4179,9 +3691,7 @@ var _ = Describe("cluster", func() { ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ UserManagedNetworking: swag.Bool(false), - APIVip: swag.String(apiVip), APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, - IngressVip: swag.String(ingressVip), IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, }, }) @@ -4192,9 +3702,7 @@ var _ = Describe("cluster", func() { ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ UserManagedNetworking: swag.Bool(true), - APIVip: swag.String(""), APIVips: []*models.APIVip{}, - IngressVip: swag.String(""), IngressVips: []*models.IngressVip{}, }, }) @@ -4205,9 +3713,7 @@ var _ = Describe("cluster", func() { ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ UserManagedNetworking: swag.Bool(false), - APIVip: swag.String(apiVip), APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, - IngressVip: swag.String(ingressVip), IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, }, }) @@ -4246,11 +3752,11 @@ var _ = Describe("cluster", func() { reply = bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String("10.11.12.15"), - IngressVip: swag.String("10.11.12.16"), + APIVips: []*models.APIVip{{IP: "10.11.12.15"}}, + IngressVips: []*models.IngressVip{{IP: "10.11.12.16"}}, }, }) - verifyApiErrorString(reply, http.StatusBadRequest, "API VIP cannot be set with User Managed Networking") + verifyApiErrorString(reply, http.StatusBadRequest, "API VIPs cannot be set with User Managed Networking") }) It("Fail to set UserManagedNetworking true when cluster VIPs were set", func() { @@ -4275,8 +3781,8 @@ var _ = Describe("cluster", func() { reply = bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String("10.11.12.15"), - IngressVip: swag.String("10.11.12.16"), + APIVips: []*models.APIVip{{IP: "10.11.12.15"}}, + IngressVips: []*models.IngressVip{{IP: "10.11.12.16"}}, }, }) Expect(reply).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) @@ -4314,8 +3820,8 @@ var _ = Describe("cluster", func() { reply = bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String("10.11.12.15"), - IngressVip: swag.String("10.11.12.16"), + APIVips: []*models.APIVip{{IP: "10.11.12.15"}}, + IngressVips: []*models.IngressVip{{IP: "10.11.12.16"}}, }, }) Expect(reply).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) @@ -4367,17 +3873,13 @@ var _ = Describe("cluster", func() { By("Update VIPS in DB cluster to mimic DHCP allocation") cluster, err := common.GetClusterFromDB(db, clusterID, common.SkipEagerLoading) Expect(err).ToNot(HaveOccurred()) - cluster.APIVip = apiVip cluster.APIVips = []*models.APIVip{{IP: models.IP(apiVip)}} - cluster.IngressVip = ingressVip cluster.IngressVips = []*models.IngressVip{{IP: models.IP(ingressVip)}} db.Save(&cluster) By("Verify VIPs updates") replay := bm.V2GetCluster(ctx, installer.V2GetClusterParams{ClusterID: clusterID}).(*installer.V2GetClusterOK) - Expect(replay.Payload.APIVip).Should(Equal(apiVip)) Expect(len(replay.Payload.APIVips)).Should(Equal(1)) - Expect(replay.Payload.IngressVip).Should(Equal(ingressVip)) Expect(len(replay.Payload.IngressVips)).Should(Equal(1)) By("Set User Managed Networking: true and VipDhcpAllocation: false") @@ -4392,9 +3894,7 @@ var _ = Describe("cluster", func() { By("Verify that DHCP VIPs were cleared") replay = bm.V2GetCluster(ctx, installer.V2GetClusterParams{ClusterID: clusterID}).(*installer.V2GetClusterOK) - Expect(replay.Payload.APIVip).Should(Equal("")) Expect(len(replay.Payload.APIVips)).Should(BeZero()) - Expect(replay.Payload.IngressVip).Should(Equal("")) Expect(len(replay.Payload.IngressVips)).Should(BeZero()) }) @@ -4433,8 +3933,8 @@ var _ = Describe("cluster", func() { actual := reply.(*installer.V2UpdateClusterCreated) Expect(actual.Payload.UserManagedNetworking).To(Equal(swag.Bool(true))) Expect(actual.Payload.VipDhcpAllocation).To(Equal(swag.Bool(false))) - Expect(actual.Payload.APIVip).To(Equal("")) - Expect(actual.Payload.IngressVip).To(Equal("")) + Expect(len(actual.Payload.APIVips)).Should(BeZero()) + Expect(len(actual.Payload.IngressVips)).Should(BeZero()) validateNetworkConfiguration(actual.Payload, nil, nil, &[]*models.MachineNetwork{}) }) @@ -4470,8 +3970,8 @@ var _ = Describe("cluster", func() { ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ UserManagedNetworking: swag.Bool(true), - APIVip: swag.String("10.35.20.9"), - IngressVip: swag.String("10.35.20.10"), + APIVips: []*models.APIVip{{IP: "10.35.20.9"}}, + IngressVips: []*models.IngressVip{{IP: "10.35.20.10"}}, }, }) verifyApiErrorString(reply, http.StatusBadRequest, "User Managed Networking cannot be set with API VIP") @@ -4483,7 +3983,7 @@ var _ = Describe("cluster", func() { ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ UserManagedNetworking: swag.Bool(true), - APIVip: swag.String("10.35.20.10"), + APIVips: []*models.APIVip{{IP: "10.35.20.10"}}, }, }) verifyApiErrorString(reply, http.StatusBadRequest, "User Managed Networking cannot be set with API VIP") @@ -4493,7 +3993,7 @@ var _ = Describe("cluster", func() { ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ UserManagedNetworking: swag.Bool(true), - IngressVip: swag.String("10.35.20.10"), + IngressVips: []*models.IngressVip{{IP: "10.35.20.10"}}, }, }) verifyApiErrorString(reply, http.StatusBadRequest, "User Managed Networking cannot be set with Ingress VIP") @@ -4586,8 +4086,8 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, }, }) verifyApiErrorString(reply, http.StatusBadRequest, @@ -4600,8 +4100,8 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, }, }) verifyApiErrorString(reply, http.StatusBadRequest, @@ -4613,8 +4113,8 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, }, }) verifyApiErrorString(reply, http.StatusBadRequest, fmt.Sprintf("The IP address \"%s\" appears both in apiVIPs and ingressVIPs", apiVip)) @@ -4625,7 +4125,7 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, }, }) verifyApiErrorString(reply, http.StatusBadRequest, fmt.Sprintf("Could not parse VIP ip %s", apiVip)) @@ -4636,7 +4136,7 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - IngressVip: swag.String(ingressVip), + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, }, }) verifyApiErrorString(reply, http.StatusBadRequest, fmt.Sprintf("Could not parse VIP ip %s", ingressVip)) @@ -4651,14 +4151,14 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, }, }) Expect(reply).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) actual := reply.(*installer.V2UpdateClusterCreated) - Expect(actual.Payload.APIVip).To(Equal(apiVip)) - Expect(actual.Payload.IngressVip).To(Equal(ingressVip)) + Expect(string(actual.Payload.APIVips[0].IP)).To(Equal(apiVip)) + Expect(string(actual.Payload.IngressVips[0].IP)).To(Equal(ingressVip)) validateNetworkConfiguration(actual.Payload, nil, nil, &[]*models.MachineNetwork{{Cidr: "10.11.0.0/16"}}) validateHostsRequestedHostname(actual.Payload) expectedNetworks := sortedNetworks([]*models.HostNetwork{ @@ -4699,8 +4199,8 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, MachineNetworks: []*models.MachineNetwork{{Cidr: "10.11.0.0/16"}}, }, }) @@ -4717,8 +4217,8 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, ClusterNetworks: []*models.ClusterNetwork{{Cidr: "10.128.0.0/14", HostPrefix: 23}, {Cidr: "fd01::/48", HostPrefix: 64}}, MachineNetworks: []*models.MachineNetwork{{Cidr: "10.11.0.0/16"}, {Cidr: "fd2e:6f44:5dd8:c956::/120"}}, }, @@ -4736,8 +4236,8 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, ClusterNetworks: []*models.ClusterNetwork{{Cidr: "10.128.0.0/14", HostPrefix: 23}, {Cidr: "fd01::/48", HostPrefix: 64}}, MachineNetworks: []*models.MachineNetwork{{Cidr: "10.11.0.0/16"}, {Cidr: "fd2e:6f44:5dd8:c956::/120"}}, }, @@ -4747,8 +4247,8 @@ var _ = Describe("cluster", func() { reply = bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, MachineNetworks: []*models.MachineNetwork{{Cidr: "fd2e:6f44:5dd8:c956::/120"}, {Cidr: "10.12.0.0/16"}}, }, }) @@ -4760,8 +4260,8 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, ClusterNetworks: []*models.ClusterNetwork{{Cidr: "10.128.0.0/14", HostPrefix: 23}, {Cidr: "fd01::/48", HostPrefix: 64}}, MachineNetworks: []*models.MachineNetwork{{Cidr: "10.12.0.0/16"}, {Cidr: "fd2e:6f44:5dd8:c956::/120"}}, }, @@ -4790,16 +4290,16 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, ClusterNetworks: clusterNetworks, ServiceNetworks: serviceNetworks, }, }) Expect(reply).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) actual := reply.(*installer.V2UpdateClusterCreated) - Expect(actual.Payload.APIVip).To(Equal(apiVip)) - Expect(actual.Payload.IngressVip).To(Equal(ingressVip)) + Expect(string(actual.Payload.APIVips[0].IP)).To(Equal(apiVip)) + Expect(string(actual.Payload.IngressVips[0].IP)).To(Equal(ingressVip)) validateNetworkConfiguration(actual.Payload, &clusterNetworks, &serviceNetworks, &[]*models.MachineNetwork{{Cidr: "10.11.0.0/16"}}) @@ -4877,8 +4377,8 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, ClusterNetworks: []*models.ClusterNetwork{{Cidr: "192.168.5.0/24", HostPrefix: 26}}, ServiceNetworks: []*models.ServiceNetwork{{Cidr: "193.168.4.0/23"}}, }, @@ -4890,8 +4390,8 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, ClusterNetworks: []*models.ClusterNetwork{{Cidr: "192.168.0.0/23", HostPrefix: 25}}, ServiceNetworks: []*models.ServiceNetwork{{Cidr: "193.168.4.0/27"}}, }, @@ -4903,8 +4403,8 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, ClusterNetworks: []*models.ClusterNetwork{{Cidr: "1.168.0.0/23", HostPrefix: 23}}, ServiceNetworks: []*models.ServiceNetwork{{Cidr: "193.168.4.0/1"}}, }, @@ -4916,8 +4416,8 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, ClusterNetworks: []*models.ClusterNetwork{{Cidr: "192.168.0.0/23", HostPrefix: 24}}, ServiceNetworks: []*models.ServiceNetwork{{Cidr: "193.168.4.0/25"}}, }, @@ -4945,13 +4445,13 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, VipDhcpAllocation: swag.Bool(true), MachineNetworks: []*models.MachineNetwork{{Cidr: primaryMachineCIDR}}, }, }) - verifyApiErrorString(reply, http.StatusBadRequest, "Setting API VIP is forbidden when cluster is in vip-dhcp-allocation mode") + verifyApiErrorString(reply, http.StatusBadRequest, "Setting API VIPs is forbidden when cluster is in vip-dhcp-allocation mode") }) It("Fail in DHCP", func() { @@ -4976,8 +4476,8 @@ var _ = Describe("cluster", func() { Expect(reply).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) verifyMachineCIDRTimestampUpdated(beforeTimestamp) actual := reply.(*installer.V2UpdateClusterCreated) - Expect(actual.Payload.APIVip).To(BeEmpty()) - Expect(actual.Payload.IngressVip).To(BeEmpty()) + Expect(len(actual.Payload.APIVips)).To(BeZero()) + Expect(len(actual.Payload.IngressVips)).To(BeZero()) validateNetworkConfiguration(actual.Payload, nil, nil, &machineNetworks) validateHostsRequestedHostname(actual.Payload) @@ -5018,16 +4518,16 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, VipDhcpAllocation: swag.Bool(false), }, }) Expect(reply).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) verifyMachineCIDRTimestampUpdated(beforeTimestamp) actual := reply.(*installer.V2UpdateClusterCreated) - Expect(actual.Payload.APIVip).To(Equal(apiVip)) - Expect(actual.Payload.IngressVip).To(Equal(ingressVip)) + Expect(string(actual.Payload.APIVips[0].IP)).To(Equal(apiVip)) + Expect(string(actual.Payload.IngressVips[0].IP)).To(Equal(ingressVip)) validateNetworkConfiguration(actual.Payload, nil, nil, &[]*models.MachineNetwork{{Cidr: primaryMachineCIDR}}) validateHostsRequestedHostname(actual.Payload) @@ -5517,9 +5017,7 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: &apiVip, APIVips: apiVips, - IngressVip: &ingressVip, IngressVips: ingressVips, }, }) @@ -5536,9 +5034,7 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: &apiVip, APIVips: apiVips, - IngressVip: &ingressVip, IngressVips: ingressVips, }, }) @@ -5555,9 +5051,7 @@ var _ = Describe("cluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: &apiVip, APIVips: apiVips, - IngressVip: &ingressVip, IngressVips: ingressVips, }, }) @@ -5658,16 +5152,16 @@ var _ = Describe("cluster", func() { defaultCluster := &common.Cluster{Cluster: models.Cluster{ ID: &clusterID, - APIVip: "10.11.12.13", - IngressVip: "10.11.20.50", + APIVips: []*models.APIVip{{IP: "10.11.12.13"}}, + IngressVips: []*models.IngressVip{{IP: "10.11.20.50"}}, OpenshiftVersion: common.TestDefaultConfig.OpenShiftVersion, Status: swag.String(models.ClusterStatusReady), }} clusterWithIgnoredValidations := &common.Cluster{Cluster: models.Cluster{ ID: &clusterID, - APIVip: "10.11.12.13", - IngressVip: "10.11.20.50", + APIVips: []*models.APIVip{{IP: "10.11.12.13"}}, + IngressVips: []*models.IngressVip{{IP: "10.11.20.50"}}, OpenshiftVersion: common.TestDefaultConfig.OpenShiftVersion, Status: swag.String(models.ClusterStatusInstalling), }, @@ -5815,8 +5309,8 @@ var _ = Describe("cluster", func() { clusterID = strfmt.UUID(uuid.New().String()) err := db.Create(&common.Cluster{Cluster: models.Cluster{ ID: &clusterID, - APIVip: "10.11.12.13", - IngressVip: "10.11.20.50", + APIVips: []*models.APIVip{{IP: "10.11.12.13"}}, + IngressVips: []*models.IngressVip{{IP: "10.11.20.50"}}, OpenshiftVersion: "4.11", Status: swag.String(models.ClusterStatusReady), CPUArchitecture: common.ARM64CPUArchitecture, @@ -5876,8 +5370,8 @@ var _ = Describe("cluster", func() { clusterID = strfmt.UUID(uuid.New().String()) err := db.Create(&common.Cluster{Cluster: models.Cluster{ ID: &clusterID, - APIVip: "10.11.12.13", - IngressVip: "10.11.20.50", + APIVips: []*models.APIVip{{IP: "10.11.12.13"}}, + IngressVips: []*models.IngressVip{{IP: "10.11.20.50"}}, OpenshiftVersion: "4.11", Status: swag.String(models.ClusterStatusReady), CPUArchitecture: common.ARM64CPUArchitecture, @@ -6349,10 +5843,16 @@ var _ = Describe("V2ClusterUpdate cluster", func() { }) It("Set Machine CIDR", func() { - Expect(db.Model(&common.Cluster{}).Where("id = ?", clusterID).Updates(map[string]interface{}{ - "api_vip": common.TestIPv4Networking.APIVip, - "ingress_vip": common.TestIPv4Networking.IngressVip, - }).Error).ShouldNot(HaveOccurred()) + err := network.UpdateVipsTables(db, + &common.Cluster{Cluster: models.Cluster{ + ID: &clusterID, + APIVips: common.TestIPv4Networking.APIVips, + IngressVips: common.TestIPv4Networking.IngressVips, + }}, + true, + true, + ) + Expect(err).ShouldNot(HaveOccurred()) mockSuccess(1) @@ -6366,8 +5866,8 @@ var _ = Describe("V2ClusterUpdate cluster", func() { Expect(reply).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) actual := reply.(*installer.V2UpdateClusterCreated) Expect(actual.Payload.VipDhcpAllocation).To(Equal(swag.Bool(false))) - Expect(actual.Payload.APIVip).To(Equal("")) - Expect(actual.Payload.IngressVip).To(Equal("")) + Expect(len(actual.Payload.APIVips)).To(BeZero()) + Expect(len(actual.Payload.IngressVips)).To(BeZero()) validateNetworkConfiguration(actual.Payload, nil, nil, &machineNetworks) }) @@ -6396,8 +5896,8 @@ var _ = Describe("V2ClusterUpdate cluster", func() { Expect(reply).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) actual := reply.(*installer.V2UpdateClusterCreated) Expect(actual.Payload.VipDhcpAllocation).To(Equal(swag.Bool(false))) - Expect(actual.Payload.APIVip).To(Equal("")) - Expect(actual.Payload.IngressVip).To(Equal("")) + Expect(len(actual.Payload.APIVips)).To(BeZero()) + Expect(len(actual.Payload.IngressVips)).To(BeZero()) validateNetworkConfiguration(actual.Payload, nil, nil, &wrongMachineCidrNetworks) }) }) @@ -10699,7 +10199,7 @@ var _ = Describe("KubeConfig download", func() { c = common.Cluster{Cluster: models.Cluster{ ID: &clusterID, OpenshiftVersion: common.TestDefaultConfig.OpenShiftVersion, - APIVip: "10.11.12.13", + APIVips: []*models.APIVip{{IP: "10.11.12.13"}}, }} err := db.Create(&c).Error Expect(err).ShouldNot(HaveOccurred()) @@ -10892,7 +10392,7 @@ var _ = Describe("V2UploadClusterIngressCert test", func() { c = common.Cluster{Cluster: models.Cluster{ ID: &clusterID, OpenshiftVersion: common.TestDefaultConfig.OpenShiftVersion, - APIVip: "10.11.12.13", + APIVips: []*models.APIVip{{IP: "10.11.12.13"}}, }} kubeconfigNoingress = fmt.Sprintf("%s/%s", clusterID, "kubeconfig-noingress") kubeconfigObject = fmt.Sprintf("%s/%s", clusterID, constants.Kubeconfig) @@ -11075,7 +10575,7 @@ var _ = Describe("List clusters", func() { ID: &clusterID, OpenshiftVersion: common.TestDefaultConfig.OpenShiftVersion, Name: "mycluster", - APIVip: "10.11.12.13", + APIVips: []*models.APIVip{{IP: "10.11.12.13"}}, OpenshiftClusterID: *openshiftClusterID, AmsSubscriptionID: *amsSubscriptionID, }} @@ -11372,7 +10872,7 @@ var _ = Describe("Upload and Download logs test", func() { ID: &clusterID, OpenshiftVersion: common.TestDefaultConfig.OpenShiftVersion, Name: "mycluster", - APIVip: "10.11.12.13", + APIVips: []*models.APIVip{{IP: "10.11.12.13"}}, }} err := db.Create(&c).Error Expect(err).ShouldNot(HaveOccurred()) @@ -13739,8 +13239,8 @@ var _ = Describe("TestRegisterCluster", func() { apiVip := "1.2.3.5" ingressVip := "1.2.3.6" - params.APIVip = apiVip - params.IngressVip = ingressVip + params.APIVips = []*models.APIVip{{IP: models.IP(apiVip)}} + params.IngressVips = []*models.IngressVip{{IP: models.IP(ingressVip)}} params.Platform = &models.Platform{Type: common.PlatformTypePtr(models.PlatformTypeVsphere)} params.UserManagedNetworking = swag.Bool(false) reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ @@ -14341,8 +13841,8 @@ var _ = Describe("TestRegisterCluster", func() { It("Fail multi-node UserManagedNetworking with API Vip and Ingress Vip", func() { clusterParams := getDefaultClusterCreateParams() clusterParams.UserManagedNetworking = swag.Bool(true) - clusterParams.APIVip = "10.35.10.11" - clusterParams.IngressVip = "10.35.10.10" + clusterParams.APIVips = []*models.APIVip{{IP: "10.35.10.11"}} + clusterParams.IngressVips = []*models.IngressVip{{IP: "10.35.10.10"}} reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ NewClusterParams: clusterParams, }) @@ -14352,8 +13852,8 @@ var _ = Describe("TestRegisterCluster", func() { It("Fail SNO (UserManagedNetworking) with API Vip and Ingress Vip", func() { clusterParams := getDefaultClusterCreateParams() clusterParams.UserManagedNetworking = swag.Bool(true) - clusterParams.APIVip = "10.35.10.11" - clusterParams.IngressVip = "10.35.10.10" + clusterParams.APIVips = []*models.APIVip{{IP: "10.35.10.11"}} + clusterParams.IngressVips = []*models.IngressVip{{IP: "10.35.10.10"}} clusterParams.HighAvailabilityMode = swag.String(models.ClusterHighAvailabilityModeNone) clusterParams.OpenshiftVersion = swag.String("4.12") clusterParams.Platform = &models.Platform{ @@ -14638,8 +14138,8 @@ var _ = Describe("TestRegisterCluster", func() { ingressVip := "1.2.3.6" clusterCreateParams := getDefaultClusterCreateParams() - clusterCreateParams.APIVip = apiVip - clusterCreateParams.IngressVip = ingressVip + clusterCreateParams.APIVips = []*models.APIVip{{IP: models.IP(apiVip)}} + clusterCreateParams.IngressVips = []*models.IngressVip{{IP: models.IP(ingressVip)}} clusterCreateParams.ClusterNetworks = common.TestDualStackNetworking.ClusterNetworks clusterCreateParams.MachineNetworks = common.TestDualStackNetworking.MachineNetworks clusterCreateParams.ServiceNetworks = common.TestDualStackNetworking.ServiceNetworks @@ -14650,8 +14150,8 @@ var _ = Describe("TestRegisterCluster", func() { }) Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2RegisterClusterCreated())) actual := reply.(*installer.V2RegisterClusterCreated).Payload - Expect(actual.APIVip).To(Equal(apiVip)) - Expect(actual.IngressVip).To(Equal(ingressVip)) + Expect(string(actual.APIVips[0].IP)).To(Equal(apiVip)) + Expect(string(actual.IngressVips[0].IP)).To(Equal(ingressVip)) Expect(actual.VipDhcpAllocation).To(Equal(swag.Bool(false))) Expect(actual.ClusterNetworks).To(Equal(common.TestDualStackNetworking.ClusterNetworks)) Expect(actual.MachineNetworks).To(Equal(common.TestDualStackNetworking.MachineNetworks)) @@ -14665,8 +14165,8 @@ var _ = Describe("TestRegisterCluster", func() { ingressVip := "1.2.3.6" clusterCreateParams := getDefaultClusterCreateParams() - clusterCreateParams.APIVip = apiVip - clusterCreateParams.IngressVip = ingressVip + clusterCreateParams.APIVips = []*models.APIVip{{IP: models.IP(apiVip)}} + clusterCreateParams.IngressVips = []*models.IngressVip{{IP: models.IP(ingressVip)}} clusterCreateParams.ClusterNetworks = common.TestIPv4Networking.ClusterNetworks clusterCreateParams.MachineNetworks = common.TestIPv4Networking.MachineNetworks clusterCreateParams.ServiceNetworks = common.TestIPv4Networking.ServiceNetworks @@ -14677,8 +14177,8 @@ var _ = Describe("TestRegisterCluster", func() { }) Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2RegisterClusterCreated())) actual := reply.(*installer.V2RegisterClusterCreated).Payload - Expect(actual.APIVip).To(Equal(apiVip)) - Expect(actual.IngressVip).To(Equal(ingressVip)) + Expect(string(actual.APIVips[0].IP)).To(Equal(apiVip)) + Expect(string(actual.IngressVips[0].IP)).To(Equal(ingressVip)) Expect(actual.VipDhcpAllocation).To(Equal(swag.Bool(false))) Expect(actual.ClusterNetworks).To(Equal(common.TestIPv4Networking.ClusterNetworks)) Expect(actual.MachineNetworks).To(Equal(common.TestIPv4Networking.MachineNetworks)) @@ -14690,8 +14190,8 @@ var _ = Describe("TestRegisterCluster", func() { reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ NewClusterParams: &models.ClusterCreateParams{ - APIVip: apiVip, - IngressVip: ingressVip, + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, ClusterNetworks: common.TestDualStackNetworking.ClusterNetworks, MachineNetworks: common.TestDualStackNetworking.MachineNetworks, ServiceNetworks: common.TestDualStackNetworking.ServiceNetworks, @@ -14706,8 +14206,8 @@ var _ = Describe("TestRegisterCluster", func() { reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ NewClusterParams: &models.ClusterCreateParams{ - APIVip: apiVip, - IngressVip: ingressVip, + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, ClusterNetworks: common.TestDualStackNetworking.ClusterNetworks, MachineNetworks: common.TestDualStackNetworking.MachineNetworks, ServiceNetworks: common.TestDualStackNetworking.ServiceNetworks, @@ -14722,8 +14222,8 @@ var _ = Describe("TestRegisterCluster", func() { reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ NewClusterParams: &models.ClusterCreateParams{ - APIVip: apiVip, - IngressVip: ingressVip, + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, ClusterNetworks: common.TestDualStackNetworking.ClusterNetworks, MachineNetworks: common.TestDualStackNetworking.MachineNetworks, ServiceNetworks: common.TestDualStackNetworking.ServiceNetworks, @@ -14738,8 +14238,8 @@ var _ = Describe("TestRegisterCluster", func() { reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ NewClusterParams: &models.ClusterCreateParams{ - APIVip: apiVip, - IngressVip: ingressVip, + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, ClusterNetworks: common.TestDualStackNetworking.ClusterNetworks, ServiceNetworks: common.TestDualStackNetworking.ServiceNetworks, VipDhcpAllocation: swag.Bool(false), @@ -14754,8 +14254,8 @@ var _ = Describe("TestRegisterCluster", func() { reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ NewClusterParams: &models.ClusterCreateParams{ - APIVip: apiVip, - IngressVip: ingressVip, + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, ClusterNetworks: common.TestDualStackNetworking.ClusterNetworks, MachineNetworks: common.TestDualStackNetworking.MachineNetworks, ServiceNetworks: common.TestDualStackNetworking.ServiceNetworks, @@ -14771,8 +14271,8 @@ var _ = Describe("TestRegisterCluster", func() { reply := bm.V2RegisterCluster(ctx, installer.V2RegisterClusterParams{ NewClusterParams: &models.ClusterCreateParams{ - APIVip: apiVip, - IngressVip: ingressVip, + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, ClusterNetworks: common.TestDualStackNetworking.ClusterNetworks, MachineNetworks: common.TestDualStackNetworking.MachineNetworks, ServiceNetworks: common.TestDualStackNetworking.ServiceNetworks, @@ -14813,18 +14313,18 @@ var _ = Describe("TestRegisterCluster", func() { reply := bm.V2UpdateCluster(ctx, installer.V2UpdateClusterParams{ ClusterID: clusterID, ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, ClusterNetworks: common.TestDualStackNetworking.ClusterNetworks, MachineNetworks: common.TestDualStackNetworking.MachineNetworks, ServiceNetworks: common.TestDualStackNetworking.ServiceNetworks, }, }) Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) - cluster := &common.Cluster{Cluster: *reply.(*installer.V2UpdateClusterCreated).Payload} - Expect(cluster.APIVip).To(Equal(apiVip)) + cluster = &common.Cluster{Cluster: *reply.(*installer.V2UpdateClusterCreated).Payload} + Expect(string(cluster.APIVips[0].IP)).To(Equal(apiVip)) Expect(network.GetApiVipById(cluster, 0)).To(Equal(apiVip)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) + Expect(string(cluster.IngressVips[0].IP)).To(Equal(ingressVip)) Expect(network.GetIngressVipById(cluster, 0)).To(Equal(ingressVip)) Expect(cluster.ClusterNetworks).To(Equal(common.TestDualStackNetworking.ClusterNetworks)) Expect(cluster.MachineNetworks).To(Equal(common.TestDualStackNetworking.MachineNetworks)) @@ -17368,8 +16868,8 @@ var _ = Describe("IPv6 support disabled", func() { }) It("IPv6 ingress VIP rejected", func() { - params.NewClusterParams.APIVip = "2001:db8::2" - params.NewClusterParams.IngressVip = "2001:db8::1" + params.NewClusterParams.APIVips = []*models.APIVip{{IP: "2001:db8::2"}} + params.NewClusterParams.IngressVips = []*models.IngressVip{{IP: "2001:db8::1"}} reply := bm.V2RegisterCluster(ctx, params) verifyApiErrorString(reply, http.StatusBadRequest, errorMsg) }) @@ -17431,16 +16931,16 @@ var _ = Describe("IPv6 support disabled", func() { }) It("IPv6 API VIP rejected", func() { - params.ClusterUpdateParams.APIVip = swag.String("2003:db8::a") - params.ClusterUpdateParams.IngressVip = swag.String("2003:db8::b") + params.ClusterUpdateParams.APIVips = []*models.APIVip{{IP: "2003:db8::a"}} + params.ClusterUpdateParams.IngressVips = []*models.IngressVip{{IP: "2003:db8::b"}} reply := bm.V2UpdateCluster(ctx, params) verifyApiErrorString(reply, http.StatusBadRequest, errorMsg) }) It("IPv6 ingress VIP rejected", func() { - params.ClusterUpdateParams.IngressVip = swag.String("2002:db8::1") - params.ClusterUpdateParams.APIVip = swag.String("2002:db8::2") + params.ClusterUpdateParams.APIVips = []*models.APIVip{{IP: "2002:db8::1"}} + params.ClusterUpdateParams.IngressVips = []*models.IngressVip{{IP: "2002:db8::2"}} reply := bm.V2UpdateCluster(ctx, params) verifyApiErrorString(reply, http.StatusBadRequest, errorMsg) @@ -17460,8 +16960,8 @@ var _ = Describe("Dual-stack cluster", func() { ClusterNetworks: append(common.TestIPv4Networking.ClusterNetworks, common.TestIPv6Networking.ClusterNetworks...), ServiceNetworks: append(common.TestIPv4Networking.ServiceNetworks, common.TestIPv6Networking.ServiceNetworks...), MachineNetworks: append(common.TestIPv4Networking.MachineNetworks, common.TestIPv6Networking.MachineNetworks...), - APIVip: common.TestIPv4Networking.APIVip, - IngressVip: common.TestIPv4Networking.IngressVip, + APIVips: common.TestIPv4Networking.APIVips, + IngressVips: common.TestIPv4Networking.IngressVips, } ) @@ -18331,7 +17831,7 @@ var _ = Describe("Download presigned cluster credentials", func() { c = common.Cluster{Cluster: models.Cluster{ ID: &clusterID, OpenshiftVersion: common.TestDefaultConfig.OpenShiftVersion, - APIVip: "10.11.12.13", + APIVips: []*models.APIVip{{IP: "10.11.12.13"}}, }} err := db.Create(&c).Error Expect(err).ShouldNot(HaveOccurred()) diff --git a/internal/cluster/cluster.go b/internal/cluster/cluster.go index 7ff88ce64b..de01e6de54 100644 --- a/internal/cluster/cluster.go +++ b/internal/cluster/cluster.go @@ -1017,8 +1017,8 @@ func (m *Manager) HandlePreInstallSuccess(ctx context.Context, c *common.Cluster } func vipMismatchError(apiVip, ingressVip string, cluster *common.Cluster) error { - return errors.Errorf("Got VIPs different than those that are stored in the DB for cluster %s. APIVip = %s @db = %s, IngressVIP = %s @db = %s", - cluster.ID.String(), apiVip, cluster.APIVip, ingressVip, cluster.IngressVip) + return errors.Errorf("Got VIPs different than those that are stored in the DB for cluster %s. first APIVip = '%s' @db = '%s', first IngressVIP = '%s' @db = '%s'", + cluster.ID.String(), apiVip, network.GetApiVipById(cluster, 0), ingressVip, network.GetIngressVipById(cluster, 0)) } func (m *Manager) SetVipsData(ctx context.Context, c *common.Cluster, apiVip, ingressVip, apiVipLease, ingressVipLease string, db *gorm.DB) error { @@ -1029,8 +1029,11 @@ func (m *Manager) SetVipsData(ctx context.Context, c *common.Cluster, apiVip, in log := logutil.FromContext(ctx, m.log) formattedApiLease := network.FormatLease(apiVipLease) formattedIngressVip := network.FormatLease(ingressVipLease) - if apiVip == c.APIVip && apiVip == network.GetApiVipById(c, 0) && - ingressVip == c.IngressVip && ingressVip == network.GetIngressVipById(c, 0) && + clusterIngressVip := network.GetIngressVipById(c, 0) + clusterApiVip := network.GetApiVipById(c, 0) + + if apiVip == clusterApiVip && + ingressVip == clusterIngressVip && formattedApiLease == c.ApiVipLease && formattedIngressVip == c.IngressVipLease { return nil @@ -1044,23 +1047,22 @@ func (m *Manager) SetVipsData(ctx context.Context, c *common.Cluster, apiVip, in } if err = db.Model(&common.Cluster{}).Where("id = ?", c.ID.String()). Updates(map[string]interface{}{ - "api_vip": apiVip, - "ingress_vip": ingressVip, "api_vip_lease": formattedApiLease, "ingress_vip_lease": formattedIngressVip, }).Error; err != nil { log.WithError(err).Warnf("Update vips of cluster %s", c.ID.String()) return err } - if apiVip != c.APIVip || c.IngressVip != ingressVip { - if c.APIVip != "" || c.IngressVip != "" { + + if apiVip != clusterApiVip || clusterIngressVip != ingressVip { + if clusterApiVip != "" || clusterIngressVip != "" { log.WithError(vipMismatchError(apiVip, ingressVip, c)).Warn("VIPs changed") } eventgen.SendApiIngressVipUpdatedEvent(ctx, m.eventsHandler, *c.ID, apiVip, ingressVip) } case models.ClusterStatusInstalling, models.ClusterStatusPreparingForInstallation, models.ClusterStatusFinalizing: - if c.APIVip != apiVip || c.IngressVip != ingressVip { + if clusterApiVip != apiVip || clusterIngressVip != ingressVip { err = vipMismatchError(apiVip, ingressVip, c) log.WithError(err).Error("VIPs changed during installation") diff --git a/internal/cluster/cluster_test.go b/internal/cluster/cluster_test.go index ed52452195..71a3140d35 100644 --- a/internal/cluster/cluster_test.go +++ b/internal/cluster/cluster_test.go @@ -446,9 +446,7 @@ var _ = Describe("TestClusterMonitoring", func() { ClusterNetworks: common.TestIPv4Networking.ClusterNetworks, ServiceNetworks: common.TestIPv4Networking.ServiceNetworks, MachineNetworks: common.TestIPv4Networking.MachineNetworks, - APIVip: common.TestIPv4Networking.APIVip, APIVips: common.TestIPv4Networking.APIVips, - IngressVip: common.TestIPv4Networking.IngressVip, IngressVips: common.TestIPv4Networking.IngressVips, BaseDNSDomain: "test.com", PullSecretSet: true, @@ -486,7 +484,17 @@ var _ = Describe("TestClusterMonitoring", func() { shouldHaveUpdated = true expectedState = "ready" - Expect(db.Model(&c).Updates(map[string]interface{}{"api_vip": "1.2.3.5", "ingress_vip": "1.2.3.6"}).Error).To(Not(HaveOccurred())) + + err = network.UpdateVipsTables(db, + &common.Cluster{Cluster: models.Cluster{ + ID: c.ID, + APIVips: []*models.APIVip{{IP: "1.2.3.5", ClusterID: *c.ID}}, + IngressVips: []*models.IngressVip{{IP: "1.2.3.6", ClusterID: *c.ID}}, + }}, + true, + true, + ) + Expect(err).ShouldNot(HaveOccurred()) }) It("insufficient -> insufficient including hosts in discovering", func() { createHost(id, "known", db) @@ -526,9 +534,7 @@ var _ = Describe("TestClusterMonitoring", func() { ClusterNetworks: common.TestIPv4Networking.ClusterNetworks, ServiceNetworks: common.TestIPv4Networking.ServiceNetworks, MachineNetworks: common.TestIPv4Networking.MachineNetworks, - APIVip: common.TestIPv4Networking.APIVip, APIVips: common.TestIPv4Networking.APIVips, - IngressVip: common.TestIPv4Networking.IngressVip, IngressVips: common.TestIPv4Networking.IngressVips, BaseDNSDomain: "test.com", PullSecretSet: true, @@ -635,9 +641,7 @@ var _ = Describe("TestClusterMonitoring", func() { ClusterNetworks: common.TestIPv4Networking.ClusterNetworks, ServiceNetworks: common.TestIPv4Networking.ServiceNetworks, MachineNetworks: common.TestIPv4Networking.MachineNetworks, - APIVip: common.TestIPv4Networking.APIVip, APIVips: common.TestIPv4Networking.APIVips, - IngressVip: common.TestIPv4Networking.IngressVip, IngressVips: common.TestIPv4Networking.IngressVips, BaseDNSDomain: "test.com", PullSecretSet: true, @@ -804,8 +808,6 @@ var _ = Describe("lease timeout event", func() { c = common.Cluster{Cluster: models.Cluster{ ID: &id, Status: swag.String(t.srcState), - APIVip: t.apiVip, - IngressVip: t.ingressVip, ClusterNetworks: common.TestIPv4Networking.ClusterNetworks, ServiceNetworks: common.TestIPv4Networking.ServiceNetworks, MachineNetworks: common.TestIPv4Networking.MachineNetworks, @@ -1342,7 +1344,6 @@ var _ = Describe("Auto assign machine CIDR", func() { Status: swag.String(t.srcState), BaseDNSDomain: "test.com", PullSecretSet: true, - APIVip: t.apiVip, APIVips: t.apiVips, ClusterNetworks: common.TestIPv4Networking.ClusterNetworks, ServiceNetworks: common.TestIPv4Networking.ServiceNetworks, @@ -1680,6 +1681,13 @@ func createHost(clusterId strfmt.UUID, state string, db *gorm.DB) { Role: models.HostRoleMaster, Status: swag.String(state), Inventory: common.GenerateTestDefaultInventory(), + FreeAddresses: makeFreeNetworksAddressesStr( + makeFreeAddresses( + string(common.TestIPv4Networking.MachineNetworks[0].Cidr), + strfmt.IPv4(common.TestIPv4Networking.IngressVips[0].IP), + strfmt.IPv4(common.TestIPv4Networking.APIVips[0].IP), + ), + ), } Expect(db.Create(&host).Error).ShouldNot(HaveOccurred()) } @@ -2162,9 +2170,7 @@ var _ = Describe("SetVipsData", func() { Cluster: models.Cluster{ ID: &clusterId, Status: swag.String(t.srcState), - APIVip: t.clusterApiVip, APIVips: []*models.APIVip{{IP: models.IP(t.clusterApiVip), ClusterID: clusterId}}, - IngressVip: t.clusterIngressVip, IngressVips: []*models.IngressVip{{IP: models.IP(t.clusterIngressVip), ClusterID: clusterId}}, }, } @@ -2177,10 +2183,8 @@ var _ = Describe("SetVipsData", func() { err := capi.SetVipsData(ctx, &cluster, t.apiVip, t.ingressVip, t.clusterApiLease, t.clusterIngressLease, db) Expect(err != nil).To(Equal(t.errorExpected)) c := getClusterFromDB(clusterId, db) - Expect(c.APIVip).To(Equal(t.expectedApiVip)) Expect(network.GetApiVipById(&c, 0)).To(Equal(t.expectedApiVip)) Expect(len(c.APIVips)).To(Equal(1)) - Expect(c.IngressVip).To(Equal(t.expectedIngressVip)) Expect(len(c.IngressVips)).To(Equal(1)) Expect(network.GetIngressVipById(&c, 0)).To(Equal(t.expectedIngressVip)) Expect(c.ApiVipLease).To(Equal(t.expectedApiLease)) @@ -2226,8 +2230,6 @@ var _ = Describe("Majority groups", func() { ClusterNetworks: common.TestIPv4Networking.ClusterNetworks, ServiceNetworks: common.TestIPv4Networking.ServiceNetworks, MachineNetworks: common.TestIPv4Networking.MachineNetworks, - APIVip: apiVip, - IngressVip: ingressVip, APIVips: []*models.APIVip{{IP: models.IP(apiVip), ClusterID: id, Verification: &verificationSuccess}}, IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip), ClusterID: id, Verification: &verificationSuccess}}, BaseDNSDomain: "test.com", @@ -2540,8 +2542,6 @@ var _ = Describe("ready_state", func() { ClusterNetworks: common.TestIPv4Networking.ClusterNetworks, ServiceNetworks: common.TestIPv4Networking.ServiceNetworks, MachineNetworks: common.TestIPv4Networking.MachineNetworks, - APIVip: apiVip, - IngressVip: ingressVip, APIVips: []*models.APIVip{{IP: models.IP(apiVip), ClusterID: id, Verification: common.VipVerificationPtr(models.VipVerificationSucceeded)}}, IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip), ClusterID: id, Verification: common.VipVerificationPtr(models.VipVerificationSucceeded)}}, BaseDNSDomain: "test.com", @@ -2645,9 +2645,7 @@ var _ = Describe("insufficient_state", func() { ID: &id, Status: swag.String(currentState), MachineNetworks: common.TestIPv4Networking.MachineNetworks, - APIVip: common.TestIPv4Networking.APIVip, APIVips: common.TestIPv4Networking.APIVips, - IngressVip: common.TestIPv4Networking.IngressVip, IngressVips: common.TestIPv4Networking.IngressVips, BaseDNSDomain: "test.com", PullSecretSet: true, @@ -3325,7 +3323,6 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { clusterKind string errorExpected bool userManagedNetwork bool - apiVip string apiVips []*models.APIVip }{ { @@ -3334,7 +3331,6 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { clusterKind: models.ClusterKindCluster, errorExpected: false, userManagedNetwork: true, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, }, { @@ -3343,7 +3339,6 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { clusterKind: models.ClusterKindCluster, errorExpected: false, userManagedNetwork: false, - apiVip: "", apiVips: nil, }, { @@ -3352,7 +3347,6 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { clusterKind: models.ClusterKindCluster, errorExpected: false, userManagedNetwork: false, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, }, { @@ -3361,7 +3355,6 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { clusterKind: models.ClusterKindAddHostsCluster, errorExpected: true, userManagedNetwork: false, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, }, { @@ -3370,7 +3363,6 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { clusterKind: models.ClusterKindCluster, errorExpected: true, userManagedNetwork: false, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, }, { @@ -3379,7 +3371,6 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { clusterKind: models.ClusterKindCluster, errorExpected: true, userManagedNetwork: false, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, }, { @@ -3388,7 +3379,6 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { clusterKind: models.ClusterKindCluster, errorExpected: true, userManagedNetwork: false, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, }, { @@ -3397,7 +3387,6 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { clusterKind: models.ClusterKindCluster, errorExpected: true, userManagedNetwork: false, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, }, { @@ -3406,7 +3395,6 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { clusterKind: models.ClusterKindCluster, errorExpected: true, userManagedNetwork: false, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, }, { @@ -3415,7 +3403,6 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { clusterKind: models.ClusterKindCluster, errorExpected: true, userManagedNetwork: false, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, }, { @@ -3424,7 +3411,6 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { clusterKind: models.ClusterKindCluster, errorExpected: true, userManagedNetwork: false, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, }, { @@ -3433,7 +3419,6 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { clusterKind: models.ClusterKindAddHostsCluster, errorExpected: true, userManagedNetwork: false, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, }, { @@ -3442,7 +3427,6 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { clusterKind: models.ClusterKindCluster, errorExpected: true, userManagedNetwork: false, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, }, { @@ -3451,7 +3435,6 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { clusterKind: models.ClusterKindCluster, errorExpected: true, userManagedNetwork: false, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, }, } @@ -3466,9 +3449,7 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { OpenshiftVersion: common.TestDefaultConfig.OpenShiftVersion, Status: swag.String(t.clusterStatus), MachineNetworks: common.TestIPv4Networking.MachineNetworks, - APIVip: t.apiVip, APIVips: t.apiVips, - IngressVip: common.TestIPv4Networking.IngressVip, IngressVips: common.TestIPv4Networking.IngressVips, BaseDNSDomain: "test.com", PullSecretSet: true, @@ -3482,11 +3463,10 @@ var _ = Describe("Transform day1 cluster to a day2 cluster", func() { Expect(db.Take(&c, "id = ?", cluster.ID.String()).Error).ToNot(HaveOccurred()) Expect(c.Kind).To(Equal(swag.String(models.ClusterKindAddHostsCluster))) Expect(c.Status).To(Equal(swag.String(models.ClusterStatusAddingHosts))) - if t.apiVip == "" || t.userManagedNetwork { + if t.apiVips == nil || t.userManagedNetwork { apiVipDnsname := fmt.Sprintf("api.%s.%s", c.Name, c.BaseDNSDomain) Expect(c.APIVipDNSName).To(Equal(swag.String(apiVipDnsname))) } else { - Expect(c.APIVipDNSName).To(Equal(swag.String(cluster.APIVip))) Expect(c.APIVipDNSName).To(Equal(swag.String(network.GetApiVipById(cluster, 0)))) } diff --git a/internal/cluster/common.go b/internal/cluster/common.go index 5260b9b857..2e70a34211 100644 --- a/internal/cluster/common.go +++ b/internal/cluster/common.go @@ -7,7 +7,6 @@ import ( "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" - "github.com/openshift/assisted-service/internal/cluster/validations" "github.com/openshift/assisted-service/internal/common" eventgen "github.com/openshift/assisted-service/internal/common/events" eventsapi "github.com/openshift/assisted-service/internal/events/api" @@ -125,15 +124,11 @@ func clusterExistsInDB(db *gorm.DB, clusterId strfmt.UUID, where map[string]inte func UpdateCluster(ctx context.Context, log logrus.FieldLogger, db *gorm.DB, notificationStream stream.Notifier, clusterId strfmt.UUID, srcStatus string, extra ...interface{}) (*common.Cluster, error) { updates := make(map[string]interface{}) - updateChangesVips := false if len(extra)%2 != 0 { return nil, errors.Errorf("invalid update extra parameters %+v", extra) } for i := 0; i < len(extra); i += 2 { - if extra[i].(string) == "api_vip" || extra[i].(string) == "ingress_vip" { - updateChangesVips = true - } updates[extra[i].(string)] = extra[i+1] } @@ -149,46 +144,6 @@ func UpdateCluster(ctx context.Context, log logrus.FieldLogger, db *gorm.DB, not return nil, errors.Errorf("failed to update cluster %s. nothing has changed", clusterId) } - // (MGMT-9915) - // The block below is responsible for updating plural VIP structure in any scenario when an - // update of singular VIP has been requested via the `updates[]` mechanism. This is - // a workaround for e.g. a scenario when SNO updates its VIP from the Host inventory and not - // using the regular get&set for the Cluster.*Vip field. - // - // This part covers specifically the scenario as follows - // * updates[api_vip] or updates[ingress_vip] contains a value - // * Cluster.ApiVips and Cluster.IngressVips are not updated - // - // Without this block below, such a scenario would lead to unsynchronized state of the DB. - if updateChangesVips { - updatedCluster, err := common.GetClusterFromDB(db, clusterId, common.UseEagerLoading) - if err != nil { - return nil, err - } - apiVips, err := validations.HandleApiVipBackwardsCompatibility(*updatedCluster.ID, updatedCluster.APIVip, nil) - if err != nil { - return nil, err - } - ingressVips, err := validations.HandleIngressVipBackwardsCompatibility(*updatedCluster.ID, updatedCluster.IngressVip, nil) - if err != nil { - return nil, err - } - - if err = network.UpdateVipsTables(db, - &common.Cluster{Cluster: models.Cluster{ - ID: updatedCluster.ID, - APIVip: updatedCluster.APIVip, - APIVips: apiVips, - IngressVip: updatedCluster.IngressVip, - IngressVips: ingressVips, - }}, - true, - true, - ); err != nil { - return nil, err - } - } - cluster, err := common.GetClusterFromDB(db, clusterId, common.UseEagerLoading) if err == nil { notifiableCluster := stream.GetNotifiableCluster(cluster) diff --git a/internal/cluster/progress_test.go b/internal/cluster/progress_test.go index bdea7031d5..39bf73d2c7 100644 --- a/internal/cluster/progress_test.go +++ b/internal/cluster/progress_test.go @@ -408,8 +408,8 @@ var _ = Describe("Progress bar test", func() { Kind: swag.String(models.ClusterKindCluster), HighAvailabilityMode: &none, MachineNetworks: []*models.MachineNetwork{{Cidr: "1.2.3.0/24"}}, - APIVip: "1.2.3.5", - IngressVip: "1.2.3.6", + APIVips: []*models.APIVip{{IP: "1.2.3.5"}}, + IngressVips: []*models.IngressVip{{IP: "1.2.3.6"}}, Status: swag.String(t.clusterStatus), StatusUpdatedAt: strfmt.DateTime(time.Now()), InstallStartedAt: t.installStartTime, diff --git a/internal/cluster/transition.go b/internal/cluster/transition.go index fc08f58130..3a434e3060 100644 --- a/internal/cluster/transition.go +++ b/internal/cluster/transition.go @@ -116,7 +116,17 @@ func (th *transitionHandler) PostResetCluster(sw stateswitch.StateSwitch, args s extra := resetFields[:] // reset api_vip and ingress_vip in case of resetting the SNO cluster if common.IsSingleNodeCluster(sCluster.cluster) { - extra = append(extra, "api_vip", "", "ingress_vip", "") + if err := network.UpdateVipsTables(params.db, + &common.Cluster{Cluster: models.Cluster{ + ID: sCluster.cluster.ID, + APIVips: []*models.APIVip{}, + IngressVips: []*models.IngressVip{}, + }}, + true, + true, + ); err != nil { + return err + } } return th.updateTransitionCluster(params.ctx, logutil.FromContext(params.ctx, th.log), params.db, sCluster, params.reason, extra...) @@ -576,7 +586,13 @@ func (th *transitionHandler) PostRefreshCluster(reason string) stateswitch.PostT if sCluster.srcState != swag.StringValue(sCluster.cluster.Status) || reason != swag.StringValue(sCluster.cluster.StatusInfo) { var extra []interface{} var log = logutil.FromContext(params.ctx, th.log) - extra, err = addExtraParams(log, sCluster.cluster, sCluster.srcState) + + if common.IsSingleNodeCluster(sCluster.cluster) { + if err = updateSNOClusterVips(log, params.db, sCluster.cluster, sCluster.srcState); err != nil { + return err + } + } + extra, err = addExtraParams(sCluster.cluster, sCluster.srcState) if err != nil { return err } @@ -730,19 +746,33 @@ func initProgressParamsInstallingStage() []interface{} { "progress_total_percentage", totalPercentage} } -func addExtraParams(log logrus.FieldLogger, cluster *common.Cluster, srcState string) ([]interface{}, error) { +func updateSNOClusterVips(log logrus.FieldLogger, db *gorm.DB, cluster *common.Cluster, srcState string) error { + if swag.StringValue(cluster.Status) == models.ClusterStatusInstalling { + // In case of SNO cluster, set api_vip and ingress_vip with host ip + hostIP, err := network.GetIpForSingleNodeInstallation(cluster, log) + if err != nil { + log.WithError(err).Errorf("Failed to find host ip for single node installation") + return err + } + if err = network.UpdateVipsTables(db, + &common.Cluster{Cluster: models.Cluster{ + ID: cluster.ID, + APIVips: []*models.APIVip{{IP: models.IP(hostIP), ClusterID: *cluster.ID}}, + IngressVips: []*models.IngressVip{{IP: models.IP(hostIP), ClusterID: *cluster.ID}}, + }}, + true, + true, + ); err != nil { + return err + } + } + return nil +} + +func addExtraParams(cluster *common.Cluster, srcState string) ([]interface{}, error) { extra := []interface{}{} switch swag.StringValue(cluster.Status) { case models.ClusterStatusInstalling: - // In case of SNO cluster, set api_vip and ingress_vip with host ip - if common.IsSingleNodeCluster(cluster) { - hostIP, err := network.GetIpForSingleNodeInstallation(cluster, log) - if err != nil { - log.WithError(err).Errorf("Failed to find host ip for single node installation") - return nil, err - } - extra = append(make([]interface{}, 0), "api_vip", hostIP, "ingress_vip", hostIP) - } if srcState == models.ClusterStatusPreparingForInstallation { extra = append(extra, initProgressParamsInstallingStage()...) } diff --git a/internal/cluster/transition_test.go b/internal/cluster/transition_test.go index db56871f27..499eb07119 100644 --- a/internal/cluster/transition_test.go +++ b/internal/cluster/transition_test.go @@ -541,9 +541,7 @@ var _ = Describe("Reset cluster", func() { ID: &clusterId, Status: swag.String(t.state), HighAvailabilityMode: &haMode, - APIVip: hostIP, APIVips: []*models.APIVip{{IP: models.IP(hostIP)}}, - IngressVip: hostIP, IngressVips: []*models.IngressVip{{IP: models.IP(hostIP)}}, }, } @@ -553,15 +551,11 @@ var _ = Describe("Reset cluster", func() { cluster = getClusterFromDB(clusterId, db) if t.success { Expect(err).ShouldNot(HaveOccurred()) - Expect(cluster.Cluster.APIVip).Should(Equal("")) - Expect(cluster.Cluster.IngressVip).Should(Equal("")) Expect(len(cluster.Cluster.APIVips)).Should(Equal(0)) Expect(len(cluster.Cluster.IngressVips)).Should(Equal(0)) } else { Expect(err).Should(HaveOccurred()) Expect(err.StatusCode()).Should(Equal(t.statusCode)) - Expect(cluster.Cluster.APIVip).ShouldNot(Equal("")) - Expect(cluster.Cluster.IngressVip).ShouldNot(Equal("")) Expect(len(cluster.Cluster.APIVips)).ShouldNot(Equal(0)) Expect(len(cluster.Cluster.IngressVips)).ShouldNot(Equal(0)) } @@ -682,9 +676,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcState string srcStatusInfo string machineNetworks []*models.MachineNetwork - apiVip string apiVips []*models.APIVip - ingressVip string ingressVips []*models.IngressVip dnsDomain string pullSecretSet bool @@ -699,9 +691,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { name: "pending-for-input to pending-for-input", srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusPendingForInput, - apiVip: "", apiVips: nil, - ingressVip: "", ingressVips: nil, dnsDomain: "test.com", pullSecretSet: true, @@ -733,9 +723,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { name: "pending-for-input to pending-for-input api-vip-defined", srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusPendingForInput, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: "", ingressVips: nil, dnsDomain: "test.com", pullSecretSet: true, @@ -768,9 +756,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusPendingForInput, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: "", apiVips: nil, - ingressVip: "", ingressVips: nil, dnsDomain: "test.com", pullSecretSet: true, @@ -803,9 +789,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusPendingForInput, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: "", ingressVips: nil, dnsDomain: "test.com", pullSecretSet: true, @@ -837,9 +821,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { name: "pending-for-input to pending-for-input with single inventory", srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusPendingForInput, - apiVip: "", apiVips: nil, - ingressVip: "", ingressVips: nil, dnsDomain: "test.com", pullSecretSet: true, @@ -871,9 +853,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { name: "pending-for-input to pending-for-input with 2 workers", srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusPendingForInput, - apiVip: "", apiVips: nil, - ingressVip: "", ingressVips: nil, dnsDomain: "test.com", pullSecretSet: true, @@ -905,9 +885,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { name: "pending-for-input to pending-for-input with 3 master 2 workers candidates in auto-assign mode", srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusPendingForInput, - apiVip: "", apiVips: nil, - ingressVip: "", ingressVips: nil, dnsDomain: "test.com", pullSecretSet: true, @@ -941,9 +919,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusInsufficient, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -976,9 +952,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusReady, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1010,9 +984,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusReady, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1043,9 +1015,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusInsufficient, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1077,9 +1047,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcState: models.ClusterStatusReady, dstState: models.ClusterStatusPendingForInput, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: "", apiVips: nil, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1111,9 +1079,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcState: models.ClusterStatusReady, dstState: models.ClusterStatusPendingForInput, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "", pullSecretSet: true, @@ -1145,9 +1111,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcState: models.ClusterStatusReady, dstState: models.ClusterStatusPendingForInput, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: false, @@ -1178,9 +1142,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusReady, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1212,9 +1174,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcState: models.ClusterStatusInsufficient, dstState: models.ClusterStatusReady, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1246,9 +1206,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcState: models.ClusterStatusReady, dstState: models.ClusterStatusReady, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1279,9 +1237,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcStatusInfo: statusInfoFinalizing, dstState: models.ClusterStatusFinalizing, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1301,9 +1257,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcState: models.ClusterStatusError, dstState: models.ClusterStatusError, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1324,9 +1278,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcStatusInfo: statusInfoInstalled, dstState: models.ClusterStatusInstalled, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1347,9 +1299,7 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { srcStatusInfo: statusInfoInstalling, dstState: models.ClusterStatusInstalling, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1371,10 +1321,8 @@ var _ = Describe("Refresh Cluster - No DHCP", func() { It(t.name, func() { cluster = common.Cluster{ Cluster: models.Cluster{ - APIVip: t.apiVip, APIVips: t.apiVips, ID: &clusterId, - IngressVip: t.ingressVip, IngressVips: t.ingressVips, MachineNetworks: t.machineNetworks, Status: &t.srcState, @@ -1499,9 +1447,7 @@ var _ = Describe("Refresh Cluster - Same networks", func() { srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusPendingForInput, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1525,9 +1471,7 @@ var _ = Describe("Refresh Cluster - Same networks", func() { machineNetworks: common.TestIPv4Networking.MachineNetworks, serviceNetworks: common.TestIPv6Networking.ServiceNetworks, clusterNetworks: common.TestIPv4Networking.ClusterNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1551,9 +1495,7 @@ var _ = Describe("Refresh Cluster - Same networks", func() { machineNetworks: common.TestDualStackNetworking.MachineNetworks, serviceNetworks: common.TestIPv4Networking.ServiceNetworks, clusterNetworks: common.TestIPv4Networking.ClusterNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1577,9 +1519,7 @@ var _ = Describe("Refresh Cluster - Same networks", func() { machineNetworks: common.TestIPv4Networking.MachineNetworks, serviceNetworks: common.TestIPv4Networking.ServiceNetworks, clusterNetworks: common.TestIPv4Networking.ClusterNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1603,9 +1543,7 @@ var _ = Describe("Refresh Cluster - Same networks", func() { machineNetworks: common.TestIPv6Networking.MachineNetworks, serviceNetworks: common.TestIPv6Networking.ServiceNetworks, clusterNetworks: common.TestIPv6Networking.ClusterNetworks, - apiVip: common.TestIPv6Networking.APIVip, apiVips: common.TestIPv6Networking.APIVips, - ingressVip: common.TestIPv6Networking.IngressVip, ingressVips: common.TestIPv6Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1629,9 +1567,7 @@ var _ = Describe("Refresh Cluster - Same networks", func() { machineNetworks: common.TestDualStackNetworking.MachineNetworks, serviceNetworks: common.TestDualStackNetworking.ServiceNetworks, clusterNetworks: common.TestDualStackNetworking.ClusterNetworks, - apiVip: common.TestDualStackNetworking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -1655,10 +1591,8 @@ var _ = Describe("Refresh Cluster - Same networks", func() { It(t.name, func() { cluster = common.Cluster{ Cluster: models.Cluster{ - APIVip: t.apiVip, APIVips: t.apiVips, ID: &clusterId, - IngressVip: t.ingressVip, IngressVips: t.ingressVips, MachineNetworks: t.machineNetworks, Status: &t.srcState, @@ -1764,9 +1698,7 @@ var _ = Describe("RefreshCluster - preparing for install", func() { }{ { name: "no change", - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dstState: models.ClusterStatusPreparingForInstallation, installationStatus: models.LastInstallationPreparationStatusPreparationNeverPerformed, @@ -1788,9 +1720,7 @@ var _ = Describe("RefreshCluster - preparing for install", func() { }, { name: "one insufficient host", - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dstState: models.ClusterStatusInsufficient, installationStatus: models.LastInstallationPreparationStatusPreparationNeverPerformed, @@ -1812,9 +1742,7 @@ var _ = Describe("RefreshCluster - preparing for install", func() { }, { name: "one insufficient host + preparation failed", - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dstState: models.ClusterStatusInsufficient, hosts: []models.Host{ @@ -1836,9 +1764,7 @@ var _ = Describe("RefreshCluster - preparing for install", func() { }, { name: "one insufficient host + preparation succeeded", - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dstState: models.ClusterStatusInsufficient, hosts: []models.Host{ @@ -1860,9 +1786,7 @@ var _ = Describe("RefreshCluster - preparing for install", func() { }, { name: "preparation failed", - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dstState: models.ClusterStatusReady, hosts: []models.Host{ @@ -1884,9 +1808,7 @@ var _ = Describe("RefreshCluster - preparing for install", func() { }, { name: "all hosts prepared + preparation succeeded", - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dstState: models.ClusterStatusInstalling, hosts: []models.Host{ @@ -1912,10 +1834,8 @@ var _ = Describe("RefreshCluster - preparing for install", func() { It(t.name, func() { cluster = common.Cluster{ Cluster: models.Cluster{ - APIVip: t.apiVip, APIVips: t.apiVips, ID: &clusterId, - IngressVip: t.ingressVip, IngressVips: t.ingressVips, PullSecretSet: true, BaseDNSDomain: "test.com", @@ -2027,9 +1947,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusPendingForInput, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, hosts: []models.Host{ {ID: &hid1, Status: swag.String(models.HostStatusKnown), Inventory: common.GenerateTestDefaultInventory(), Role: models.HostRoleMaster}, @@ -2097,9 +2015,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { clusterNetworks: common.TestIPv4Networking.ClusterNetworks, serviceNetworks: common.TestIPv4Networking.ServiceNetworks, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, networkType: models.ClusterNetworkTypeOVNKubernetes, hosts: []models.Host{ @@ -2180,9 +2096,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { {Cidr: models.Subnet(common.IncrementCidrMask(string(common.TestIPv4Networking.MachineNetworks[0].Cidr)))}, }, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, networkType: models.ClusterNetworkTypeOpenShiftSDN, hosts: []models.Host{ @@ -2219,9 +2133,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { }, serviceNetworks: common.TestIPv4Networking.ServiceNetworks, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, networkType: models.ClusterNetworkTypeOVNKubernetes, hosts: []models.Host{ @@ -2258,9 +2170,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { }, serviceNetworks: common.TestIPv4Networking.ServiceNetworks, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, networkType: models.ClusterNetworkTypeOVNKubernetes, hosts: []models.Host{ @@ -2295,9 +2205,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { clusterNetworks: common.TestIPv4Networking.ClusterNetworks, serviceNetworks: common.TestIPv4Networking.ServiceNetworks, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, networkType: models.ClusterNetworkTypeOVNKubernetes, hosts: []models.Host{ @@ -2332,9 +2240,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { }, serviceNetworks: common.TestIPv4Networking.ServiceNetworks, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, networkType: models.ClusterNetworkTypeOVNKubernetes, hosts: []models.Host{ @@ -2369,9 +2275,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { clusterNetworks: common.TestIPv4Networking.ClusterNetworks, serviceNetworks: common.TestIPv4Networking.ServiceNetworks, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, networkType: models.ClusterNetworkTypeOVNKubernetes, hosts: []models.Host{ @@ -2406,9 +2310,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { clusterNetworks: common.TestIPv4Networking.ClusterNetworks, serviceNetworks: common.TestIPv4Networking.ServiceNetworks, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, networkType: models.ClusterNetworkTypeOVNKubernetes, vipDhcpAllocation: true, @@ -2442,9 +2344,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { clusterNetworks: common.TestIPv4Networking.ClusterNetworks, serviceNetworks: common.TestIPv4Networking.ServiceNetworks, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, networkType: models.ClusterNetworkTypeOpenShiftSDN, sno: true, @@ -2477,10 +2377,8 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { It(t.name, func() { cluster = common.Cluster{ Cluster: models.Cluster{ - APIVip: t.apiVip, APIVips: t.apiVips, ID: &clusterId, - IngressVip: t.ingressVip, IngressVips: t.ingressVips, ClusterNetworks: t.clusterNetworks, ServiceNetworks: t.serviceNetworks, @@ -2558,9 +2456,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusPendingForInput, machineNetworks: common.TestIPv6Networking.MachineNetworks, - apiVip: common.TestIPv6Networking.APIVip, apiVips: common.TestIPv6Networking.APIVips, - ingressVip: common.TestIPv6Networking.IngressVip, ingressVips: common.TestIPv6Networking.IngressVips, networkType: models.ClusterNetworkTypeOVNKubernetes, hosts: []models.Host{ @@ -2663,9 +2559,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { clusterNetworks: common.TestIPv6Networking.ClusterNetworks, serviceNetworks: common.TestIPv6Networking.ServiceNetworks, machineNetworks: common.TestIPv6Networking.MachineNetworks, - apiVip: common.TestIPv6Networking.APIVip, apiVips: common.TestIPv6Networking.APIVips, - ingressVip: common.TestIPv6Networking.IngressVip, ingressVips: common.TestIPv6Networking.IngressVips, networkType: models.ClusterNetworkTypeOVNKubernetes, hosts: []models.Host{ @@ -2703,9 +2597,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { {Cidr: models.Subnet(common.IncrementCidrMask(string(common.TestIPv6Networking.MachineNetworks[0].Cidr)))}, }, machineNetworks: common.TestIPv6Networking.MachineNetworks, - apiVip: common.TestIPv6Networking.APIVip, apiVips: common.TestIPv6Networking.APIVips, - ingressVip: common.TestIPv6Networking.IngressVip, ingressVips: common.TestIPv6Networking.IngressVips, networkType: models.ClusterNetworkTypeOVNKubernetes, hosts: []models.Host{ @@ -2742,9 +2634,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { }, serviceNetworks: common.TestIPv6Networking.ServiceNetworks, machineNetworks: common.TestIPv6Networking.MachineNetworks, - apiVip: common.TestIPv6Networking.APIVip, apiVips: common.TestIPv6Networking.APIVips, - ingressVip: common.TestIPv6Networking.IngressVip, ingressVips: common.TestIPv6Networking.IngressVips, networkType: models.ClusterNetworkTypeOVNKubernetes, hosts: []models.Host{ @@ -2779,9 +2669,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { clusterNetworks: common.TestIPv6Networking.ClusterNetworks, serviceNetworks: common.TestIPv6Networking.ServiceNetworks, machineNetworks: common.TestIPv6Networking.MachineNetworks, - apiVip: common.TestIPv6Networking.APIVip, apiVips: common.TestIPv6Networking.APIVips, - ingressVip: common.TestIPv6Networking.IngressVip, ingressVips: common.TestIPv6Networking.IngressVips, networkType: models.ClusterNetworkTypeOpenShiftSDN, hosts: []models.Host{ @@ -2817,9 +2705,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { }, serviceNetworks: common.TestIPv6Networking.ServiceNetworks, machineNetworks: common.TestIPv6Networking.MachineNetworks, - apiVip: common.TestIPv6Networking.APIVip, apiVips: common.TestIPv6Networking.APIVips, - ingressVip: common.TestIPv6Networking.IngressVip, ingressVips: common.TestIPv6Networking.IngressVips, networkType: models.ClusterNetworkTypeOVNKubernetes, hosts: []models.Host{ @@ -2854,9 +2740,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { clusterNetworks: common.TestIPv6Networking.ClusterNetworks, serviceNetworks: common.TestIPv6Networking.ServiceNetworks, machineNetworks: common.TestIPv6Networking.MachineNetworks, - apiVip: common.TestIPv6Networking.APIVip, apiVips: common.TestIPv6Networking.APIVips, - ingressVip: common.TestIPv6Networking.IngressVip, ingressVips: common.TestIPv6Networking.IngressVips, networkType: models.ClusterNetworkTypeOVNKubernetes, hosts: []models.Host{ @@ -2891,9 +2775,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { }, serviceNetworks: common.TestIPv6Networking.ServiceNetworks, machineNetworks: common.TestIPv6Networking.MachineNetworks, - apiVip: common.TestIPv6Networking.APIVip, apiVips: common.TestIPv6Networking.APIVips, - ingressVip: common.TestIPv6Networking.IngressVip, ingressVips: common.TestIPv6Networking.IngressVips, networkType: models.ClusterNetworkTypeOVNKubernetes, hosts: []models.Host{ @@ -2928,9 +2810,7 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { clusterNetworks: common.TestIPv6Networking.ClusterNetworks, serviceNetworks: common.TestIPv6Networking.ServiceNetworks, machineNetworks: common.TestIPv6Networking.MachineNetworks, - apiVip: common.TestIPv6Networking.APIVip, apiVips: common.TestIPv6Networking.APIVips, - ingressVip: common.TestIPv6Networking.IngressVip, ingressVips: common.TestIPv6Networking.IngressVips, networkType: models.ClusterNetworkTypeOVNKubernetes, hosts: []models.Host{ @@ -2965,10 +2845,8 @@ var _ = Describe("Refresh Cluster - Advanced networking validations", func() { It(t.name, func() { cluster = common.Cluster{ Cluster: models.Cluster{ - APIVip: t.apiVip, APIVips: t.apiVips, ID: &clusterId, - IngressVip: t.ingressVip, IngressVips: t.ingressVips, ClusterNetworks: t.clusterNetworks, ServiceNetworks: t.serviceNetworks, @@ -3139,9 +3017,7 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusInsufficient, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -3173,9 +3049,7 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusInsufficient, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -3205,9 +3079,7 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusInsufficient, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -3270,9 +3142,7 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { srcState: models.ClusterStatusReady, dstState: models.ClusterStatusInsufficient, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: clearApiVipsVerfication(common.TestIPv4Networking.APIVips), - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: clearIngressVIpsVerification(common.TestIPv4Networking.IngressVips), dnsDomain: "test.com", pullSecretSet: true, @@ -3288,9 +3158,9 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { IsMachineCidrDefined: {status: ValidationSuccess, messagePattern: "Machine Network CIDR is defined"}, IsMachineCidrEqualsToCalculatedCidr: {status: ValidationSuccess, messagePattern: "Cluster Machine CIDR is equivalent to the calculated CIDR"}, AreApiVipsDefined: {status: ValidationSuccess, messagePattern: "API virtual IPs are defined"}, - AreApiVipsValid: {status: ValidationFailure, messagePattern: fmt.Sprintf("api vips <%s> is already in use in cidr %s", common.TestIPv4Networking.APIVip, string(common.TestIPv4Networking.MachineNetworks[0].Cidr))}, + AreApiVipsValid: {status: ValidationFailure, messagePattern: fmt.Sprintf("api vips <%s> is already in use in cidr %s", common.TestIPv4Networking.APIVips[0].IP, string(common.TestIPv4Networking.MachineNetworks[0].Cidr))}, AreIngressVipsDefined: {status: ValidationSuccess, messagePattern: "Ingress virtual IPs are defined"}, - AreIngressVipsValid: {status: ValidationFailure, messagePattern: fmt.Sprintf("ingress vips <%s> is already in use in cidr %s", common.TestIPv4Networking.IngressVip, string(common.TestIPv4Networking.MachineNetworks[0].Cidr))}, + AreIngressVipsValid: {status: ValidationFailure, messagePattern: fmt.Sprintf("ingress vips <%s> is already in use in cidr %s", common.TestIPv4Networking.IngressVips[0].IP, string(common.TestIPv4Networking.MachineNetworks[0].Cidr))}, AllHostsAreReadyToInstall: {status: ValidationSuccess, messagePattern: "All hosts in the cluster are ready to install."}, IsDNSDomainDefined: {status: ValidationSuccess, messagePattern: "The base domain is defined"}, IsPullSecretSet: {status: ValidationSuccess, messagePattern: "The pull secret is set."}, @@ -3306,7 +3176,6 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { machineNetworks: common.TestIPv4Networking.MachineNetworks, apiVip: "", apiVips: nil, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -3340,7 +3209,6 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { machineNetworks: common.TestIPv4Networking.MachineNetworks, apiVip: "", apiVips: nil, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -3373,9 +3241,7 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { srcState: models.ClusterStatusInsufficient, dstState: models.ClusterStatusReady, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -3406,9 +3272,7 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { srcState: models.ClusterStatusPendingForInput, dstState: models.ClusterStatusReady, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -3439,9 +3303,7 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { srcState: models.ClusterStatusInsufficient, dstState: models.ClusterStatusReady, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -3472,9 +3334,7 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { srcState: models.ClusterStatusReady, dstState: models.ClusterStatusReady, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -3506,9 +3366,7 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { srcStatusInfo: statusInfoFinalizing, dstState: models.ClusterStatusFinalizing, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -3528,9 +3386,7 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { srcState: models.ClusterStatusError, dstState: models.ClusterStatusError, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -3551,9 +3407,7 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { srcStatusInfo: statusInfoInstalled, dstState: models.ClusterStatusInstalled, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, hosts: []models.Host{ {ID: &hid1, Status: swag.String(models.HostStatusKnown), Inventory: common.GenerateTestDefaultInventory(), Role: models.HostRoleMaster}, @@ -3572,9 +3426,7 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { srcStatusInfo: statusInfoInstalling, dstState: models.ClusterStatusInstalling, machineNetworks: common.TestIPv4Networking.MachineNetworks, - apiVip: common.TestIPv4Networking.APIVip, apiVips: common.TestIPv4Networking.APIVips, - ingressVip: common.TestIPv4Networking.IngressVip, ingressVips: common.TestIPv4Networking.IngressVips, dnsDomain: "test.com", pullSecretSet: true, @@ -3596,10 +3448,8 @@ var _ = Describe("Refresh Cluster - With DHCP", func() { It(t.name, func() { cluster = common.Cluster{ Cluster: models.Cluster{ - APIVip: t.apiVip, APIVips: t.apiVips, ID: &clusterId, - IngressVip: t.ingressVip, IngressVips: t.ingressVips, MachineNetworks: t.machineNetworks, Status: &t.srcState, @@ -4005,9 +3855,7 @@ var _ = Describe("Refresh Cluster - Installing Cases", func() { ClusterNetworks: common.TestIPv4Networking.ClusterNetworks, ServiceNetworks: common.TestIPv4Networking.ServiceNetworks, MachineNetworks: common.TestIPv4Networking.MachineNetworks, - APIVip: common.TestIPv4Networking.APIVip, APIVips: common.TestIPv4Networking.APIVips, - IngressVip: common.TestIPv4Networking.IngressVip, IngressVips: common.TestIPv4Networking.IngressVips, ID: &clusterId, Status: &t.srcState, @@ -4490,9 +4338,7 @@ var _ = Describe("NTP refresh cluster", func() { ClusterNetworks: common.TestIPv4Networking.ClusterNetworks, ServiceNetworks: common.TestIPv4Networking.ServiceNetworks, MachineNetworks: common.TestIPv4Networking.MachineNetworks, - APIVip: common.TestIPv4Networking.APIVip, APIVips: common.TestIPv4Networking.APIVips, - IngressVip: common.TestIPv4Networking.IngressVip, IngressVips: common.TestIPv4Networking.IngressVips, ID: &clusterId, Status: &t.srcState, @@ -4775,9 +4621,7 @@ var _ = Describe("Single node", func() { ClusterNetworks: common.TestIPv4Networking.ClusterNetworks, ServiceNetworks: common.TestIPv4Networking.ServiceNetworks, MachineNetworks: common.TestIPv4Networking.MachineNetworks, - APIVip: common.TestIPv4Networking.APIVip, APIVips: common.TestIPv4Networking.APIVips, - IngressVip: common.TestIPv4Networking.IngressVip, IngressVips: common.TestIPv4Networking.IngressVips, ID: &clusterId, Status: &t.srcState, diff --git a/internal/cluster/validations/validations.go b/internal/cluster/validations/validations.go index 53d891d85c..93e3570a05 100644 --- a/internal/cluster/validations/validations.go +++ b/internal/cluster/validations/validations.go @@ -382,40 +382,6 @@ func HandleApiVipBackwardsCompatibility(clusterId strfmt.UUID, apiVip string, ap return apiVips, nil } -func handleIngressVipUpdateBackwardsCompatibility(cluster *common.Cluster, params *models.V2ClusterUpdateParams) error { - if cluster.IngressVip != "" { - // IngressVip was cleared and IngressVips were not provided, clear both fields. - if params.IngressVip != nil && swag.StringValue(params.IngressVip) == "" && params.IngressVips == nil { - params.IngressVips = []*models.IngressVip{} - } - // IngressVip was changed (but not cleared), IngressVips will be forcefully set to the value of IngressVips as a one-element list. - if params.IngressVip != nil && swag.StringValue(params.IngressVip) != "" && swag.StringValue(params.IngressVip) != cluster.IngressVip { - if err := validateIngressVipAddressesInput(params.IngressVips); err != nil { - return err - } - params.IngressVips = []*models.IngressVip{{IP: models.IP(swag.StringValue(params.IngressVip)), ClusterID: *cluster.ID}} - } - } - return nil -} - -func handleApiVipUpdateBackwardsCompatibility(cluster *common.Cluster, params *models.V2ClusterUpdateParams) error { - if cluster.APIVip != "" { - // APIVip was cleared and APIVips were not provided, clear both fields. - if params.APIVip != nil && swag.StringValue(params.APIVip) == "" && params.APIVips == nil { - params.APIVips = []*models.APIVip{} - } - // APIVip was changed (but not cleared), APIVips will be forcefully set to the value of APIVip as a one-element list. - if params.APIVip != nil && swag.StringValue(params.APIVip) != "" && swag.StringValue(params.APIVip) != cluster.APIVip { - if err := validateApiVipAddressesInput(params.APIVips); err != nil { - return err - } - params.APIVips = []*models.APIVip{{IP: models.IP(swag.StringValue(params.APIVip)), ClusterID: *cluster.ID}} - } - } - return nil -} - func HandleIngressVipBackwardsCompatibility(clusterId strfmt.UUID, ingressVip string, ingressVips []*models.IngressVip) ([]*models.IngressVip, error) { // IngressVip provided, but IngressVips were not. if ingressVip != "" && len(ingressVips) == 0 { @@ -433,20 +399,8 @@ func HandleIngressVipBackwardsCompatibility(clusterId strfmt.UUID, ingressVip st } func ValidateClusterCreateIPAddresses(ipV6Supported bool, clusterId strfmt.UUID, params *models.ClusterCreateParams) error { - var err error targetConfiguration := common.Cluster{} - // Backwards compatibility: An old client is used and it can't send fields it doesn't know about. - params.APIVips, err = HandleApiVipBackwardsCompatibility(clusterId, params.APIVip, params.APIVips) - if err != nil { - return common.NewApiError(http.StatusBadRequest, err) - } - - params.IngressVips, err = HandleIngressVipBackwardsCompatibility(clusterId, params.IngressVip, params.IngressVips) - if err != nil { - return common.NewApiError(http.StatusBadRequest, err) - } - if (len(params.APIVips) > 1 || len(params.IngressVips) > 1) && !featuresupport.IsFeatureAvailable(models.FeatureSupportLevelIDDUALSTACKVIPS, swag.StringValue(params.OpenshiftVersion), swag.String(params.CPUArchitecture)) { @@ -462,8 +416,6 @@ func ValidateClusterCreateIPAddresses(ipV6Supported bool, clusterId strfmt.UUID, targetConfiguration.VipDhcpAllocation = params.VipDhcpAllocation } targetConfiguration.ID = &clusterId - targetConfiguration.APIVip = params.APIVip - targetConfiguration.IngressVip = params.IngressVip targetConfiguration.APIVips = params.APIVips targetConfiguration.IngressVips = params.IngressVips targetConfiguration.UserManagedNetworking = params.UserManagedNetworking @@ -478,29 +430,19 @@ func ValidateClusterCreateIPAddresses(ipV6Supported bool, clusterId strfmt.UUID, func validateVIPsWithUMA(cluster *common.Cluster, params *models.V2ClusterUpdateParams, vipDhcpAllocation bool) error { var ( - apiVip string - ingressVip string apiVips []*models.APIVip ingressVips []*models.IngressVip ) if swag.BoolValue(cluster.VipDhcpAllocation) { return ValidateVIPsWereNotSetUserManagedNetworking( - apiVip, ingressVip, apiVips, ingressVips, vipDhcpAllocation, + apiVips, ingressVips, vipDhcpAllocation, ) } - apiVip = cluster.APIVip - ingressVip = cluster.IngressVip apiVips = cluster.APIVips ingressVips = cluster.IngressVips - if params.APIVip != nil { - apiVip = swag.StringValue(params.APIVip) - } - if params.IngressVip != nil { - ingressVip = swag.StringValue(params.IngressVip) - } if params.APIVips != nil { apiVips = params.APIVips } @@ -509,37 +451,19 @@ func validateVIPsWithUMA(cluster *common.Cluster, params *models.V2ClusterUpdate } return ValidateVIPsWereNotSetUserManagedNetworking( - apiVip, ingressVip, apiVips, ingressVips, vipDhcpAllocation, + apiVips, ingressVips, vipDhcpAllocation, ) } func ValidateClusterUpdateVIPAddresses(ipV6Supported bool, cluster *common.Cluster, params *models.V2ClusterUpdateParams) error { var err error targetConfiguration := common.Cluster{} - - // Backwards compatibility: An old client is used and it can't send fields it doesn't know about. - params.APIVips, err = HandleApiVipBackwardsCompatibility(*cluster.ID, swag.StringValue(params.APIVip), params.APIVips) - if err != nil { - return common.NewApiError(http.StatusBadRequest, err) - } - params.IngressVips, err = HandleIngressVipBackwardsCompatibility(*cluster.ID, swag.StringValue(params.IngressVip), params.IngressVips) - if err != nil { - return common.NewApiError(http.StatusBadRequest, err) - } - if (len(params.APIVips) > 1 || len(params.IngressVips) > 1) && !featuresupport.IsFeatureAvailable(models.FeatureSupportLevelIDDUALSTACKVIPS, cluster.OpenshiftVersion, swag.String(cluster.CPUArchitecture)) { return common.NewApiError(http.StatusBadRequest, errors.Errorf("%s %s", "dual-stack VIPs are not supported in OpenShift", cluster.OpenshiftVersion)) } - // Update-flow backwards compatibility: An old client is used and it can't send fields it doesn't know about. - if err1 := handleApiVipUpdateBackwardsCompatibility(cluster, params); err1 != nil { - err = multierror.Append(err, err1) - } - if err2 := handleIngressVipUpdateBackwardsCompatibility(cluster, params); err2 != nil { - err = multierror.Append(err, err2) - } if err != nil && !strings.Contains(err.Error(), "0 errors occurred") { return common.NewApiError(http.StatusBadRequest, err) } @@ -558,8 +482,6 @@ func ValidateClusterUpdateVIPAddresses(ipV6Supported bool, cluster *common.Clust } if cluster.VipDhcpAllocation != nil && swag.BoolValue(cluster.VipDhcpAllocation) { // override VIPs that were allocated via DHCP - params.APIVip = swag.String("") - params.IngressVip = swag.String("") params.APIVips = []*models.APIVip{} params.IngressVips = []*models.IngressVip{} } @@ -567,9 +489,7 @@ func ValidateClusterUpdateVIPAddresses(ipV6Supported bool, cluster *common.Clust targetConfiguration.ID = cluster.ID targetConfiguration.VipDhcpAllocation = params.VipDhcpAllocation - targetConfiguration.APIVip = swag.StringValue(params.APIVip) targetConfiguration.APIVips = params.APIVips - targetConfiguration.IngressVip = swag.StringValue(params.IngressVip) targetConfiguration.IngressVips = params.IngressVips targetConfiguration.UserManagedNetworking = params.UserManagedNetworking targetConfiguration.HighAvailabilityMode = cluster.HighAvailabilityMode @@ -762,7 +682,7 @@ func validateVIPAddresses(ipV6Supported bool, targetConfiguration common.Cluster // When running with User Managed Networking we do not allow setting any advanced network // parameters via the Cluster configuration if swag.BoolValue(targetConfiguration.UserManagedNetworking) { - if err = ValidateVIPsWereNotSetUserManagedNetworking(targetConfiguration.APIVip, targetConfiguration.IngressVip, + if err = ValidateVIPsWereNotSetUserManagedNetworking( targetConfiguration.APIVips, targetConfiguration.IngressVips, swag.BoolValue(targetConfiguration.VipDhcpAllocation)); err != nil { return common.NewApiError(http.StatusBadRequest, err) } @@ -773,7 +693,7 @@ func validateVIPAddresses(ipV6Supported bool, targetConfiguration common.Cluster // In any case, if VIPs are provided, they must pass the validation for being part of the // primary Machine Network and for non-overlapping addresses if swag.BoolValue(targetConfiguration.VipDhcpAllocation) { - if err = ValidateVIPsWereNotSetDhcpMode(targetConfiguration.APIVip, targetConfiguration.IngressVip, + if err = ValidateVIPsWereNotSetDhcpMode( targetConfiguration.APIVips, targetConfiguration.IngressVips); err != nil { return common.NewApiError(http.StatusBadRequest, err) } @@ -797,23 +717,15 @@ func validateVIPAddresses(ipV6Supported bool, targetConfiguration common.Cluster return nil } -func ValidateVIPsWereNotSetUserManagedNetworking(apiVip string, ingressVip string, apiVips []*models.APIVip, ingressVips []*models.IngressVip, vipDhcpAllocation bool) error { +func ValidateVIPsWereNotSetUserManagedNetworking(apiVips []*models.APIVip, ingressVips []*models.IngressVip, vipDhcpAllocation bool) error { if vipDhcpAllocation { err := errors.Errorf("VIP DHCP Allocation cannot be set with User Managed Networking") return err } - if apiVip != "" { - err := errors.New("API VIP cannot be set with User Managed Networking") - return err - } if len(apiVips) > 0 { err := errors.New("API VIPs cannot be set with User Managed Networking") return err } - if ingressVip != "" { - err := errors.New("Ingress VIP cannot be set with User Managed Networking") - return err - } if len(ingressVips) > 0 { err := errors.New("Ingress VIPs cannot be set with User Managed Networking") return err @@ -821,19 +733,11 @@ func ValidateVIPsWereNotSetUserManagedNetworking(apiVip string, ingressVip strin return nil } -func ValidateVIPsWereNotSetDhcpMode(apiVip string, ingressVip string, apiVips []*models.APIVip, ingressVips []*models.IngressVip) error { - if apiVip != "" { - err := errors.New("Setting API VIP is forbidden when cluster is in vip-dhcp-allocation mode") - return err - } +func ValidateVIPsWereNotSetDhcpMode(apiVips []*models.APIVip, ingressVips []*models.IngressVip) error { if len(apiVips) > 0 { err := errors.New("Setting API VIPs is forbidden when cluster is in vip-dhcp-allocation mode") return err } - if ingressVip != "" { - err := errors.New("Setting Ingress VIP is forbidden when cluster is in vip-dhcp-allocation mode") - return err - } if len(ingressVips) > 0 { err := errors.New("Setting Ingress VIPs is forbidden when cluster is in vip-dhcp-allocation mode") return err diff --git a/internal/common/common.go b/internal/common/common.go index 0eba37442f..0456cdbe10 100644 --- a/internal/common/common.go +++ b/internal/common/common.go @@ -451,8 +451,14 @@ func GetTagFromImageRef(ref string) string { func GetConvertedClusterAPIVipDNSName(c *Cluster) string { // In case cluster that isn't configured with user-managed-networking // and api vip is set we should set api vip as APIVipDNSName - if !swag.BoolValue(c.Cluster.UserManagedNetworking) && c.Cluster.APIVip != "" { - return c.Cluster.APIVip + + apiVip := "" + if len(c.APIVips) > 0 { + apiVip = string(c.APIVips[0].IP) + } + + if !swag.BoolValue(c.Cluster.UserManagedNetworking) && apiVip != "" { + return apiVip } return fmt.Sprintf("api.%s.%s", c.Cluster.Name, c.Cluster.BaseDNSDomain) } diff --git a/internal/common/common_test.go b/internal/common/common_test.go index 50ddefbf64..ece095cb1b 100644 --- a/internal/common/common_test.go +++ b/internal/common/common_test.go @@ -453,9 +453,9 @@ func createHost(hostRole models.HostRole, state string) *models.Host { func createClusterFromHosts(hosts []*models.Host) Cluster { return Cluster{ Cluster: models.Cluster{ - APIVip: "192.168.10.10", Hosts: hosts, - IngressVip: "192.168.10.11", + APIVips: []*models.APIVip{{IP: "192.168.10.10"}}, + IngressVips: []*models.IngressVip{{IP: "192.168.10.11"}}, OpenshiftVersion: "4.9", }, } diff --git a/internal/common/test_configuration.go b/internal/common/test_configuration.go index 0644dcbccc..39e632ef4a 100644 --- a/internal/common/test_configuration.go +++ b/internal/common/test_configuration.go @@ -19,9 +19,7 @@ type TestNetworking struct { ClusterNetworks []*models.ClusterNetwork ServiceNetworks []*models.ServiceNetwork MachineNetworks []*models.MachineNetwork - APIVip string APIVips []*models.APIVip - IngressVip string IngressVips []*models.IngressVip } @@ -250,9 +248,7 @@ var TestIPv4Networking = TestNetworking{ ClusterNetworks: []*models.ClusterNetwork{{Cidr: "1.3.0.0/16", HostPrefix: 24}}, ServiceNetworks: []*models.ServiceNetwork{{Cidr: "1.2.5.0/24"}}, MachineNetworks: []*models.MachineNetwork{{Cidr: "1.2.3.0/24"}}, - APIVip: "1.2.3.5", APIVips: []*models.APIVip{{IP: "1.2.3.5", Verification: VipVerificationPtr(models.VipVerificationSucceeded)}}, - IngressVip: "1.2.3.6", IngressVips: []*models.IngressVip{{IP: "1.2.3.6", Verification: VipVerificationPtr(models.VipVerificationSucceeded)}}, } @@ -263,9 +259,7 @@ var TestIPv6Networking = TestNetworking{ ClusterNetworks: []*models.ClusterNetwork{{Cidr: "1003:db8::/53", HostPrefix: 64}}, ServiceNetworks: []*models.ServiceNetwork{{Cidr: "1002:db8::/119"}}, MachineNetworks: []*models.MachineNetwork{{Cidr: "1001:db8::/120"}}, - APIVip: "1001:db8::64", APIVips: []*models.APIVip{{IP: "1001:db8::64", Verification: VipVerificationPtr(models.VipVerificationSucceeded)}}, - IngressVip: "1001:db8::65", IngressVips: []*models.IngressVip{{IP: "1001:db8::65", Verification: VipVerificationPtr(models.VipVerificationSucceeded)}}, } @@ -273,9 +267,7 @@ var TestEquivalentIPv6Networking = TestNetworking{ ClusterNetworks: []*models.ClusterNetwork{{Cidr: "1003:0db8:0::/53", HostPrefix: 64}}, ServiceNetworks: []*models.ServiceNetwork{{Cidr: "1002:0db8:0::/119"}}, MachineNetworks: []*models.MachineNetwork{{Cidr: "1001:0db8:0::/120"}}, - APIVip: "1001:0db8:0::64", APIVips: []*models.APIVip{{IP: "1001:db8::64"}}, - IngressVip: "1001:0db8:0::65", IngressVips: []*models.IngressVip{{IP: "1001:db8::65"}}, } @@ -283,9 +275,7 @@ var TestDualStackNetworking = TestNetworking{ ClusterNetworks: append(TestIPv4Networking.ClusterNetworks, TestIPv6Networking.ClusterNetworks...), ServiceNetworks: append(TestIPv4Networking.ServiceNetworks, TestIPv6Networking.ServiceNetworks...), MachineNetworks: append(TestIPv4Networking.MachineNetworks, TestIPv6Networking.MachineNetworks...), - APIVip: TestIPv4Networking.APIVip, APIVips: TestIPv4Networking.APIVips, - IngressVip: TestIPv4Networking.IngressVip, IngressVips: TestIPv4Networking.IngressVips, } diff --git a/internal/controller/controllers/clusterdeployments_controller.go b/internal/controller/controllers/clusterdeployments_controller.go index f2e5e46e52..7d60a0fd0a 100644 --- a/internal/controller/controllers/clusterdeployments_controller.go +++ b/internal/controller/controllers/clusterdeployments_controller.go @@ -929,16 +929,16 @@ func (r *ClusterDeploymentsReconciler) updateNetworkParams(clusterDeployment *hi // We must not run this reconciler in case VIPs are missing from the cluster spec as this can // indicate a scenario when backend calculates them automatically, e.g. SNO cluster. isDHCPEnabled := swag.BoolValue(cluster.VipDhcpAllocation) - if !isDHCPEnabled && (clusterInstall.Spec.APIVIP != "" || clusterInstall.Spec.IngressVIP != "") { + if !isDHCPEnabled && (clusterInstall.Spec.APIVIP != "" || clusterInstall.Spec.IngressVIP != "" || + len(clusterInstall.Spec.APIVIPs) > 0 || len(clusterInstall.Spec.IngressVIPs) > 0) { desiredApiVips, _ := validations.HandleApiVipBackwardsCompatibility( *cluster.ID, clusterInstall.Spec.APIVIP, apiVipsEntriesToArray(clusterInstall.Spec.APIVIPs)) - if clusterInstall.Spec.APIVIP != cluster.APIVip || + if clusterInstall.Spec.APIVIP != network.GetApiVipById(cluster, 0) || !network.AreApiVipsIdentical(desiredApiVips, cluster.APIVips) { - params.APIVip = swag.String(clusterInstall.Spec.APIVIP) params.APIVips = desiredApiVips update = true } @@ -947,10 +947,9 @@ func (r *ClusterDeploymentsReconciler) updateNetworkParams(clusterDeployment *hi clusterInstall.Spec.IngressVIP, ingressVipsEntriesToArray(clusterInstall.Spec.IngressVIPs)) - if clusterInstall.Spec.IngressVIP != cluster.IngressVip || + if clusterInstall.Spec.IngressVIP != network.GetIngressVipById(cluster, 0) || !network.AreIngressVipsIdentical(desiredIngressVips, cluster.IngressVips) { - params.IngressVip = swag.String(clusterInstall.Spec.IngressVIP) params.IngressVips = desiredIngressVips update = true } @@ -1267,8 +1266,8 @@ func CreateClusterParams(clusterDeployment *hivev1.ClusterDeployment, clusterIns OlmOperators: nil, // TODO: handle operators PullSecret: swag.String(pullSecret), VipDhcpAllocation: swag.Bool(false), - APIVip: clusterInstall.Spec.APIVIP, - IngressVip: clusterInstall.Spec.IngressVIP, + APIVips: apiVipsEntriesToArray(clusterInstall.Spec.APIVIPs), + IngressVips: ingressVipsEntriesToArray(clusterInstall.Spec.IngressVIPs), SSHPublicKey: clusterInstall.Spec.SSHPublicKey, CPUArchitecture: releaseImageCPUArch, UserManagedNetworking: swag.Bool(isUserManagedNetwork(clusterInstall)), @@ -1711,8 +1710,8 @@ func (r *ClusterDeploymentsReconciler) updateStatus(ctx context.Context, log log } else { clusterInstall.Status.Progress.TotalPercentage = c.Progress.TotalPercentage } - clusterInstall.Status.APIVIP = c.APIVip - clusterInstall.Status.IngressVIP = c.IngressVip + clusterInstall.Status.APIVIP = network.GetApiVipById(c, 0) + clusterInstall.Status.IngressVIP = network.GetIngressVipById(c, 0) clusterInstall.Status.APIVIPs = apiVipsArrayToStrings(c.APIVips) clusterInstall.Status.IngressVIPs = ingressVipsArrayToStrings(c.IngressVips) clusterInstall.Status.UserManagedNetworking = c.UserManagedNetworking diff --git a/internal/controller/controllers/clusterdeployments_controller_test.go b/internal/controller/controllers/clusterdeployments_controller_test.go index b5426f5c63..4117f5a769 100644 --- a/internal/controller/controllers/clusterdeployments_controller_test.go +++ b/internal/controller/controllers/clusterdeployments_controller_test.go @@ -115,8 +115,10 @@ func newAgentClusterInstall(name, namespace string, spec hiveext.AgentClusterIns func getDefaultAgentClusterInstallSpec(clusterName string) hiveext.AgentClusterInstallSpec { return hiveext.AgentClusterInstallSpec{ - APIVIP: common.TestIPv4Networking.APIVip, - IngressVIP: common.TestIPv4Networking.IngressVip, + APIVIP: string(common.TestIPv4Networking.APIVips[0].IP), + IngressVIP: string(common.TestIPv4Networking.IngressVips[0].IP), + APIVIPs: apiVipsArrayToStrings(common.TestIPv4Networking.APIVips), + IngressVIPs: ingressVipsArrayToStrings(common.TestIPv4Networking.IngressVips), Networking: hiveext.Networking{ MachineNetwork: nil, ClusterNetwork: clusterNetworksArrayToEntries(common.TestIPv4Networking.ClusterNetworks), @@ -695,7 +697,7 @@ var _ = Describe("cluster reconcile", func() { Expect(params.Name).To(Equal(&cluster.Spec.ClusterName)) Expect(params.BaseDNSDomain).To(Equal(cluster.Spec.BaseDomain)) Expect(params.PullSecret).To(Equal(&pullSecretString)) - Expect(params.IngressVip).To(Equal(aci.Spec.IngressVIP)) + Expect(string(params.IngressVips[0].IP)).To(Equal(aci.Spec.IngressVIPs[0])) Expect(params.SSHPublicKey).To(Equal(aci.Spec.SSHPublicKey)) Expect(params.CPUArchitecture).To(Equal(cpuArch)) Expect(params.OpenshiftVersion).To(Equal(&openshiftVersion)) @@ -849,10 +851,8 @@ var _ = Describe("cluster reconcile", func() { ServiceNetworks: serviceNetworksEntriesToArray(defaultAgentClusterInstallSpec.Networking.ServiceNetwork), NetworkType: swag.String(models.ClusterNetworkTypeOpenShiftSDN), Status: swag.String(models.ClusterStatusReady), - IngressVip: defaultAgentClusterInstallSpec.IngressVIP, - APIVip: defaultAgentClusterInstallSpec.APIVIP, - IngressVips: []*models.IngressVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.IngressVIP)}}, - APIVips: []*models.APIVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.APIVIP)}}, + APIVips: common.TestIPv4Networking.APIVips, + IngressVips: common.TestIPv4Networking.IngressVips, BaseDNSDomain: defaultClusterSpec.BaseDomain, SSHPublicKey: defaultAgentClusterInstallSpec.SSHPublicKey, Hyperthreading: models.ClusterHyperthreadingAll, @@ -959,10 +959,8 @@ var _ = Describe("cluster reconcile", func() { Hyperthreading: models.ClusterHyperthreadingAll, SSHPublicKey: "some-key", NetworkType: swag.String(models.ClusterNetworkTypeOVNKubernetes), - APIVip: aci.Spec.APIVIP, - IngressVip: aci.Spec.IngressVIP, - APIVips: []*models.APIVip{{ClusterID: sId, IP: models.IP(aci.Spec.APIVIP)}}, - IngressVips: []*models.IngressVip{{ClusterID: sId, IP: models.IP(aci.Spec.IngressVIP)}}, + APIVips: common.TestIPv4Networking.APIVips, + IngressVips: common.TestIPv4Networking.IngressVips, }, PullSecret: testPullSecretVal, } @@ -1343,8 +1341,6 @@ var _ = Describe("cluster reconcile", func() { ServiceNetworks: serviceNetworksEntriesToArray(defaultAgentClusterInstallSpec.Networking.ServiceNetwork), NetworkType: swag.String(models.ClusterNetworkTypeOpenShiftSDN), Status: swag.String(models.ClusterStatusReady), - IngressVip: defaultAgentClusterInstallSpec.IngressVIP, - APIVip: defaultAgentClusterInstallSpec.APIVIP, IngressVips: []*models.IngressVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.IngressVIP)}}, APIVips: []*models.APIVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.APIVIP)}}, BaseDNSDomain: defaultClusterSpec.BaseDomain, @@ -1598,8 +1594,7 @@ var _ = Describe("cluster reconcile", func() { Name: clusterName, OpenshiftVersion: "4.8", Status: swag.String(models.ClusterStatusAddingHosts), - APIVip: backEndCluster.APIVip, - APIVips: []*models.APIVip{{ClusterID: *backEndCluster.ID, IP: models.IP(backEndCluster.APIVip)}}, + APIVips: backEndCluster.APIVips, BaseDNSDomain: backEndCluster.BaseDNSDomain, Kind: swag.String(models.ClusterKindAddHostsCluster), APIVipDNSName: swag.String(fmt.Sprintf("api.%s.%s", backEndCluster.Name, backEndCluster.BaseDNSDomain)), @@ -1683,10 +1678,8 @@ var _ = Describe("cluster reconcile", func() { Name: clusterName, OpenshiftVersion: "4.8", Status: swag.String(models.ClusterStatusAddingHosts), - APIVip: backEndCluster.APIVip, - APIVips: []*models.APIVip{{ClusterID: *backEndCluster.ID, IP: models.IP(backEndCluster.APIVip)}}, - IngressVip: backEndCluster.IngressVip, - IngressVips: []*models.IngressVip{{ClusterID: *backEndCluster.ID, IP: models.IP(backEndCluster.IngressVip)}}, + APIVips: backEndCluster.APIVips, + IngressVips: backEndCluster.IngressVips, BaseDNSDomain: backEndCluster.BaseDNSDomain, Kind: swag.String(models.ClusterKindAddHostsCluster), APIVipDNSName: swag.String(fmt.Sprintf("api.%s.%s", backEndCluster.Name, backEndCluster.BaseDNSDomain)), @@ -1740,8 +1733,7 @@ var _ = Describe("cluster reconcile", func() { Name: clusterName, OpenshiftVersion: "4.8", Status: swag.String(models.ClusterStatusAddingHosts), - APIVip: backEndCluster.APIVip, - APIVips: []*models.APIVip{{ClusterID: *backEndCluster.ID, IP: models.IP(backEndCluster.APIVip)}}, + APIVips: backEndCluster.APIVips, BaseDNSDomain: backEndCluster.BaseDNSDomain, Kind: swag.String(models.ClusterKindAddHostsCluster), APIVipDNSName: swag.String(fmt.Sprintf("api.%s.%s", backEndCluster.Name, backEndCluster.BaseDNSDomain)), @@ -2455,10 +2447,8 @@ var _ = Describe("cluster reconcile", func() { installClusterReply := &common.Cluster{ Cluster: models.Cluster{ ID: backEndCluster.ID, - APIVip: defaultAgentClusterInstallSpec.APIVIP, - IngressVip: defaultAgentClusterInstallSpec.IngressVIP, - APIVips: []*models.APIVip{{ClusterID: *backEndCluster.ID, IP: models.IP(defaultAgentClusterInstallSpec.APIVIP)}}, - IngressVips: []*models.IngressVip{{ClusterID: *backEndCluster.ID, IP: models.IP(defaultAgentClusterInstallSpec.IngressVIP)}}, + APIVips: common.TestIPv4Networking.APIVips, + IngressVips: common.TestIPv4Networking.IngressVips, Status: swag.String(models.ClusterStatusPreparingForInstallation), StatusInfo: swag.String("Waiting for control plane"), }, @@ -2475,8 +2465,8 @@ var _ = Describe("cluster reconcile", func() { Expect(FindStatusCondition(aci.Status.Conditions, hiveext.ClusterCompletedCondition).Reason).To(Equal(hiveext.ClusterInstallationInProgressReason)) Expect(FindStatusCondition(aci.Status.Conditions, hiveext.ClusterCompletedCondition).Message).To(Equal(hiveext.ClusterInstallationInProgressMsg + " Waiting for control plane")) Expect(FindStatusCondition(aci.Status.Conditions, hiveext.ClusterCompletedCondition).Status).To(Equal(corev1.ConditionFalse)) - Expect(aci.Status.APIVIP).To(Equal(defaultAgentClusterInstallSpec.APIVIP)) - Expect(aci.Status.IngressVIP).To(Equal(defaultAgentClusterInstallSpec.IngressVIP)) + Expect(aci.Status.APIVIPs).To(Equal(defaultAgentClusterInstallSpec.APIVIPs)) + Expect(aci.Status.IngressVIPs).To(Equal(defaultAgentClusterInstallSpec.IngressVIPs)) }) }) @@ -2512,10 +2502,8 @@ var _ = Describe("cluster reconcile", func() { ServiceNetworks: serviceNetworksEntriesToArray(defaultAgentClusterInstallSpec.Networking.ServiceNetwork), NetworkType: swag.String(models.ClusterNetworkTypeOpenShiftSDN), Status: swag.String(models.ClusterStatusInsufficient), - IngressVip: defaultAgentClusterInstallSpec.IngressVIP, - APIVip: defaultAgentClusterInstallSpec.APIVIP, - IngressVips: []*models.IngressVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.IngressVIP)}}, - APIVips: []*models.APIVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.APIVIP)}}, + APIVips: common.TestIPv4Networking.APIVips, + IngressVips: common.TestIPv4Networking.IngressVips, BaseDNSDomain: defaultClusterSpec.BaseDomain, SSHPublicKey: defaultAgentClusterInstallSpec.SSHPublicKey, Hyperthreading: models.ClusterHyperthreadingAll, @@ -2597,8 +2585,8 @@ var _ = Describe("cluster reconcile", func() { ServiceNetworks: serviceNetworksEntriesToArray(defaultAgentClusterInstallSpec.Networking.ServiceNetwork), NetworkType: swag.String(models.ClusterNetworkTypeOpenShiftSDN), Status: swag.String(models.ClusterStatusInsufficient), - IngressVip: defaultAgentClusterInstallSpec.IngressVIP, - APIVip: defaultAgentClusterInstallSpec.APIVIP, + IngressVips: common.TestIPv4Networking.IngressVips, + APIVips: common.TestIPv4Networking.APIVips, BaseDNSDomain: defaultClusterSpec.BaseDomain, SSHPublicKey: defaultAgentClusterInstallSpec.SSHPublicKey, }, @@ -2642,8 +2630,8 @@ var _ = Describe("cluster reconcile", func() { ServiceNetworks: serviceNetworksEntriesToArray(defaultAgentClusterInstallSpec.Networking.ServiceNetwork), NetworkType: swag.String(models.ClusterNetworkTypeOpenShiftSDN), Status: swag.String(models.ClusterStatusInsufficient), - IngressVip: defaultAgentClusterInstallSpec.IngressVIP, - APIVip: defaultAgentClusterInstallSpec.APIVIP, + IngressVips: common.TestIPv4Networking.IngressVips, + APIVips: common.TestIPv4Networking.APIVips, BaseDNSDomain: defaultClusterSpec.BaseDomain, SSHPublicKey: defaultAgentClusterInstallSpec.SSHPublicKey, }, @@ -2788,8 +2776,6 @@ var _ = Describe("cluster reconcile", func() { ServiceNetworks: serviceNetworksEntriesToArray(defaultAgentClusterInstallSpec.Networking.ServiceNetwork), NetworkType: swag.String(models.ClusterNetworkTypeOpenShiftSDN), Status: swag.String(models.ClusterStatusInsufficient), - IngressVip: defaultAgentClusterInstallSpec.IngressVIP, - APIVip: defaultAgentClusterInstallSpec.APIVIP, IngressVips: []*models.IngressVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.IngressVIP)}}, APIVips: []*models.APIVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.APIVIP)}}, BaseDNSDomain: defaultClusterSpec.BaseDomain, @@ -2874,8 +2860,6 @@ var _ = Describe("cluster reconcile", func() { ServiceNetworks: serviceNetworksEntriesToArray(defaultAgentClusterInstallSpec.Networking.ServiceNetwork), NetworkType: swag.String(models.ClusterNetworkTypeOpenShiftSDN), Status: swag.String(models.ClusterStatusInsufficient), - IngressVip: defaultAgentClusterInstallSpec.IngressVIP, - APIVip: defaultAgentClusterInstallSpec.APIVIP, IngressVips: []*models.IngressVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.IngressVIP)}}, APIVips: []*models.APIVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.APIVIP)}}, BaseDNSDomain: defaultClusterSpec.BaseDomain, @@ -2920,8 +2904,6 @@ var _ = Describe("cluster reconcile", func() { ServiceNetworks: serviceNetworksEntriesToArray(defaultAgentClusterInstallSpec.Networking.ServiceNetwork), NetworkType: swag.String(models.ClusterNetworkTypeOpenShiftSDN), Status: swag.String(models.ClusterStatusInsufficient), - IngressVip: defaultAgentClusterInstallSpec.IngressVIP, - APIVip: defaultAgentClusterInstallSpec.APIVIP, IngressVips: []*models.IngressVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.IngressVIP)}}, APIVips: []*models.APIVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.APIVIP)}}, BaseDNSDomain: defaultClusterSpec.BaseDomain, @@ -2963,10 +2945,8 @@ var _ = Describe("cluster reconcile", func() { ServiceNetworks: serviceNetworksEntriesToArray(defaultAgentClusterInstallSpec.Networking.ServiceNetwork), NetworkType: swag.String(models.ClusterNetworkTypeOpenShiftSDN), Status: swag.String(models.ClusterStatusInsufficient), - IngressVip: defaultAgentClusterInstallSpec.IngressVIP, - APIVip: defaultAgentClusterInstallSpec.APIVIP, - IngressVips: []*models.IngressVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.IngressVIP)}}, - APIVips: []*models.APIVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.APIVIP)}}, + IngressVips: common.TestIPv4Networking.IngressVips, + APIVips: common.TestIPv4Networking.APIVips, BaseDNSDomain: defaultClusterSpec.BaseDomain, SSHPublicKey: defaultAgentClusterInstallSpec.SSHPublicKey, Hyperthreading: models.ClusterHyperthreadingAll, @@ -3010,10 +2990,8 @@ var _ = Describe("cluster reconcile", func() { ServiceNetworks: serviceNetworksEntriesToArray(defaultAgentClusterInstallSpec.Networking.ServiceNetwork), NetworkType: swag.String(models.ClusterNetworkTypeOpenShiftSDN), Status: swag.String(models.ClusterStatusInsufficient), - IngressVip: defaultAgentClusterInstallSpec.IngressVIP, - APIVip: defaultAgentClusterInstallSpec.APIVIP, - IngressVips: []*models.IngressVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.IngressVIP)}}, - APIVips: []*models.APIVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.APIVIP)}}, + IngressVips: common.TestIPv4Networking.IngressVips, + APIVips: common.TestIPv4Networking.APIVips, BaseDNSDomain: defaultClusterSpec.BaseDomain, SSHPublicKey: defaultAgentClusterInstallSpec.SSHPublicKey, Hyperthreading: models.ClusterHyperthreadingAll, @@ -3064,10 +3042,8 @@ var _ = Describe("cluster reconcile", func() { ServiceNetworks: serviceNetworksEntriesToArray(defaultAgentClusterInstallSpec.Networking.ServiceNetwork), NetworkType: swag.String(models.ClusterNetworkTypeOpenShiftSDN), Status: swag.String(models.ClusterStatusInsufficient), - IngressVip: defaultAgentClusterInstallSpec.IngressVIP, - APIVip: defaultAgentClusterInstallSpec.APIVIP, - IngressVips: []*models.IngressVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.IngressVIP)}}, - APIVips: []*models.APIVip{{ClusterID: sId, IP: models.IP(defaultAgentClusterInstallSpec.APIVIP)}}, + IngressVips: common.TestIPv4Networking.IngressVips, + APIVips: common.TestIPv4Networking.APIVips, BaseDNSDomain: defaultClusterSpec.BaseDomain, SSHPublicKey: defaultAgentClusterInstallSpec.SSHPublicKey, Hyperthreading: models.ClusterHyperthreadingAll, @@ -3105,8 +3081,6 @@ var _ = Describe("cluster reconcile", func() { ServiceNetworks: serviceNetworksEntriesToArray(defaultAgentClusterInstallSpec.Networking.ServiceNetwork), NetworkType: swag.String(models.ClusterNetworkTypeOVNKubernetes), Status: swag.String(models.ClusterStatusInstalling), - IngressVip: hostIP, - APIVip: hostIP, IngressVips: []*models.IngressVip{{ClusterID: sId, IP: models.IP(hostIP)}}, APIVips: []*models.APIVip{{ClusterID: sId, IP: models.IP(hostIP)}}, BaseDNSDomain: defaultClusterSpec.BaseDomain, @@ -3122,12 +3096,10 @@ var _ = Describe("cluster reconcile", func() { mockInstallerInternal.EXPECT().HostWithCollectedLogsExists(gomock.Any()).Return(false, nil) mockInstallerInternal.EXPECT().UpdateClusterNonInteractive(gomock.Any(), gomock.Any()). Do(func(ctx context.Context, param installer.V2UpdateClusterParams) { - Expect(swag.StringValue(param.ClusterUpdateParams.APIVip)).To(Equal(common.TestIPv4Networking.APIVip)) - Expect(swag.StringValue(param.ClusterUpdateParams.IngressVip)).To(Equal(common.TestIPv4Networking.IngressVip)) Expect(len(param.ClusterUpdateParams.APIVips)).To(Equal(1)) Expect(len(param.ClusterUpdateParams.IngressVips)).To(Equal(1)) - Expect(string(param.ClusterUpdateParams.APIVips[0].IP)).To(Equal(common.TestIPv4Networking.APIVip)) - Expect(string(param.ClusterUpdateParams.IngressVips[0].IP)).To(Equal(common.TestIPv4Networking.IngressVip)) + Expect(param.ClusterUpdateParams.APIVips[0].IP).To(Equal(common.TestIPv4Networking.APIVips[0].IP)) + Expect(param.ClusterUpdateParams.IngressVips[0].IP).To(Equal(common.TestIPv4Networking.IngressVips[0].IP)) }).Return(backEndCluster, nil) pullSecret := getDefaultTestPullSecret("pull-secret", testNamespace) @@ -3157,8 +3129,8 @@ var _ = Describe("cluster reconcile", func() { ServiceNetworks: serviceNetworksEntriesToArray(defaultAgentClusterInstallSpec.Networking.ServiceNetwork), NetworkType: swag.String(models.ClusterNetworkTypeOpenShiftSDN), Status: swag.String(models.ClusterStatusInstalling), - IngressVip: defaultAgentClusterInstallSpec.IngressVIP, - APIVip: defaultAgentClusterInstallSpec.APIVIP, + IngressVips: common.TestIPv4Networking.IngressVips, + APIVips: common.TestIPv4Networking.APIVips, BaseDNSDomain: defaultClusterSpec.BaseDomain, SSHPublicKey: defaultAgentClusterInstallSpec.SSHPublicKey, Hyperthreading: models.ClusterHyperthreadingAll, @@ -4161,9 +4133,7 @@ var _ = Describe("day2 cluster", func() { Kind: swag.String(models.ClusterKindAddHostsCluster), ID: &id, Status: swag.String(models.ClusterStatusInstalled), - APIVip: common.TestIPv4Networking.APIVip, APIVips: common.TestIPv4Networking.APIVips, - IngressVip: common.TestIPv4Networking.IngressVip, IngressVips: common.TestIPv4Networking.IngressVips, ClusterNetworks: common.TestIPv4Networking.ClusterNetworks, ServiceNetworks: common.TestIPv4Networking.ServiceNetworks, diff --git a/internal/dns/dns.go b/internal/dns/dns.go index 721fce1e5d..aa54c1b0c5 100644 --- a/internal/dns/dns.go +++ b/internal/dns/dns.go @@ -104,8 +104,8 @@ func (h *handler) updateDNSRecordSet(log logrus.FieldLogger, cluster *common.Clu return false, nil } - apiVip := cluster.APIVip - ingressVip := cluster.IngressVip + apiVip := network.GetApiVipById(cluster, 0) + ingressVip := network.GetIngressVipById(cluster, 0) if common.IsSingleNodeCluster(cluster) { apiVip, err = network.GetIpForSingleNodeInstallation(cluster, log) if err != nil { diff --git a/internal/dns/dns_test.go b/internal/dns/dns_test.go index 3dc1e5d8bd..3c5ad44808 100644 --- a/internal/dns/dns_test.go +++ b/internal/dns/dns_test.go @@ -11,6 +11,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/openshift/assisted-service/internal/common" + "github.com/openshift/assisted-service/internal/network" "github.com/openshift/assisted-service/models" "github.com/sirupsen/logrus" ) @@ -124,8 +125,8 @@ var _ = Describe("DNS record set update tests", func() { Cluster: models.Cluster{ Name: "ut-cluster", BaseDNSDomain: "dns-test.com", - APIVip: "10.56.20.50", - IngressVip: "2001:db8:3c4d:15::2b", + APIVips: []*models.APIVip{{IP: "10.56.20.50"}}, + IngressVips: []*models.IngressVip{{IP: "2001:db8:3c4d:15::2b"}}, MachineNetworks: []*models.MachineNetwork{{Cidr: "10.56.20.0/24"}}, }, } @@ -153,8 +154,8 @@ var _ = Describe("DNS record set update tests", func() { }) It("create DNS record set multi-node", func() { mockProv := NewMockDNSProvider(ctrl) - mockProv.EXPECT().CreateRecordSet(fmt.Sprintf("api.%s.%s", cluster.Name, cluster.BaseDNSDomain), cluster.APIVip).Times(1) - mockProv.EXPECT().CreateRecordSet(fmt.Sprintf("*.apps.%s.%s", cluster.Name, cluster.BaseDNSDomain), cluster.IngressVip).Times(1) + mockProv.EXPECT().CreateRecordSet(fmt.Sprintf("api.%s.%s", cluster.Name, cluster.BaseDNSDomain), network.GetApiVipById(cluster, 0)).Times(1) + mockProv.EXPECT().CreateRecordSet(fmt.Sprintf("*.apps.%s.%s", cluster.Name, cluster.BaseDNSDomain), network.GetIngressVipById(cluster, 0)).Times(1) mockProviders.EXPECT().GetProviderByRecordType(gomock.Any(), "A").Times(1).Return(mockProv) mockProviders.EXPECT().GetProviderByRecordType(gomock.Any(), "AAAA").Times(1).Return(mockProv) err := dns.CreateDNSRecordSets(ctx, cluster) @@ -162,8 +163,8 @@ var _ = Describe("DNS record set update tests", func() { }) It("delete DNS record set multi-node", func() { mockProv := NewMockDNSProvider(ctrl) - mockProv.EXPECT().DeleteRecordSet(fmt.Sprintf("api.%s.%s", cluster.Name, cluster.BaseDNSDomain), cluster.APIVip).Times(1) - mockProv.EXPECT().DeleteRecordSet(fmt.Sprintf("*.apps.%s.%s", cluster.Name, cluster.BaseDNSDomain), cluster.IngressVip).Times(1) + mockProv.EXPECT().DeleteRecordSet(fmt.Sprintf("api.%s.%s", cluster.Name, cluster.BaseDNSDomain), network.GetApiVipById(cluster, 0)).Times(1) + mockProv.EXPECT().DeleteRecordSet(fmt.Sprintf("*.apps.%s.%s", cluster.Name, cluster.BaseDNSDomain), network.GetIngressVipById(cluster, 0)).Times(1) mockProviders.EXPECT().GetProviderByRecordType(gomock.Any(), "A").Times(1).Return(mockProv) mockProviders.EXPECT().GetProviderByRecordType(gomock.Any(), "AAAA").Times(1).Return(mockProv) err := dns.DeleteDNSRecordSets(ctx, cluster) diff --git a/internal/installcfg/builder/builder_test.go b/internal/installcfg/builder/builder_test.go index 4b1b7259ff..eb916337e0 100644 --- a/internal/installcfg/builder/builder_test.go +++ b/internal/installcfg/builder/builder_test.go @@ -89,8 +89,8 @@ aEA8gNEmV+rb7h1v0r3EwDQYJKoZIhvcNAQELBQAwYTELMAkGA1UEBhMCaXMxCzAJBgNVBAgMAmRk ClusterNetworks: []*models.ClusterNetwork{{Cidr: "1.1.1.0/24"}}, ServiceNetworks: []*models.ServiceNetwork{{Cidr: "2.2.2.0/24"}}, MachineNetworks: []*models.MachineNetwork{{Cidr: "1.2.3.0/24"}}, - APIVip: "1.2.3.11", - IngressVip: "1.2.3.12", + APIVips: []*models.APIVip{{IP: "1.2.3.11", ClusterID: clusterId}}, + IngressVips: []*models.IngressVip{{IP: "1.2.3.12", ClusterID: clusterId}}, InstallConfigOverrides: `{"fips":true}`, ImageInfo: &models.ImageInfo{}, Platform: &models.Platform{Type: common.PlatformTypePtr(models.PlatformTypeBaremetal)}, @@ -713,8 +713,8 @@ var _ = Describe("ValidateInstallConfigPatch", func() { ID: &id, OpenshiftVersion: "4.6", BaseDNSDomain: "example.com", - APIVip: "102.345.34.34", - IngressVip: "376.5.56.6", + APIVips: []*models.APIVip{{IP: "102.345.34.34", ClusterID: id}}, + IngressVips: []*models.IngressVip{{IP: "376.5.56.6", ClusterID: id}}, ImageInfo: &models.ImageInfo{}, Platform: &models.Platform{Type: common.PlatformTypePtr(models.PlatformTypeBaremetal)}, }} diff --git a/internal/migrations/20221031103047_multiple_vips.go b/internal/migrations/20221031103047_multiple_vips.go index e74f5d776c..2a930e68f8 100644 --- a/internal/migrations/20221031103047_multiple_vips.go +++ b/internal/migrations/20221031103047_multiple_vips.go @@ -2,37 +2,38 @@ package migrations import ( gormigrate "github.com/go-gormigrate/gormigrate/v2" - "github.com/openshift/assisted-service/internal/common" "github.com/openshift/assisted-service/models" "gorm.io/gorm" ) func multipleVips() *gormigrate.Migration { migrate := func(tx *gorm.DB) error { - dbClusters, err := common.GetClustersFromDBWhere(tx, common.UseEagerLoading, common.IncludeDeletedRecords) - if err != nil { - return err - } - for _, cluster := range dbClusters { - if cluster.APIVip != "" { - apiVIPs := &models.APIVip{ - ClusterID: *cluster.ID, - IP: models.IP(cluster.APIVip), - } - if err = tx.Save(apiVIPs).Error; err != nil { - return err - } - } - if cluster.IngressVip != "" { - ingressVIPs := &models.IngressVip{ - ClusterID: *cluster.ID, - IP: models.IP(cluster.IngressVip), - } - if err = tx.Save(ingressVIPs).Error; err != nil { - return err - } - } - } + // WIP + + //dbClusters, err := common.GetClustersFromDBWhere(tx, common.UseEagerLoading, common.IncludeDeletedRecords) + //if err != nil { + // return err + //} + //for _, cluster := range dbClusters { + // if cluster.APIVip != "" { + // apiVIPs := &models.APIVip{ + // ClusterID: *cluster.ID, + // IP: models.IP(cluster.APIVip), + // } + // if err = tx.Save(apiVIPs).Error; err != nil { + // return err + // } + // } + // if cluster.IngressVip != "" { + // ingressVIPs := &models.IngressVip{ + // ClusterID: *cluster.ID, + // IP: models.IP(cluster.IngressVip), + // } + // if err = tx.Save(ingressVIPs).Error; err != nil { + // return err + // } + // } + //} return nil } diff --git a/internal/migrations/20221031103047_multiple_vips_test.go b/internal/migrations/20221031103047_multiple_vips_test.go deleted file mode 100644 index 8d215fd26a..0000000000 --- a/internal/migrations/20221031103047_multiple_vips_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package migrations - -import ( - gormigrate "github.com/go-gormigrate/gormigrate/v2" - "github.com/go-openapi/strfmt" - "github.com/google/uuid" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/openshift/assisted-service/internal/common" - "github.com/openshift/assisted-service/models" - "gorm.io/gorm" -) - -var _ = Describe("multipleVips", func() { - var ( - db *gorm.DB - dbName string - clusterID strfmt.UUID - cluster *common.Cluster - ) - - BeforeEach(func() { - db, dbName = common.PrepareTestDB() - clusterID = strfmt.UUID(uuid.New().String()) - cluster = &common.Cluster{ - Cluster: models.Cluster{ - ID: &clusterID, - }, - } - Expect(db.Save(cluster).Error).ShouldNot(HaveOccurred()) - - _, err := common.GetClusterFromDB(db, clusterID, common.UseEagerLoading) - Expect(err).ShouldNot(HaveOccurred()) - - var value []string - db.Raw("UPDATE clusters SET api_vip = ? WHERE id = ? RETURNING id", "192.168.111.10", clusterID).Scan(&value) - db.Raw("UPDATE clusters SET ingress_vip = ? WHERE id = ? RETURNING id", "192.168.111.11", clusterID).Scan(&value) - - db.Raw("SELECT api_vip FROM clusters WHERE id = ?", clusterID).Scan(&value) - Expect(value[0]).To(Equal("192.168.111.10")) - db.Raw("SELECT ingress_vip FROM clusters WHERE id = ?", clusterID).Scan(&value) - Expect(value[0]).To(Equal("192.168.111.11")) - }) - - AfterEach(func() { - common.DeleteTestDB(db, dbName) - }) - - It("Migrates up", func() { - // setup - err := migrateTo(db, "20221031103047") - Expect(err).NotTo(HaveOccurred()) - - // test - var valueStr []string - var valueNum []int - db.Raw("SELECT COUNT(ip) FROM api_vips WHERE cluster_id = ?", clusterID).Scan(&valueNum) - Expect(valueNum[0]).To(Equal(1)) - db.Raw("SELECT ip FROM api_vips WHERE cluster_id = ?", clusterID).Scan(&valueStr) - Expect(valueStr[0]).To(Equal("192.168.111.10")) - db.Raw("SELECT COUNT(ip) FROM ingress_vips WHERE cluster_id = ?", clusterID).Scan(&valueNum) - Expect(valueNum[0]).To(Equal(1)) - db.Raw("SELECT ip FROM ingress_vips WHERE cluster_id = ?", clusterID).Scan(&valueStr) - Expect(valueStr[0]).To(Equal("192.168.111.11")) - }) - - It("Migrates down", func() { - err := migrateTo(db, "20221031103047") - Expect(err).NotTo(HaveOccurred()) - - // setup - err = gormigrate.New(db, gormigrate.DefaultOptions, post()).RollbackMigration(multipleVips()) - Expect(err).NotTo(HaveOccurred()) - - // test - var valueNum []int - db.Raw("SELECT COUNT(ip) FROM api_vips WHERE cluster_id = ?", clusterID).Scan(&valueNum) - Expect(valueNum[0]).To(Equal(0)) - db.Raw("SELECT COUNT(ip) FROM ingress_vips WHERE cluster_id = ?", clusterID).Scan(&valueNum) - Expect(valueNum[0]).To(Equal(0)) - }) -}) diff --git a/internal/network/dhcp_param_file.go b/internal/network/dhcp_param_file.go index ec9ed60bf6..fb859a61bf 100644 --- a/internal/network/dhcp_param_file.go +++ b/internal/network/dhcp_param_file.go @@ -22,22 +22,23 @@ type vips struct { func generateOpenshiftDhcpParamFileContents(cluster *common.Cluster) ([]byte, error) { if swag.BoolValue(cluster.VipDhcpAllocation) && !swag.BoolValue(cluster.UserManagedNetworking) { - if cluster.APIVip != "" && cluster.IngressVip != "" { + if GetApiVipById(cluster, 0) != "" && GetIngressVipById(cluster, 0) != "" { v := vips{ APIVip: &vip{ Name: "api", MacAddress: GenerateAPIVipMAC(cluster.ID.String()), - IpAddress: cluster.APIVip, + IpAddress: GetApiVipById(cluster, 0), }, IngressVip: &vip{ Name: "ingress", MacAddress: GenerateIngressVipMAC(cluster.ID.String()), - IpAddress: cluster.IngressVip, + IpAddress: GetIngressVipById(cluster, 0), }, } return yaml.Marshal(&v) } else { - return nil, errors.Errorf("Either API VIP <%s> or Ingress VIP <%s> are not set", cluster.APIVip, cluster.IngressVip) + return nil, errors.Errorf("Either API VIP <%s> or Ingress VIP <%s> are not set", + GetApiVipById(cluster, 0), GetIngressVipById(cluster, 0)) } } return nil, nil diff --git a/internal/network/dhcp_param_file_test.go b/internal/network/dhcp_param_file_test.go index 17f15bbdf0..9b5229a6e6 100644 --- a/internal/network/dhcp_param_file_test.go +++ b/internal/network/dhcp_param_file_test.go @@ -27,8 +27,8 @@ var _ = Describe("dhcp param file", func() { Cluster: models.Cluster{ ID: &clusterId, VipDhcpAllocation: swag.Bool(dhcpEnabled), - APIVip: apiVip, - IngressVip: ingressVip, + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, }, } } diff --git a/internal/network/machine_network_cidr_test.go b/internal/network/machine_network_cidr_test.go index f6191d9a9d..3c1c67972e 100644 --- a/internal/network/machine_network_cidr_test.go +++ b/internal/network/machine_network_cidr_test.go @@ -39,7 +39,7 @@ func createHosts(inventories ...string) []*models.Host { func createCluster(apiVip string, machineCidr string, inventories ...string) *common.Cluster { return &common.Cluster{Cluster: models.Cluster{ - APIVip: apiVip, + APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, MachineNetworks: CreateMachineNetworksArray(machineCidr), Hosts: createHosts(inventories...), }} @@ -52,7 +52,7 @@ var _ = Describe("inventory", func() { cluster := createCluster("1.2.5.6", "", createInventory(createInterface("3.3.3.3/16"), createInterface("8.8.8.8/8", "1.2.5.7/23")), createInventory(createInterface("127.0.0.1/17"))) - cidr, err := CalculateMachineNetworkCIDR(cluster.APIVip, cluster.IngressVip, cluster.Hosts, true) + cidr, err := CalculateMachineNetworkCIDR(GetApiVipById(cluster, 0), GetIngressVipById(cluster, 0), cluster.Hosts, true) Expect(err).To(Not(HaveOccurred())) Expect(cidr).To(Equal("1.2.4.0/23")) }) @@ -62,7 +62,7 @@ var _ = Describe("inventory", func() { createInventory(addIPv6Addresses(createInterface(), "1001:db8::1/120")), createInventory(addIPv6Addresses(createInterface(), "1001:db8::2/120")), createInventory(addIPv6Addresses(createInterface(), "1001:db8::3/120"))) - cidr, err := CalculateMachineNetworkCIDR(cluster.APIVip, cluster.IngressVip, cluster.Hosts, true) + cidr, err := CalculateMachineNetworkCIDR(GetApiVipById(cluster, 0), GetIngressVipById(cluster, 0), cluster.Hosts, true) Expect(err).To(Not(HaveOccurred())) Expect(cidr).To(Equal("1001:db8::/120")) }) @@ -71,7 +71,7 @@ var _ = Describe("inventory", func() { cluster := createCluster("1.2.5.257", "", createInventory(createInterface("3.3.3.3/16"), createInterface("8.8.8.8/8", "1.2.5.7/23")), createInventory(createInterface("127.0.0.1/17"))) - cidr, err := CalculateMachineNetworkCIDR(cluster.APIVip, cluster.IngressVip, cluster.Hosts, true) + cidr, err := CalculateMachineNetworkCIDR(GetApiVipById(cluster, 0), GetIngressVipById(cluster, 0), cluster.Hosts, true) Expect(err).To(HaveOccurred()) Expect(cidr).To(Equal("")) }) @@ -80,7 +80,7 @@ var _ = Describe("inventory", func() { cluster := createCluster("1.2.5.200", "", createInventory(createInterface("3.3.3.3/16"), createInterface("8.8.8.8/8", "1.2.6.7/23")), createInventory(createInterface("127.0.0.1/17"))) - cidr, err := CalculateMachineNetworkCIDR(cluster.APIVip, cluster.IngressVip, cluster.Hosts, true) + cidr, err := CalculateMachineNetworkCIDR(GetApiVipById(cluster, 0), GetIngressVipById(cluster, 0), cluster.Hosts, true) Expect(err).To(HaveOccurred()) Expect(cidr).To(Equal("")) }) @@ -89,7 +89,7 @@ var _ = Describe("inventory", func() { "Bad inventory", createInventory(createInterface("3.3.3.3/16"), createInterface("8.8.8.8/8", "1.2.5.7/23")), createInventory(createInterface("127.0.0.1/17"))) - cidr, err := CalculateMachineNetworkCIDR(cluster.APIVip, cluster.IngressVip, cluster.Hosts, true) + cidr, err := CalculateMachineNetworkCIDR(GetApiVipById(cluster, 0), GetIngressVipById(cluster, 0), cluster.Hosts, true) Expect(err).To(Not(HaveOccurred())) Expect(cidr).To(Equal("1.2.4.0/23")) }) @@ -97,7 +97,7 @@ var _ = Describe("inventory", func() { cluster := createCluster("1.2.5.200", "", createInventory(createInterface("3.3.3.3/16"), createInterface("8.8.8.8/8", "1.2.6.7/23")), createInventory(createInterface("127.0.0.1/17"))) - cidr, err := CalculateMachineNetworkCIDR(cluster.APIVip, cluster.IngressVip, cluster.Hosts, false) + cidr, err := CalculateMachineNetworkCIDR(GetApiVipById(cluster, 0), GetIngressVipById(cluster, 0), cluster.Hosts, false) Expect(err).NotTo(HaveOccurred()) Expect(cidr).To(Equal("")) }) @@ -149,56 +149,56 @@ var _ = Describe("inventory", func() { FreeAddresses: "[{\"network\":\"1.2.4.0/23\",\"free_addresses\":[\"1.2.5.6\",\"1.2.5.8\"]}]", }, } - cluster.IngressVip = cluster.APIVip - err := VerifyVips(cluster.Hosts, primaryMachineCidr, cluster.APIVip, cluster.IngressVip, log) + cluster.IngressVips = []*models.IngressVip{{IP: models.IP(GetApiVipById(cluster, 0))}} + err := VerifyVips(cluster.Hosts, primaryMachineCidr, GetApiVipById(cluster, 0), GetIngressVipById(cluster, 0), log) Expect(err).To(HaveOccurred()) }) It("Different vips", func() { cluster := createCluster("1.2.5.6", primaryMachineCidr, createInventory(createInterface("1.2.5.7/23"))) - cluster.IngressVip = "1.2.5.8" + cluster.IngressVips = []*models.IngressVip{{IP: "1.2.5.8"}} cluster.Hosts = []*models.Host{ { FreeAddresses: "[{\"network\":\"1.2.4.0/23\",\"free_addresses\":[\"1.2.5.6\",\"1.2.5.8\"]}]", }, } - err := VerifyVips(cluster.Hosts, primaryMachineCidr, cluster.APIVip, cluster.IngressVip, log) + err := VerifyVips(cluster.Hosts, primaryMachineCidr, GetApiVipById(cluster, 0), GetIngressVipById(cluster, 0), log) Expect(err).ToNot(HaveOccurred()) }) It("Not free", func() { cluster := createCluster("1.2.5.6", primaryMachineCidr, createInventory(createInterface("1.2.5.7/23"))) - cluster.IngressVip = "1.2.5.8" + cluster.IngressVips = []*models.IngressVip{{IP: "1.2.5.8"}} cluster.Hosts = []*models.Host{ { FreeAddresses: "[{\"network\":\"1.2.4.0/23\",\"free_addresses\":[\"1.2.5.9\"]}]", }, } - err := VerifyVips(cluster.Hosts, primaryMachineCidr, cluster.APIVip, cluster.IngressVip, log) + err := VerifyVips(cluster.Hosts, primaryMachineCidr, GetApiVipById(cluster, 0), GetIngressVipById(cluster, 0), log) Expect(err).To(HaveOccurred()) }) It("Empty", func() { cluster := createCluster("1.2.5.6", primaryMachineCidr, createInventory(createInterface("1.2.5.7/23"))) - cluster.IngressVip = "1.2.5.8" + cluster.IngressVips = []*models.IngressVip{{IP: "1.2.5.8"}} cluster.Hosts = []*models.Host{ { FreeAddresses: "", }, } - err := VerifyVips(cluster.Hosts, primaryMachineCidr, cluster.APIVip, cluster.IngressVip, log) + err := VerifyVips(cluster.Hosts, primaryMachineCidr, GetApiVipById(cluster, 0), GetIngressVipById(cluster, 0), log) Expect(err).ToNot(HaveOccurred()) }) It("Free", func() { cluster := createCluster("1.2.5.6", primaryMachineCidr, createInventory(createInterface("1.2.5.7/23"))) - cluster.IngressVip = "1.2.5.8" + cluster.IngressVips = []*models.IngressVip{{IP: "1.2.5.8"}} cluster.Hosts = []*models.Host{ { FreeAddresses: "[{\"network\":\"1.2.4.0/23\",\"free_addresses\":[\"1.2.5.6\",\"1.2.5.8\",\"1.2.5.9\"]}]", }, } - err := VerifyVips(cluster.Hosts, primaryMachineCidr, cluster.APIVip, cluster.IngressVip, log) + err := VerifyVips(cluster.Hosts, primaryMachineCidr, GetApiVipById(cluster, 0), GetIngressVipById(cluster, 0), log) Expect(err).ToNot(HaveOccurred()) }) It("machine cidr is too small", func() { @@ -212,8 +212,8 @@ var _ = Describe("inventory", func() { FreeAddresses: "[{\"network\":\"1.2.5.0/29\",\"free_addresses\":[\"1.2.5.7\"]}]", } cluster.Hosts = []*models.Host{h, h, h, h, h} - cluster.APIVip = "1.2.5.2" - err := VerifyVips(cluster.Hosts, "1.2.5.0/29", cluster.APIVip, cluster.IngressVip, log) + cluster.APIVips = []*models.APIVip{{IP: "1.2.5.2"}} + err := VerifyVips(cluster.Hosts, "1.2.5.0/29", GetApiVipById(cluster, 0), GetIngressVipById(cluster, 0), log) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("The machine network range is too small for the cluster")) }) diff --git a/internal/network/utils.go b/internal/network/utils.go index 5693f48305..71e40d40a4 100644 --- a/internal/network/utils.go +++ b/internal/network/utils.go @@ -380,12 +380,6 @@ func UpdateVipsTables(db *gorm.DB, cluster *common.Cluster, apiVipUpdated bool, if apiVipUpdated { if err := db.Transaction(func(tx *gorm.DB) error { - if err := db.Model(&models.Cluster{}).Where("id = ?", *cluster.ID). - Update("api_vip", cluster.APIVip).Error; err != nil { - err = errors.Wrapf(err, "failed to delete api_vip of cluster %s", *cluster.ID) - return common.NewApiError(http.StatusInternalServerError, err) - } - if err := db.Where("cluster_id = ?", *cluster.ID).Delete(&models.APIVip{}).Error; err != nil { err = errors.Wrapf(err, "failed to delete api vips of cluster %s", *cluster.ID) return common.NewApiError(http.StatusInternalServerError, err) @@ -405,11 +399,6 @@ func UpdateVipsTables(db *gorm.DB, cluster *common.Cluster, apiVipUpdated bool, if ingressVipUpdated { if err := db.Transaction(func(tx *gorm.DB) error { - if err := db.Model(&models.Cluster{}).Where("id = ?", *cluster.ID). - Update("ingress_vip", cluster.IngressVip).Error; err != nil { - err = errors.Wrapf(err, "failed to delete ingress_vip of cluster %s", *cluster.ID) - return common.NewApiError(http.StatusInternalServerError, err) - } if err := db.Where("cluster_id = ?", *cluster.ID).Delete(&models.IngressVip{}).Error; err != nil { err = errors.Wrapf(err, "failed to delete ingress vips of cluster %s", *cluster.ID) return common.NewApiError(http.StatusInternalServerError, err) diff --git a/internal/network/utils_test.go b/internal/network/utils_test.go index 0e6fb29524..33fb4f568c 100644 --- a/internal/network/utils_test.go +++ b/internal/network/utils_test.go @@ -964,9 +964,7 @@ var _ = Describe("GetVips", func() { cluster = &common.Cluster{ Cluster: models.Cluster{ Name: "cluster", - APIVip: "192.168.10.10", APIVips: []*models.APIVip{{IP: "192.168.10.10"}}, - IngressVip: "192.168.10.11", IngressVips: []*models.IngressVip{{IP: "192.168.10.11"}}, OpenshiftVersion: "4.12", MachineNetworks: []*models.MachineNetwork{{Cidr: "192.168.10.0/24"}}, @@ -991,9 +989,7 @@ var _ = Describe("GetVips", func() { cluster = &common.Cluster{ Cluster: models.Cluster{ Name: "cluster", - APIVip: "192.168.10.10", APIVips: []*models.APIVip{{IP: "192.168.10.10"}, {IP: "1001:db8:0:200::78"}}, - IngressVip: "192.168.10.11", IngressVips: []*models.IngressVip{{IP: "192.168.10.11"}, {IP: "1001:db8:0:200::79"}}, OpenshiftVersion: "4.12", MachineNetworks: []*models.MachineNetwork{{Cidr: "192.168.10.0/24"}, {Cidr: "1001:db8:0:200::/40"}}, diff --git a/internal/operators/odf/validation_test.go b/internal/operators/odf/validation_test.go index d5e515bd90..5a8650fe68 100644 --- a/internal/operators/odf/validation_test.go +++ b/internal/operators/odf/validation_test.go @@ -881,9 +881,7 @@ var _ = Describe("Ocs Operator use-cases", func() { ClusterNetworks: common.TestIPv4Networking.ClusterNetworks, ServiceNetworks: common.TestIPv4Networking.ServiceNetworks, MachineNetworks: common.TestIPv4Networking.MachineNetworks, - APIVip: common.TestIPv4Networking.APIVip, APIVips: common.TestIPv4Networking.APIVips, - IngressVip: common.TestIPv4Networking.IngressVip, IngressVips: common.TestIPv4Networking.IngressVips, Status: &t.srcState, StatusInfo: &t.srcStatusInfo, diff --git a/internal/provider/baremetal/installConfig.go b/internal/provider/baremetal/installConfig.go index 1572de9ad0..424023bfd9 100644 --- a/internal/provider/baremetal/installConfig.go +++ b/internal/provider/baremetal/installConfig.go @@ -103,6 +103,8 @@ func (p baremetalProvider) AddPlatformToInstallConfig( cfg.Platform = installcfg.Platform{ Baremetal: &installcfg.BareMetalInstallConfigPlatform{ ProvisioningNetwork: provNetwork, + APIVIPs: []string{network.GetApiVips(cluster)[0]}, + IngressVIPs: []string{network.GetIngressVips(cluster)[0]}, DeprecatedAPIVIP: network.GetApiVipById(cluster, 0), DeprecatedIngressVIP: network.GetIngressVipById(cluster, 0), Hosts: hosts, diff --git a/internal/provider/nutanix/installConfig.go b/internal/provider/nutanix/installConfig.go index 498b2d090f..89797a7579 100644 --- a/internal/provider/nutanix/installConfig.go +++ b/internal/provider/nutanix/installConfig.go @@ -54,6 +54,8 @@ func (p nutanixProvider) AddPlatformToInstallConfig( nPlatform.APIVIPs = network.GetApiVips(cluster) nPlatform.IngressVIPs = network.GetIngressVips(cluster) } else { + nPlatform.APIVIPs = []string{network.GetApiVips(cluster)[0]} + nPlatform.IngressVIPs = []string{network.GetIngressVips(cluster)[0]} nPlatform.DeprecatedAPIVIP = network.GetApiVipById(cluster, 0) nPlatform.DeprecatedIngressVIP = network.GetIngressVipById(cluster, 0) } diff --git a/internal/provider/registry/registry_test.go b/internal/provider/registry/registry_test.go index 8af86fd135..a6c42a2744 100644 --- a/internal/provider/registry/registry_test.go +++ b/internal/provider/registry/registry_test.go @@ -26,7 +26,11 @@ var ( const invalidInventory = "{\"system_vendor\": \"invalid\"}" -const expectedNutanixInstallConfig411 = `apiVIP: 192.168.10.10 +const expectedNutanixInstallConfig411 = `apiVIPs: +- 192.168.10.10 +apiVIP: 192.168.10.10 +ingressVIPs: +- 192.168.10.11 ingressVIP: 192.168.10.11 prismCentral: endpoint: @@ -204,8 +208,8 @@ var _ = Describe("Test AddPlatformToInstallConfig", func() { err := providerRegistry.AddPlatformToInstallConfig(models.PlatformTypeBaremetal, &cfg, &cluster) Expect(err).To(BeNil()) Expect(cfg.Platform.Baremetal).ToNot(BeNil()) - Expect(cfg.Platform.Baremetal.DeprecatedAPIVIP).To(Equal(cluster.Cluster.APIVip)) - Expect(cfg.Platform.Baremetal.DeprecatedIngressVIP).To(Equal(cluster.Cluster.IngressVip)) + Expect(cfg.Platform.Baremetal.APIVIPs[0]).To(Equal(string(cluster.Cluster.APIVips[0].IP))) + Expect(cfg.Platform.Baremetal.IngressVIPs[0]).To(Equal(string(cluster.Cluster.IngressVips[0].IP))) Expect(cfg.Platform.Baremetal.ProvisioningNetwork).To(Equal("Disabled")) Expect(len(cfg.Platform.Baremetal.Hosts)).To(Equal(len(cluster.Cluster.Hosts))) Expect(cfg.Platform.Baremetal.Hosts[0].Name).Should(Equal("hostname0")) @@ -228,8 +232,8 @@ var _ = Describe("Test AddPlatformToInstallConfig", func() { err := providerRegistry.AddPlatformToInstallConfig(models.PlatformTypeBaremetal, &cfg, &cluster) Expect(err).To(BeNil()) Expect(cfg.Platform.Baremetal).ToNot(BeNil()) - Expect(cfg.Platform.Baremetal.DeprecatedAPIVIP).To(Equal(cluster.Cluster.APIVip)) - Expect(cfg.Platform.Baremetal.DeprecatedIngressVIP).To(Equal(cluster.Cluster.IngressVip)) + Expect(cfg.Platform.Baremetal.APIVIPs[0]).To(Equal(string(cluster.Cluster.APIVips[0].IP))) + Expect(cfg.Platform.Baremetal.IngressVIPs[0]).To(Equal(string(cluster.Cluster.IngressVips[0].IP))) Expect(cfg.Platform.Baremetal.ProvisioningNetwork).To(Equal("Unmanaged")) Expect(len(cfg.Platform.Baremetal.Hosts)).To(Equal(len(cluster.Cluster.Hosts))) Expect(cfg.Platform.Baremetal.Hosts[0].Name).Should(Equal("hostname0")) @@ -308,8 +312,8 @@ var _ = Describe("Test AddPlatformToInstallConfig", func() { err := providerRegistry.AddPlatformToInstallConfig(models.PlatformTypeVsphere, &cfg, &cluster) Expect(err).To(BeNil()) Expect(cfg.Platform.Vsphere).ToNot(BeNil()) - Expect(cfg.Platform.Vsphere.DeprecatedAPIVIP).To(Equal(cluster.Cluster.APIVip)) - Expect(cfg.Platform.Vsphere.DeprecatedIngressVIP).To(Equal(cluster.Cluster.IngressVip)) + Expect(cfg.Platform.Vsphere.APIVIPs[0]).To(Equal(string(cluster.Cluster.APIVips[0].IP))) + Expect(cfg.Platform.Vsphere.IngressVIPs[0]).To(Equal(string(cluster.Cluster.IngressVips[0].IP))) Expect(cfg.Platform.Vsphere.DeprecatedVCenter).To(Equal(vsphere.PhVcenter)) Expect(cfg.Platform.Vsphere.VCenters).To(BeNil()) }) @@ -321,8 +325,8 @@ var _ = Describe("Test AddPlatformToInstallConfig", func() { err := providerRegistry.AddPlatformToInstallConfig(models.PlatformTypeVsphere, &cfg, &cluster) Expect(err).To(BeNil()) Expect(cfg.Platform.Vsphere).ToNot(BeNil()) - Expect(cfg.Platform.Vsphere.DeprecatedAPIVIP).To(Equal(cluster.Cluster.APIVip)) - Expect(cfg.Platform.Vsphere.DeprecatedIngressVIP).To(Equal(cluster.Cluster.IngressVip)) + Expect(cfg.Platform.Vsphere.APIVIPs[0]).To(Equal(string(cluster.Cluster.APIVips[0].IP))) + Expect(cfg.Platform.Vsphere.IngressVIPs[0]).To(Equal(string(cluster.Cluster.IngressVips[0].IP))) Expect(cfg.Platform.Vsphere.DeprecatedVCenter).To(Equal(vsphere.PhVcenter)) Expect(cfg.Platform.Vsphere.DeprecatedCluster).To(Equal(vsphere.PhCluster)) Expect(cfg.Platform.Vsphere.DeprecatedNetwork).To(Equal(vsphere.PhNetwork)) @@ -557,10 +561,8 @@ func createClusterFromHosts(hosts []*models.Host) common.Cluster { Cluster: models.Cluster{ Name: "cluster", ID: &clusterID, - APIVip: "192.168.10.10", APIVips: []*models.APIVip{{IP: "192.168.10.10"}}, Hosts: hosts, - IngressVip: "192.168.10.11", IngressVips: []*models.IngressVip{{IP: "192.168.10.11"}}, OpenshiftVersion: "4.7", CPUArchitecture: models.ClusterCPUArchitectureX8664, diff --git a/internal/provider/vsphere/installConfig.go b/internal/provider/vsphere/installConfig.go index 4591088e49..58a15bc606 100644 --- a/internal/provider/vsphere/installConfig.go +++ b/internal/provider/vsphere/installConfig.go @@ -68,6 +68,8 @@ func (p vsphereProvider) AddPlatformToInstallConfig(cfg *installcfg.InstallerCon vsPlatform.APIVIPs = network.GetApiVips(cluster) vsPlatform.IngressVIPs = network.GetIngressVips(cluster) } else { + vsPlatform.APIVIPs = []string{network.GetApiVips(cluster)[0]} + vsPlatform.IngressVIPs = []string{network.GetIngressVips(cluster)[0]} vsPlatform.DeprecatedAPIVIP = network.GetApiVipById(cluster, 0) vsPlatform.DeprecatedIngressVIP = network.GetIngressVipById(cluster, 0) } diff --git a/subsystem/agent_based_installer_client_test.go b/subsystem/agent_based_installer_client_test.go index c2933bb2f8..f5f9d75f0f 100644 --- a/subsystem/agent_based_installer_client_test.go +++ b/subsystem/agent_based_installer_client_test.go @@ -24,9 +24,7 @@ var _ = Describe("RegisterClusterAndInfraEnv", func() { "../docs/hive-integration/crds/agentClusterInstall.yaml", "../docs/hive-integration/crds/clusterImageSet.yaml", "") Expect(registerClusterErr).NotTo(HaveOccurred()) - Expect(modelCluster.APIVip).To(Equal("1.2.3.8")) Expect(network.GetApiVipById(&common.Cluster{Cluster: *modelCluster}, 0)).To(Equal("1.2.3.8")) - Expect(modelCluster.IngressVip).To(Equal("1.2.3.9")) Expect(network.GetIngressVipById(&common.Cluster{Cluster: *modelCluster}, 0)).To(Equal("1.2.3.9")) Expect(modelCluster.OpenshiftVersion).To(ContainSubstring(snoVersion)) Expect(modelCluster.CPUArchitecture).To(Equal("x86_64")) @@ -48,9 +46,7 @@ var _ = Describe("RegisterClusterAndInfraEnv", func() { "../docs/hive-integration/crds/agentClusterInstall-with-installconfig-overrides.yaml", "../docs/hive-integration/crds/clusterImageSet.yaml", "") Expect(registerClusterErr).NotTo(HaveOccurred()) - Expect(modelCluster.APIVip).To(Equal("1.2.3.8")) Expect(network.GetApiVipById(&common.Cluster{Cluster: *modelCluster}, 0)).To(Equal("1.2.3.8")) - Expect(modelCluster.IngressVip).To(Equal("1.2.3.9")) Expect(network.GetIngressVipById(&common.Cluster{Cluster: *modelCluster}, 0)).To(Equal("1.2.3.9")) Expect(modelCluster.OpenshiftVersion).To(ContainSubstring(snoVersion)) Expect(modelCluster.CPUArchitecture).To(Equal("x86_64")) diff --git a/subsystem/cluster_test.go b/subsystem/cluster_test.go index 9fc6699096..e8f6427bc0 100644 --- a/subsystem/cluster_test.go +++ b/subsystem/cluster_test.go @@ -939,8 +939,6 @@ var _ = Describe("cluster install - DHCP", func() { generateDhcpStepReply(reply.Payload.Hosts[0], "1.2.3.102", "1.2.3.103", true) _, err = userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String("1.2.3.100"), - IngressVip: swag.String("1.2.3.101"), APIVips: []*models.APIVip{{IP: "1.2.3.100", ClusterID: clusterID}}, IngressVips: []*models.IngressVip{{IP: "1.2.3.101", ClusterID: clusterID}}, }, @@ -969,8 +967,6 @@ var _ = Describe("cluster install - DHCP", func() { IgnoreStateInfo) _, err = userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: swag.String("1.2.3.100"), - IngressVip: swag.String("1.2.3.101"), APIVips: []*models.APIVip{{IP: "1.2.3.100", ClusterID: clusterID}}, IngressVips: []*models.IngressVip{{IP: "1.2.3.101", ClusterID: clusterID}}, }, @@ -983,9 +979,7 @@ var _ = Describe("cluster install - DHCP", func() { Expect(err).ToNot(HaveOccurred()) c := getReply.Payload Expect(swag.StringValue(c.Status)).To(Equal(models.ClusterStatusReady)) - Expect(c.APIVip).To(Equal("1.2.3.102")) Expect(string(c.APIVips[0].IP)).To(Equal("1.2.3.102")) - Expect(c.IngressVip).To(Equal("1.2.3.103")) Expect(string(c.IngressVips[0].IP)).To(Equal("1.2.3.103")) }) }) @@ -1490,8 +1484,6 @@ var _ = Describe("cluster install", func() { It("report usage new dual-stack cluster", func() { registerClusterReply, err := userBMClient.Installer.V2RegisterCluster(ctx, &installer.V2RegisterClusterParams{ NewClusterParams: &models.ClusterCreateParams{ - APIVip: "1.2.3.8", - IngressVip: "1.2.3.9", APIVips: []*models.APIVip{{IP: "1.2.3.8"}}, IngressVips: []*models.IngressVip{{IP: "1.2.3.9"}}, BaseDNSDomain: "example.com", @@ -1532,9 +1524,7 @@ var _ = Describe("cluster install", func() { It("report usage new dual-stack cluster with dual-stack VIPs", func() { registerClusterReply, err := userBMClient.Installer.V2RegisterCluster(ctx, &installer.V2RegisterClusterParams{ NewClusterParams: &models.ClusterCreateParams{ - APIVip: "1.2.3.8", APIVips: []*models.APIVip{{IP: "1.2.3.8"}, {IP: "1001:db8::8"}}, - IngressVip: "1.2.3.9", IngressVips: []*models.IngressVip{{IP: "1.2.3.9"}, {IP: "1001:db8::9"}}, BaseDNSDomain: "example.com", ClusterNetworks: []*models.ClusterNetwork{ @@ -1604,8 +1594,6 @@ var _ = Describe("cluster install", func() { _ = registerNode(ctx, *infraEnvID, "test-host", defaultCIDRv4) c, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: &apiVip, - IngressVip: &ingressVip, APIVips: []*models.APIVip{{IP: models.IP(apiVip), ClusterID: clusterID}}, IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip), ClusterID: clusterID}}, VipDhcpAllocation: swag.Bool(false), @@ -1614,8 +1602,8 @@ var _ = Describe("cluster install", func() { }) Expect(err).NotTo(HaveOccurred()) Expect(len(c.GetPayload().Hosts)).Should(Equal(1)) - Expect(c.Payload.APIVip).Should(Equal(apiVip)) Expect(string(c.Payload.APIVips[0].IP)).Should(Equal(apiVip)) + Expect(string(c.Payload.IngressVips[0].IP)).To(Equal("1.2.3.100")) Expect(string(c.Payload.MachineNetworks[0].Cidr)).Should(Equal("1.2.3.0/24")) }) @@ -1626,8 +1614,6 @@ var _ = Describe("cluster install", func() { host := registerNode(ctx, *infraEnvID, "test-host", defaultCIDRv4) c, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: &apiVip, - IngressVip: &ingressVip, APIVips: []*models.APIVip{{IP: models.IP(apiVip), ClusterID: clusterID}}, IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip), ClusterID: clusterID}}, VipDhcpAllocation: swag.Bool(false), @@ -1635,8 +1621,8 @@ var _ = Describe("cluster install", func() { ClusterID: clusterID, }) Expect(err).NotTo(HaveOccurred()) - Expect(c.Payload.APIVip).Should(Equal(apiVip)) Expect(string(c.Payload.APIVips[0].IP)).Should(Equal(apiVip)) + Expect(string(c.Payload.IngressVips[0].IP)).To(Equal(ingressVip)) Expect(waitForMachineNetworkCIDR( ctx, clusterID, "1.2.3.0/24", defaultWaitForMachineNetworkCIDRTimeout)).ShouldNot(HaveOccurred()) _, err1 := userBMClient.Installer.V2DeregisterHost(ctx, &installer.V2DeregisterHostParams{ @@ -1658,9 +1644,7 @@ var _ = Describe("cluster install", func() { }) Expect(err).NotTo(HaveOccurred()) Expect(len(c.GetPayload().Hosts)).Should(Equal(0)) - Expect(c.Payload.APIVip).Should(Equal("")) Expect(len(c.Payload.APIVips)).Should(Equal(0)) - Expect(c.Payload.IngressVip).Should(Equal("")) Expect(len(c.Payload.IngressVips)).Should(Equal(0)) Expect(c.Payload.MachineNetworks).Should(BeEmpty()) _ = registerNode(ctx, *infraEnvID, "test-host", defaultCIDRv4) @@ -1676,7 +1660,6 @@ var _ = Describe("cluster install", func() { apiVip := "1.2.3.8" _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: &apiVip, APIVips: []*models.APIVip{{IP: models.IP(apiVip), ClusterID: clusterID}}, VipDhcpAllocation: swag.Bool(false), }, @@ -2943,8 +2926,6 @@ spec: _, err = userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: &apiVip, - IngressVip: &ingressVip, APIVips: []*models.APIVip{{IP: models.IP(apiVip), ClusterID: clusterID}}, IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip), ClusterID: clusterID}}, }, @@ -3035,8 +3016,6 @@ spec: _, err = userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ VipDhcpAllocation: swag.Bool(false), - APIVip: &apiVip, - IngressVip: &ingressVip, APIVips: []*models.APIVip{{IP: models.IP(apiVip), ClusterID: clusterID}}, IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip), ClusterID: clusterID}}, }, @@ -3048,9 +3027,8 @@ spec: ClusterID: clusterID, }) Expect(getErr).ToNot(HaveOccurred()) - - Expect(clusterReply.Payload.APIVip).To(Equal(apiVip)) Expect(string(clusterReply.Payload.APIVips[0].IP)).To(Equal(apiVip)) + Expect(string(clusterReply.Payload.IngressVips[0].IP)).To(Equal(ingressVip)) Expect(string(clusterReply.Payload.MachineNetworks[0].Cidr)).To(Equal("1.2.3.0/24")) Expect(len(clusterReply.Payload.HostNetworks)).To(Equal(1)) Expect(clusterReply.Payload.HostNetworks[0].Cidr).To(Equal("1.2.3.0/24")) @@ -3189,8 +3167,6 @@ spec: _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ VipDhcpAllocation: swag.Bool(false), - APIVip: &apiVip, - IngressVip: &ingressVip, APIVips: []*models.APIVip{{IP: models.IP(apiVip), ClusterID: clusterID}}, IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip), ClusterID: clusterID}}, }, @@ -3285,8 +3261,6 @@ spec: _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ VipDhcpAllocation: swag.Bool(false), - APIVip: &apiVip, - IngressVip: &ingressVip, APIVips: []*models.APIVip{{IP: models.IP(apiVip), ClusterID: clusterID}}, IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip), ClusterID: clusterID}}, }, @@ -3865,171 +3839,6 @@ var _ = Describe("Multiple-VIPs Support", func() { Context("V2RegisterCluster", func() { - Context("API and Ingress VIPs Backwards Compatibility", func() { - - It("API VIP and Ingress VIP populated in APIVips and IngressVips", func() { - reply, err := userBMClient.Installer.V2RegisterCluster(ctx, &installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - BaseDNSDomain: "example.com", - ClusterNetworks: []*models.ClusterNetwork{{Cidr: models.Subnet(clusterCIDR), HostPrefix: 23}}, - ServiceNetworks: []*models.ServiceNetwork{{Cidr: models.Subnet(serviceCIDR)}}, - Name: swag.String("test-cluster"), - OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), - PullSecret: swag.String(pullSecret), - SSHPublicKey: sshPublicKey, - APIVip: apiVip, - IngressVip: ingressVip, - APIVips: []*models.APIVip{{IP: models.IP(apiVip)}}, - IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip)}}, - }, - }) - Expect(err).NotTo(HaveOccurred()) - Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2RegisterClusterCreated())) - - cluster = &common.Cluster{Cluster: *reply.Payload} - - Expect(cluster.APIVip).To(Equal(apiVip)) - Expect(network.GetApiVipById(cluster, 0)).To(Equal(apiVip)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) - Expect(network.GetIngressVipById(cluster, 0)).To(Equal(ingressVip)) - }) - - It("API VIP match APIVips first element", func() { - apiVips := []*models.APIVip{{IP: models.IP(apiVip)}} - - reply, err := userBMClient.Installer.V2RegisterCluster(ctx, &installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - BaseDNSDomain: "example.com", - ClusterNetworks: []*models.ClusterNetwork{{Cidr: models.Subnet(clusterCIDR), HostPrefix: 23}}, - ServiceNetworks: []*models.ServiceNetwork{{Cidr: models.Subnet(serviceCIDR)}}, - Name: swag.String("test-cluster"), - OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), - PullSecret: swag.String(pullSecret), - SSHPublicKey: sshPublicKey, - APIVip: apiVip, - APIVips: apiVips, - IngressVip: ingressVip, - }, - }) - Expect(err).NotTo(HaveOccurred()) - Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2RegisterClusterCreated())) - - cluster = &common.Cluster{Cluster: *reply.Payload} - setClusterIdForApiVips(apiVips, cluster.ID) - - Expect(cluster.APIVip).To(Equal(apiVip)) - Expect(cluster.APIVips).To(Equal(apiVips)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) - Expect(network.GetIngressVipById(cluster, 0)).To(Equal(ingressVip)) - }) - - It("Ingress VIP match IngressVips first element", func() { - ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}} - - reply, err := userBMClient.Installer.V2RegisterCluster(ctx, &installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - BaseDNSDomain: "example.com", - ClusterNetworks: []*models.ClusterNetwork{{Cidr: models.Subnet(clusterCIDR), HostPrefix: 23}}, - ServiceNetworks: []*models.ServiceNetwork{{Cidr: models.Subnet(serviceCIDR)}}, - Name: swag.String("test-cluster"), - OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), - PullSecret: swag.String(pullSecret), - SSHPublicKey: sshPublicKey, - APIVip: apiVip, - IngressVip: ingressVip, - IngressVips: ingressVips, - }, - }) - Expect(err).NotTo(HaveOccurred()) - Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2RegisterClusterCreated())) - - cluster = &common.Cluster{Cluster: *reply.Payload} - setClusterIdForIngressVips(ingressVips, cluster.ID) - - Expect(cluster.APIVip).To(Equal(apiVip)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) - Expect(cluster.IngressVips).To(Equal(ingressVips)) - }) - - It("API VIP not matching APIVips first element", func() { - apiVips := []*models.APIVip{{IP: models.IP("1.2.3.18")}} - - _, err := userBMClient.Installer.V2RegisterCluster(ctx, &installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - BaseDNSDomain: "example.com", - ClusterNetworks: []*models.ClusterNetwork{{Cidr: models.Subnet(clusterCIDR), HostPrefix: 23}}, - ServiceNetworks: []*models.ServiceNetwork{{Cidr: models.Subnet(serviceCIDR)}}, - Name: swag.String("test-cluster"), - OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), - PullSecret: swag.String(pullSecret), - SSHPublicKey: sshPublicKey, - APIVip: apiVip, - APIVips: apiVips, - IngressVip: ingressVip, - }, - }) - Expect(err).To(BeAssignableToTypeOf(installer.NewV2RegisterClusterBadRequest())) - }) - - It("Ingress VIP not matching IngressVips first element", func() { - ingressVips := []*models.IngressVip{{IP: models.IP("1.2.3.18")}} - - _, err := userBMClient.Installer.V2RegisterCluster(ctx, &installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - BaseDNSDomain: "example.com", - ClusterNetworks: []*models.ClusterNetwork{{Cidr: models.Subnet(clusterCIDR), HostPrefix: 23}}, - ServiceNetworks: []*models.ServiceNetwork{{Cidr: models.Subnet(serviceCIDR)}}, - Name: swag.String("test-cluster"), - OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), - PullSecret: swag.String(pullSecret), - SSHPublicKey: sshPublicKey, - APIVip: apiVip, - IngressVip: ingressVip, - IngressVips: ingressVips, - }, - }) - Expect(err).To(BeAssignableToTypeOf(installer.NewV2RegisterClusterBadRequest())) - }) - - It("Reject APIVips if no APIVip was provided", func() { - apiVips := []*models.APIVip{{IP: models.IP("1.2.3.18")}} - - _, err := userBMClient.Installer.V2RegisterCluster(ctx, &installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - BaseDNSDomain: "example.com", - ClusterNetworks: []*models.ClusterNetwork{{Cidr: models.Subnet(clusterCIDR), HostPrefix: 23}}, - ServiceNetworks: []*models.ServiceNetwork{{Cidr: models.Subnet(serviceCIDR)}}, - Name: swag.String("test-cluster"), - OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), - PullSecret: swag.String(pullSecret), - SSHPublicKey: sshPublicKey, - APIVips: apiVips, - IngressVip: ingressVip, - }, - }) - Expect(err).To(BeAssignableToTypeOf(installer.NewV2RegisterClusterBadRequest())) - }) - - It("Reject IngressVips if no IngressVip was provided", func() { - ingressVips := []*models.IngressVip{{IP: models.IP("1.2.3.18")}} - - _, err := userBMClient.Installer.V2RegisterCluster(ctx, &installer.V2RegisterClusterParams{ - NewClusterParams: &models.ClusterCreateParams{ - BaseDNSDomain: "example.com", - ClusterNetworks: []*models.ClusterNetwork{{Cidr: models.Subnet(clusterCIDR), HostPrefix: 23}}, - ServiceNetworks: []*models.ServiceNetwork{{Cidr: models.Subnet(serviceCIDR)}}, - Name: swag.String("test-cluster"), - OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), - PullSecret: swag.String(pullSecret), - SSHPublicKey: sshPublicKey, - APIVip: apiVip, - IngressVips: ingressVips, - }, - }) - Expect(err).To(BeAssignableToTypeOf(installer.NewV2RegisterClusterBadRequest())) - }) - }) - It("Two APIVips and Two IngressVips - both IPv4 - negative", func() { apiVips := []*models.APIVip{{IP: models.IP(apiVip)}, {IP: models.IP("8.8.8.8")}} ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}, {IP: models.IP("8.8.8.2")}} @@ -4043,9 +3852,7 @@ var _ = Describe("Multiple-VIPs Support", func() { OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), PullSecret: swag.String(pullSecret), SSHPublicKey: sshPublicKey, - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -4065,9 +3872,7 @@ var _ = Describe("Multiple-VIPs Support", func() { OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), PullSecret: swag.String(pullSecret), SSHPublicKey: sshPublicKey, - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -4078,9 +3883,7 @@ var _ = Describe("Multiple-VIPs Support", func() { setClusterIdForApiVips(apiVips, cluster.ID) setClusterIdForIngressVips(ingressVips, cluster.ID) - Expect(cluster.APIVip).To(Equal(apiVip)) Expect(cluster.APIVips).To(Equal(apiVips)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) Expect(cluster.IngressVips).To(Equal(ingressVips)) }) @@ -4097,9 +3900,7 @@ var _ = Describe("Multiple-VIPs Support", func() { OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), PullSecret: swag.String(pullSecret), SSHPublicKey: sshPublicKey, - APIVip: apiVipv6, APIVips: apiVips, - IngressVip: ingressVipv6, IngressVips: ingressVips, }, }) @@ -4119,9 +3920,7 @@ var _ = Describe("Multiple-VIPs Support", func() { OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), PullSecret: swag.String(pullSecret), SSHPublicKey: sshPublicKey, - APIVip: apiVipv6, APIVips: apiVips, - IngressVip: ingressVipv6, IngressVips: ingressVips, }, }) @@ -4141,9 +3940,7 @@ var _ = Describe("Multiple-VIPs Support", func() { OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), PullSecret: swag.String(pullSecret), SSHPublicKey: sshPublicKey, - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -4165,9 +3962,7 @@ var _ = Describe("Multiple-VIPs Support", func() { OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), PullSecret: swag.String(pullSecret), SSHPublicKey: sshPublicKey, - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -4188,9 +3983,7 @@ var _ = Describe("Multiple-VIPs Support", func() { OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), PullSecret: swag.String(pullSecret), SSHPublicKey: sshPublicKey, - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -4210,9 +4003,7 @@ var _ = Describe("Multiple-VIPs Support", func() { OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), PullSecret: swag.String(pullSecret), SSHPublicKey: sshPublicKey, - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -4232,9 +4023,7 @@ var _ = Describe("Multiple-VIPs Support", func() { OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), PullSecret: swag.String(pullSecret), SSHPublicKey: sshPublicKey, - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -4254,9 +4043,7 @@ var _ = Describe("Multiple-VIPs Support", func() { OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), PullSecret: swag.String(pullSecret), SSHPublicKey: sshPublicKey, - APIVip: apiVip, APIVips: apiVips, - IngressVip: ingressVip, IngressVips: ingressVips, }, }) @@ -4276,9 +4063,7 @@ var _ = Describe("Multiple-VIPs Support", func() { OpenshiftVersion: swag.String(dualstackVipsOpenShiftVersion), PullSecret: swag.String(pullSecret), SSHPublicKey: sshPublicKey, - APIVip: apiVip, APIVips: apiVips, - IngressVip: apiVip, IngressVips: ingressVips, }, }) @@ -4314,148 +4099,6 @@ var _ = Describe("Multiple-VIPs Support", func() { clearDB() }) - Context("API and Ingress VIPs Backwards Compatibility", func() { - - It("API VIP and Ingress VIP populated in APIVips and ingressVips", func() { - apiVip = "1.2.3.8" - ingressVip = "1.2.3.9" - reply, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - VipDhcpAllocation: swag.Bool(false), - APIVip: &apiVip, - IngressVip: &ingressVip, - }, - ClusterID: *cluster.ID, - }) - Expect(err).NotTo(HaveOccurred()) - Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) - - cluster = &common.Cluster{Cluster: *reply.Payload} - - Expect(cluster.APIVip).To(Equal(apiVip)) - Expect(network.GetApiVipById(cluster, 0)).To(Equal(apiVip)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) - Expect(network.GetIngressVipById(cluster, 0)).To(Equal(ingressVip)) - }) - - It("API VIP match APIVips first element", func() { - - apiVip = "1.2.3.8" - ingressVip = "1.2.3.9" - apiVips := []*models.APIVip{{IP: models.IP(apiVip)}} - - ingressVip = "1.2.3.9" - reply, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - VipDhcpAllocation: swag.Bool(false), - APIVip: &apiVip, - APIVips: apiVips, - IngressVip: &ingressVip, - }, - ClusterID: *cluster.ID, - }) - Expect(err).NotTo(HaveOccurred()) - Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) - - cluster = &common.Cluster{Cluster: *reply.Payload} - setClusterIdForApiVips(apiVips, cluster.ID) - - Expect(cluster.APIVip).To(Equal(apiVip)) - Expect(cluster.APIVips).To(Equal(apiVips)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) - Expect(network.GetIngressVipById(cluster, 0)).To(Equal(ingressVip)) - }) - - It("Ingress VIP match ingressVips first element", func() { - ingressVips := []*models.IngressVip{{IP: models.IP(ingressVip)}} - - reply, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - VipDhcpAllocation: swag.Bool(false), - APIVip: &apiVip, - IngressVip: &ingressVip, - IngressVips: ingressVips, - }, - ClusterID: *cluster.ID, - }) - Expect(err).NotTo(HaveOccurred()) - Expect(reply).Should(BeAssignableToTypeOf(installer.NewV2UpdateClusterCreated())) - - cluster = &common.Cluster{Cluster: *reply.Payload} - setClusterIdForIngressVips(ingressVips, cluster.ID) - - Expect(cluster.APIVip).To(Equal(apiVip)) - Expect(network.GetApiVipById(cluster, 0)).To(Equal(apiVip)) - Expect(cluster.IngressVip).To(Equal(ingressVip)) - Expect(cluster.IngressVips).To(Equal(ingressVips)) - }) - - It("API VIP not matching APIVips first element", func() { - apiVip = "1.2.3.100" - ingressVip = "1.2.3.101" - apiVips := []*models.APIVip{{IP: models.IP("1.2.3.111")}} - - _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - VipDhcpAllocation: swag.Bool(false), - APIVip: swag.String(apiVip), - APIVips: apiVips, - IngressVip: swag.String(ingressVip), - }, - ClusterID: *cluster.ID, - }) - Expect(err).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterBadRequest())) - }) - - It("Ingress VIP not matching ingressVips first element", func() { - apiVip = "1.2.3.100" - ingressVip = "1.2.3.101" - ingressVips := []*models.IngressVip{{IP: models.IP("1.2.3.111")}} - - _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - VipDhcpAllocation: swag.Bool(false), - APIVip: swag.String(apiVip), - IngressVip: swag.String(ingressVip), - IngressVips: ingressVips, - }, - ClusterID: *cluster.ID, - }) - Expect(err).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterBadRequest())) - }) - - It("Reject APIVips if no APIVip was provided", func() { - ingressVip = "1.2.3.101" - apiVips := []*models.APIVip{{IP: models.IP("1.2.3.111")}} - - _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - VipDhcpAllocation: swag.Bool(false), - APIVips: apiVips, - IngressVip: swag.String(ingressVip), - }, - ClusterID: *cluster.ID, - }) - Expect(err).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterBadRequest())) - }) - - It("Reject ingressVips if no ingressVip was provided", func() { - apiVip = "1.2.3.100" - ingressVips := []*models.IngressVip{{IP: models.IP("1.2.3.111")}} - - _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ - ClusterUpdateParams: &models.V2ClusterUpdateParams{ - VipDhcpAllocation: swag.Bool(false), - APIVip: swag.String(apiVip), - IngressVips: ingressVips, - }, - ClusterID: *cluster.ID, - }) - Expect(err).To(BeAssignableToTypeOf(installer.NewV2UpdateClusterBadRequest())) - }) - - }) - It("Two APIVips and Two ingressVips - IPv6 first and IPv4 second - negative", func() { apiVip = "2001:db8::1" ingressVip = "2001:db8::2" @@ -4465,9 +4108,7 @@ var _ = Describe("Multiple-VIPs Support", func() { _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ VipDhcpAllocation: swag.Bool(false), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(ingressVip), IngressVips: ingressVips, }, ClusterID: *cluster.ID, @@ -4484,9 +4125,7 @@ var _ = Describe("Multiple-VIPs Support", func() { _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ VipDhcpAllocation: swag.Bool(false), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(ingressVip), IngressVips: ingressVips, }, ClusterID: *cluster.ID, @@ -4503,9 +4142,7 @@ var _ = Describe("Multiple-VIPs Support", func() { _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ VipDhcpAllocation: swag.Bool(false), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(ingressVip), IngressVips: ingressVips, }, ClusterID: *cluster.ID, @@ -4522,9 +4159,7 @@ var _ = Describe("Multiple-VIPs Support", func() { _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ VipDhcpAllocation: swag.Bool(false), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(ingressVip), IngressVips: ingressVips, }, ClusterID: *cluster.ID, @@ -4541,9 +4176,7 @@ var _ = Describe("Multiple-VIPs Support", func() { _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ VipDhcpAllocation: swag.Bool(false), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(ingressVip), IngressVips: ingressVips, }, ClusterID: *cluster.ID, @@ -4559,9 +4192,7 @@ var _ = Describe("Multiple-VIPs Support", func() { _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ VipDhcpAllocation: swag.Bool(false), - APIVip: swag.String(apiVip), APIVips: apiVips, - IngressVip: swag.String(apiVip), IngressVips: ingressVips, }, ClusterID: *cluster.ID, @@ -4744,23 +4375,19 @@ func registerHostsAndSetRoles(clusterID, infraenvID strfmt.UUID, numHosts int, c } if !swag.BoolValue(cluster.UserManagedNetworking) { - apiVip := "" - ingressVip := "" _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ VipDhcpAllocation: swag.Bool(false), - APIVip: &apiVip, - IngressVip: &ingressVip, + APIVips: []*models.APIVip{}, + IngressVips: []*models.IngressVip{}, }, ClusterID: clusterID, }) Expect(err).NotTo(HaveOccurred()) - apiVip = "1.2.3.8" - ingressVip = "1.2.3.9" + apiVip := "1.2.3.8" + ingressVip := "1.2.3.9" _, err = userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: &apiVip, - IngressVip: &ingressVip, APIVips: []*models.APIVip{{IP: models.IP(apiVip), ClusterID: clusterID}}, IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip), ClusterID: clusterID}}, }, @@ -4809,23 +4436,19 @@ func registerHostsAndSetRolesTang(clusterID, infraenvID strfmt.UUID, numHosts in generateTangPostStepReply(ctx, tangValidated, hosts...) } - apiVip := "" - ingressVip := "" _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ VipDhcpAllocation: swag.Bool(false), - APIVip: &apiVip, - IngressVip: &ingressVip, + APIVips: []*models.APIVip{}, + IngressVips: []*models.IngressVip{}, }, ClusterID: clusterID, }) Expect(err).NotTo(HaveOccurred()) - apiVip = "1.2.3.8" - ingressVip = "1.2.3.9" + apiVip := "1.2.3.8" + ingressVip := "1.2.3.9" _, err = userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ - APIVip: &apiVip, - IngressVip: &ingressVip, APIVips: []*models.APIVip{{IP: models.IP(apiVip), ClusterID: clusterID}}, IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip), ClusterID: clusterID}}, }, diff --git a/subsystem/ipv6_test.go b/subsystem/ipv6_test.go index f10cf3a206..b8142c8661 100644 --- a/subsystem/ipv6_test.go +++ b/subsystem/ipv6_test.go @@ -124,8 +124,6 @@ func registerHostsAndSetRolesV6(clusterID, infraEnvID strfmt.UUID, numHosts int) _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ VipDhcpAllocation: swag.Bool(false), - APIVip: &apiVip, - IngressVip: &ingressVip, APIVips: []*models.APIVip{{IP: models.IP(apiVip), ClusterID: clusterID}}, IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip), ClusterID: clusterID}}, }, diff --git a/subsystem/kubeapi_test.go b/subsystem/kubeapi_test.go index 87b1527f54..8f7502ab24 100644 --- a/subsystem/kubeapi_test.go +++ b/subsystem/kubeapi_test.go @@ -5010,7 +5010,7 @@ spec: checkAgentClusterInstallCondition(ctx, installkey, hiveext.ClusterSpecSyncedCondition, hiveext.ClusterInputErrorReason) condition := controllers.FindStatusCondition(getAgentClusterInstallCRD(ctx, kubeClient, installkey).Status.Conditions, hiveext.ClusterSpecSyncedCondition) - Expect(condition.Message).To(ContainSubstring("API VIP cannot be set with User Managed Networking")) + Expect(condition.Message).To(ContainSubstring("API VIPs cannot be set with User Managed Networking")) }) It("Fail Update ACI with UserManagedNetworking true when VIPs were already set", func() { diff --git a/subsystem/utils_test.go b/subsystem/utils_test.go index eba2a1f6af..bc22900fe3 100644 --- a/subsystem/utils_test.go +++ b/subsystem/utils_test.go @@ -666,8 +666,8 @@ func updateVipParams(ctx context.Context, clusterID strfmt.UUID) { _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ VipDhcpAllocation: swag.Bool(false), - APIVip: &apiVip, - IngressVip: &ingressVip, + APIVips: []*models.APIVip{{IP: models.IP(apiVip), ClusterID: clusterID}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip), ClusterID: clusterID}}, }, ClusterID: clusterID, }) @@ -680,8 +680,8 @@ func v2UpdateVipParams(ctx context.Context, clusterID strfmt.UUID) { _, err := userBMClient.Installer.V2UpdateCluster(ctx, &installer.V2UpdateClusterParams{ ClusterUpdateParams: &models.V2ClusterUpdateParams{ VipDhcpAllocation: swag.Bool(false), - APIVip: &apiVip, - IngressVip: &ingressVip, + APIVips: []*models.APIVip{{IP: models.IP(apiVip), ClusterID: clusterID}}, + IngressVips: []*models.IngressVip{{IP: models.IP(ingressVip), ClusterID: clusterID}}, }, ClusterID: clusterID, }) diff --git a/vendor/github.com/openshift/assisted-service/models/cluster.go b/vendor/github.com/openshift/assisted-service/models/cluster.go index f996313bb3..ed4f66367b 100644 --- a/vendor/github.com/openshift/assisted-service/models/cluster.go +++ b/vendor/github.com/openshift/assisted-service/models/cluster.go @@ -30,10 +30,6 @@ type Cluster struct { // Format: uuid AmsSubscriptionID strfmt.UUID `json:"ams_subscription_id,omitempty"` - // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ - APIVip string `json:"api_vip,omitempty"` - // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -147,10 +143,6 @@ type Cluster struct { // reflect the actual cluster they represent Imported *bool `json:"imported,omitempty"` - // (DEPRECATED) The virtual IP used for cluster ingress traffic. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ - IngressVip string `json:"ingress_vip,omitempty"` - // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips" gorm:"foreignkey:ClusterID;references:ID"` @@ -289,10 +281,6 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateAPIVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -361,10 +349,6 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateIngressVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -459,18 +443,6 @@ func (m *Cluster) validateAmsSubscriptionID(formats strfmt.Registry) error { return nil } -func (m *Cluster) validateAPIVip(formats strfmt.Registry) error { - if swag.IsZero(m.APIVip) { // not required - return nil - } - - if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { - return err - } - - return nil -} - func (m *Cluster) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -863,18 +835,6 @@ func (m *Cluster) validateImageInfo(formats strfmt.Registry) error { return nil } -func (m *Cluster) validateIngressVip(formats strfmt.Registry) error { - if swag.IsZero(m.IngressVip) { // not required - return nil - } - - if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { - return err - } - - return nil -} - func (m *Cluster) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go b/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go index 432ab0ed9a..3eeade9fcd 100644 --- a/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go +++ b/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go @@ -24,10 +24,6 @@ type ClusterCreateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` - // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ - APIVip string `json:"api_vip,omitempty"` - // The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. APIVips []*APIVip `json:"api_vips"` @@ -76,10 +72,6 @@ type ClusterCreateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` - // (DEPRECATED) The virtual IP used for cluster ingress traffic. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ - IngressVip string `json:"ingress_vip,omitempty"` - // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -143,10 +135,6 @@ type ClusterCreateParams struct { func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { var res []error - if err := m.validateAPIVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -183,10 +171,6 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateIngressVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -233,18 +217,6 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { return nil } -func (m *ClusterCreateParams) validateAPIVip(formats strfmt.Registry) error { - if swag.IsZero(m.APIVip) { // not required - return nil - } - - if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { - return err - } - - return nil -} - func (m *ClusterCreateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -507,18 +479,6 @@ func (m *ClusterCreateParams) validateIgnitionEndpoint(formats strfmt.Registry) return nil } -func (m *ClusterCreateParams) validateIngressVip(formats strfmt.Registry) error { - if swag.IsZero(m.IngressVip) { // not required - return nil - } - - if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { - return err - } - - return nil -} - func (m *ClusterCreateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go b/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go index 27bc059850..cf3edc1efc 100644 --- a/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go +++ b/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go @@ -24,10 +24,6 @@ type V2ClusterUpdateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` - // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ - APIVip *string `json:"api_vip,omitempty"` - // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -69,10 +65,6 @@ type V2ClusterUpdateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` - // (DEPRECATED) The virtual IP used for cluster ingress traffic. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ - IngressVip *string `json:"ingress_vip,omitempty"` - // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -131,10 +123,6 @@ type V2ClusterUpdateParams struct { func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { var res []error - if err := m.validateAPIVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -163,10 +151,6 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateIngressVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -209,18 +193,6 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { return nil } -func (m *V2ClusterUpdateParams) validateAPIVip(formats strfmt.Registry) error { - if swag.IsZero(m.APIVip) { // not required - return nil - } - - if err := validate.Pattern("api_vip", "body", *m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { - return err - } - - return nil -} - func (m *V2ClusterUpdateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -387,18 +359,6 @@ func (m *V2ClusterUpdateParams) validateIgnitionEndpoint(formats strfmt.Registry return nil } -func (m *V2ClusterUpdateParams) validateIngressVip(formats strfmt.Registry) error { - if swag.IsZero(m.IngressVip) { // not required - return nil - } - - if err := validate.Pattern("ingress_vip", "body", *m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { - return err - } - - return nil -} - func (m *V2ClusterUpdateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil From a608123d686af492d19b8fddf9837789632a4fa3 Mon Sep 17 00:00:00 2001 From: Nir Magnezi Date: Wed, 11 Oct 2023 15:19:45 +0300 Subject: [PATCH 4/9] MGMT-14810: Regenerate --- .../assisted-service/models/cluster.go | 40 ------------------- .../models/cluster_create_params.go | 40 ------------------- .../models/v2_cluster_update_params.go | 40 ------------------- .../assisted-service/models/cluster.go | 40 ------------------- .../models/cluster_create_params.go | 40 ------------------- .../models/v2_cluster_update_params.go | 40 ------------------- 6 files changed, 240 deletions(-) diff --git a/api/vendor/github.com/openshift/assisted-service/models/cluster.go b/api/vendor/github.com/openshift/assisted-service/models/cluster.go index f996313bb3..ed4f66367b 100644 --- a/api/vendor/github.com/openshift/assisted-service/models/cluster.go +++ b/api/vendor/github.com/openshift/assisted-service/models/cluster.go @@ -30,10 +30,6 @@ type Cluster struct { // Format: uuid AmsSubscriptionID strfmt.UUID `json:"ams_subscription_id,omitempty"` - // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ - APIVip string `json:"api_vip,omitempty"` - // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -147,10 +143,6 @@ type Cluster struct { // reflect the actual cluster they represent Imported *bool `json:"imported,omitempty"` - // (DEPRECATED) The virtual IP used for cluster ingress traffic. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ - IngressVip string `json:"ingress_vip,omitempty"` - // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips" gorm:"foreignkey:ClusterID;references:ID"` @@ -289,10 +281,6 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateAPIVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -361,10 +349,6 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateIngressVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -459,18 +443,6 @@ func (m *Cluster) validateAmsSubscriptionID(formats strfmt.Registry) error { return nil } -func (m *Cluster) validateAPIVip(formats strfmt.Registry) error { - if swag.IsZero(m.APIVip) { // not required - return nil - } - - if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { - return err - } - - return nil -} - func (m *Cluster) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -863,18 +835,6 @@ func (m *Cluster) validateImageInfo(formats strfmt.Registry) error { return nil } -func (m *Cluster) validateIngressVip(formats strfmt.Registry) error { - if swag.IsZero(m.IngressVip) { // not required - return nil - } - - if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { - return err - } - - return nil -} - func (m *Cluster) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/api/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go b/api/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go index 432ab0ed9a..3eeade9fcd 100644 --- a/api/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go +++ b/api/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go @@ -24,10 +24,6 @@ type ClusterCreateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` - // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ - APIVip string `json:"api_vip,omitempty"` - // The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. APIVips []*APIVip `json:"api_vips"` @@ -76,10 +72,6 @@ type ClusterCreateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` - // (DEPRECATED) The virtual IP used for cluster ingress traffic. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ - IngressVip string `json:"ingress_vip,omitempty"` - // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -143,10 +135,6 @@ type ClusterCreateParams struct { func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { var res []error - if err := m.validateAPIVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -183,10 +171,6 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateIngressVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -233,18 +217,6 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { return nil } -func (m *ClusterCreateParams) validateAPIVip(formats strfmt.Registry) error { - if swag.IsZero(m.APIVip) { // not required - return nil - } - - if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { - return err - } - - return nil -} - func (m *ClusterCreateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -507,18 +479,6 @@ func (m *ClusterCreateParams) validateIgnitionEndpoint(formats strfmt.Registry) return nil } -func (m *ClusterCreateParams) validateIngressVip(formats strfmt.Registry) error { - if swag.IsZero(m.IngressVip) { // not required - return nil - } - - if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { - return err - } - - return nil -} - func (m *ClusterCreateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/api/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go b/api/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go index 27bc059850..cf3edc1efc 100644 --- a/api/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go +++ b/api/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go @@ -24,10 +24,6 @@ type V2ClusterUpdateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` - // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ - APIVip *string `json:"api_vip,omitempty"` - // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -69,10 +65,6 @@ type V2ClusterUpdateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` - // (DEPRECATED) The virtual IP used for cluster ingress traffic. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ - IngressVip *string `json:"ingress_vip,omitempty"` - // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -131,10 +123,6 @@ type V2ClusterUpdateParams struct { func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { var res []error - if err := m.validateAPIVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -163,10 +151,6 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateIngressVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -209,18 +193,6 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { return nil } -func (m *V2ClusterUpdateParams) validateAPIVip(formats strfmt.Registry) error { - if swag.IsZero(m.APIVip) { // not required - return nil - } - - if err := validate.Pattern("api_vip", "body", *m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { - return err - } - - return nil -} - func (m *V2ClusterUpdateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -387,18 +359,6 @@ func (m *V2ClusterUpdateParams) validateIgnitionEndpoint(formats strfmt.Registry return nil } -func (m *V2ClusterUpdateParams) validateIngressVip(formats strfmt.Registry) error { - if swag.IsZero(m.IngressVip) { // not required - return nil - } - - if err := validate.Pattern("ingress_vip", "body", *m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { - return err - } - - return nil -} - func (m *V2ClusterUpdateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/client/vendor/github.com/openshift/assisted-service/models/cluster.go b/client/vendor/github.com/openshift/assisted-service/models/cluster.go index f996313bb3..ed4f66367b 100644 --- a/client/vendor/github.com/openshift/assisted-service/models/cluster.go +++ b/client/vendor/github.com/openshift/assisted-service/models/cluster.go @@ -30,10 +30,6 @@ type Cluster struct { // Format: uuid AmsSubscriptionID strfmt.UUID `json:"ams_subscription_id,omitempty"` - // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ - APIVip string `json:"api_vip,omitempty"` - // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -147,10 +143,6 @@ type Cluster struct { // reflect the actual cluster they represent Imported *bool `json:"imported,omitempty"` - // (DEPRECATED) The virtual IP used for cluster ingress traffic. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ - IngressVip string `json:"ingress_vip,omitempty"` - // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips" gorm:"foreignkey:ClusterID;references:ID"` @@ -289,10 +281,6 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateAPIVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -361,10 +349,6 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateIngressVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -459,18 +443,6 @@ func (m *Cluster) validateAmsSubscriptionID(formats strfmt.Registry) error { return nil } -func (m *Cluster) validateAPIVip(formats strfmt.Registry) error { - if swag.IsZero(m.APIVip) { // not required - return nil - } - - if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { - return err - } - - return nil -} - func (m *Cluster) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -863,18 +835,6 @@ func (m *Cluster) validateImageInfo(formats strfmt.Registry) error { return nil } -func (m *Cluster) validateIngressVip(formats strfmt.Registry) error { - if swag.IsZero(m.IngressVip) { // not required - return nil - } - - if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { - return err - } - - return nil -} - func (m *Cluster) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/client/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go b/client/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go index 432ab0ed9a..3eeade9fcd 100644 --- a/client/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go +++ b/client/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go @@ -24,10 +24,6 @@ type ClusterCreateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` - // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ - APIVip string `json:"api_vip,omitempty"` - // The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. APIVips []*APIVip `json:"api_vips"` @@ -76,10 +72,6 @@ type ClusterCreateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` - // (DEPRECATED) The virtual IP used for cluster ingress traffic. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ - IngressVip string `json:"ingress_vip,omitempty"` - // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -143,10 +135,6 @@ type ClusterCreateParams struct { func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { var res []error - if err := m.validateAPIVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -183,10 +171,6 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateIngressVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -233,18 +217,6 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { return nil } -func (m *ClusterCreateParams) validateAPIVip(formats strfmt.Registry) error { - if swag.IsZero(m.APIVip) { // not required - return nil - } - - if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { - return err - } - - return nil -} - func (m *ClusterCreateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -507,18 +479,6 @@ func (m *ClusterCreateParams) validateIgnitionEndpoint(formats strfmt.Registry) return nil } -func (m *ClusterCreateParams) validateIngressVip(formats strfmt.Registry) error { - if swag.IsZero(m.IngressVip) { // not required - return nil - } - - if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { - return err - } - - return nil -} - func (m *ClusterCreateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/client/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go b/client/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go index 27bc059850..cf3edc1efc 100644 --- a/client/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go +++ b/client/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go @@ -24,10 +24,6 @@ type V2ClusterUpdateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` - // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ - APIVip *string `json:"api_vip,omitempty"` - // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -69,10 +65,6 @@ type V2ClusterUpdateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` - // (DEPRECATED) The virtual IP used for cluster ingress traffic. - // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ - IngressVip *string `json:"ingress_vip,omitempty"` - // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -131,10 +123,6 @@ type V2ClusterUpdateParams struct { func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { var res []error - if err := m.validateAPIVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -163,10 +151,6 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateIngressVip(formats); err != nil { - res = append(res, err) - } - if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -209,18 +193,6 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { return nil } -func (m *V2ClusterUpdateParams) validateAPIVip(formats strfmt.Registry) error { - if swag.IsZero(m.APIVip) { // not required - return nil - } - - if err := validate.Pattern("api_vip", "body", *m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { - return err - } - - return nil -} - func (m *V2ClusterUpdateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -387,18 +359,6 @@ func (m *V2ClusterUpdateParams) validateIgnitionEndpoint(formats strfmt.Registry return nil } -func (m *V2ClusterUpdateParams) validateIngressVip(formats strfmt.Registry) error { - if swag.IsZero(m.IngressVip) { // not required - return nil - } - - if err := validate.Pattern("ingress_vip", "body", *m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { - return err - } - - return nil -} - func (m *V2ClusterUpdateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil From 1b2e4abaddbca03497ec4e5467d5508bf82bdc7f Mon Sep 17 00:00:00 2001 From: Nir Magnezi Date: Thu, 12 Oct 2023 14:24:15 +0300 Subject: [PATCH 5/9] MGMT-14810: Documentation update --- .../agentClusterInstall-with-installconfig-overrides.yaml | 4 ++++ docs/hive-integration/crds/agentClusterInstall.yaml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/docs/hive-integration/crds/agentClusterInstall-with-installconfig-overrides.yaml b/docs/hive-integration/crds/agentClusterInstall-with-installconfig-overrides.yaml index 49ea5f0a2a..604746ec07 100644 --- a/docs/hive-integration/crds/agentClusterInstall-with-installconfig-overrides.yaml +++ b/docs/hive-integration/crds/agentClusterInstall-with-installconfig-overrides.yaml @@ -7,11 +7,15 @@ metadata: namespace: spoke-cluster spec: apiVIP: 1.2.3.8 + apiVIPs: + - 1.2.3.8 clusterDeploymentRef: name: test-cluster imageSetRef: name: openshift-v4.9.0 ingressVIP: 1.2.3.9 + ingressVIPs: + - 1.2.3.9 platformType: BareMetal networking: clusterNetwork: diff --git a/docs/hive-integration/crds/agentClusterInstall.yaml b/docs/hive-integration/crds/agentClusterInstall.yaml index 5c7c2f465d..95516dded7 100644 --- a/docs/hive-integration/crds/agentClusterInstall.yaml +++ b/docs/hive-integration/crds/agentClusterInstall.yaml @@ -5,11 +5,15 @@ metadata: namespace: spoke-cluster spec: apiVIP: 1.2.3.8 + apiVIPs: + - 1.2.3.8 clusterDeploymentRef: name: test-cluster imageSetRef: name: openshift-v4.9.0 ingressVIP: 1.2.3.9 + ingressVIPs: + - 1.2.3.9 platformType: BareMetal networking: clusterNetwork: From 2d8e1eb689c5614aa1383b822a76fe45ba59f9a7 Mon Sep 17 00:00:00 2001 From: Nir Magnezi Date: Thu, 12 Oct 2023 14:29:21 +0300 Subject: [PATCH 6/9] MGMT-14810: Temporarily add api_vip and ingress_vip to swagger To be removed entirely from swagger as soon as we adapt test-infra and UI. --- swagger.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/swagger.yaml b/swagger.yaml index 59f5a97870..4fe28a88fb 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -4711,11 +4711,19 @@ definitions: description: The IP address pool to use for service IP addresses. You can enter only one IP address pool. If you need to access the services from an external network, configure load balancers and routers to manage the traffic. pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3}\/(?:(?:[0-9])|(?:[1-2][0-9])|(?:3[0-2])))|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,})/(?:(?:[0-9])|(?:[1-9][0-9])|(?:1[0-1][0-9])|(?:12[0-8])))$' default: "172.30.0.0/16" + api_vip: + type: string + pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$' + description: (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. api_vips: type: array description: The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. items: $ref: '#/definitions/api_vip' + ingress_vip: + type: string + pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$' + description: (DEPRECATED) The virtual IP used for cluster ingress traffic. ingress_vips: type: array description: The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. @@ -4881,12 +4889,22 @@ definitions: description: The IP address pool to use for service IP addresses. You can enter only one IP address pool. If you need to access the services from an external network, configure load balancers and routers to manage the traffic. pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3}\/(?:(?:[0-9])|(?:[1-2][0-9])|(?:3[0-2])))|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,})/(?:(?:[0-9])|(?:[1-9][0-9])|(?:1[0-1][0-9])|(?:12[0-8])))$' x-nullable: true + api_vip: + type: string + pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$' + description: (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. + x-nullable: true api_vips: type: array description: The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. items: $ref: '#/definitions/api_vip' x-nullable: true + ingress_vip: + type: string + pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$' + description: (DEPRECATED) The virtual IP used for cluster ingress traffic. + x-nullable: true ingress_vips: type: array description: The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. @@ -5077,6 +5095,10 @@ definitions: type: string description: The IP address pool to use for service IP addresses. You can enter only one IP address pool. If you need to access the services from an external network, configure load balancers and routers to manage the traffic. pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3}\/(?:(?:[0-9])|(?:[1-2][0-9])|(?:3[0-2])))|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,})/(?:(?:[0-9])|(?:[1-9][0-9])|(?:1[0-1][0-9])|(?:12[0-8])))$' + api_vip: + type: string + pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$' + description: (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. api_vips: x-go-custom-tag: gorm:"foreignkey:ClusterID;references:ID" x-nullable: true @@ -5092,6 +5114,10 @@ definitions: type: string description: A CIDR that all hosts belonging to the cluster should have an interfaces with IP address that belongs to this CIDR. The api_vip belongs to this CIDR. pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3}\/(?:(?:[0-9])|(?:[1-2][0-9])|(?:3[0-2])))|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,})/(?:(?:[0-9])|(?:[1-9][0-9])|(?:1[0-1][0-9])|(?:12[0-8])))$' + ingress_vip: + type: string + pattern: '^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$' + description: (DEPRECATED) The virtual IP used for cluster ingress traffic. ingress_vips: x-go-custom-tag: gorm:"foreignkey:ClusterID;references:ID" x-nullable: true From 1f80da0fbf9ff39f00a76a00a95cc2dc334d18cd Mon Sep 17 00:00:00 2001 From: Nir Magnezi Date: Mon, 16 Oct 2023 13:34:32 +0300 Subject: [PATCH 7/9] MGMT-14810: Adapt operator ACI template --- deploy/operator/ztp/agentClusterInstall.j2 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/deploy/operator/ztp/agentClusterInstall.j2 b/deploy/operator/ztp/agentClusterInstall.j2 index 221b808e9b..371b7d09e9 100644 --- a/deploy/operator/ztp/agentClusterInstall.j2 +++ b/deploy/operator/ztp/agentClusterInstall.j2 @@ -9,10 +9,12 @@ spec: imageSetRef: name: '{{ cluster_image_set_name }}' {% if spoke_api_vip %} - apiVIP: '{{ spoke_api_vip }}' + apiVIPs: + - '{{ spoke_api_vip }}' {% endif %} {% if spoke_ingress_vip %} - ingressVIP: '{{ spoke_ingress_vip }}' + ingressVIPs: + - '{{ spoke_ingress_vip }}' {% endif %} networking: clusterNetwork: From 297d71d2f8f847dfbd319555459526689efe89b8 Mon Sep 17 00:00:00 2001 From: Nir Magnezi Date: Thu, 12 Oct 2023 14:43:42 +0300 Subject: [PATCH 8/9] MGMT-14810: Regenerate --- .../assisted-service/models/cluster.go | 40 ++++++++++++ .../models/cluster_create_params.go | 40 ++++++++++++ .../models/v2_cluster_update_params.go | 40 ++++++++++++ .../assisted-service/models/cluster.go | 40 ++++++++++++ .../models/cluster_create_params.go | 40 ++++++++++++ .../models/v2_cluster_update_params.go | 40 ++++++++++++ cmd/agentbasedinstaller/register.go | 21 ++++++ internal/cluster/validations/validations.go | 24 +++---- .../clusterdeployments_controller.go | 32 ++++++---- .../clusterdeployments_controller_test.go | 4 +- internal/controller/controllers/common.go | 8 +-- models/cluster.go | 40 ++++++++++++ models/cluster_create_params.go | 40 ++++++++++++ models/v2_cluster_update_params.go | 40 ++++++++++++ restapi/embedded_spec.go | 64 +++++++++++++++++++ .../assisted-service/models/cluster.go | 40 ++++++++++++ .../models/cluster_create_params.go | 40 ++++++++++++ .../models/v2_cluster_update_params.go | 40 ++++++++++++ 18 files changed, 602 insertions(+), 31 deletions(-) diff --git a/api/vendor/github.com/openshift/assisted-service/models/cluster.go b/api/vendor/github.com/openshift/assisted-service/models/cluster.go index ed4f66367b..f996313bb3 100644 --- a/api/vendor/github.com/openshift/assisted-service/models/cluster.go +++ b/api/vendor/github.com/openshift/assisted-service/models/cluster.go @@ -30,6 +30,10 @@ type Cluster struct { // Format: uuid AmsSubscriptionID strfmt.UUID `json:"ams_subscription_id,omitempty"` + // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ + APIVip string `json:"api_vip,omitempty"` + // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -143,6 +147,10 @@ type Cluster struct { // reflect the actual cluster they represent Imported *bool `json:"imported,omitempty"` + // (DEPRECATED) The virtual IP used for cluster ingress traffic. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ + IngressVip string `json:"ingress_vip,omitempty"` + // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips" gorm:"foreignkey:ClusterID;references:ID"` @@ -281,6 +289,10 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateAPIVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -349,6 +361,10 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateIngressVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -443,6 +459,18 @@ func (m *Cluster) validateAmsSubscriptionID(formats strfmt.Registry) error { return nil } +func (m *Cluster) validateAPIVip(formats strfmt.Registry) error { + if swag.IsZero(m.APIVip) { // not required + return nil + } + + if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { + return err + } + + return nil +} + func (m *Cluster) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -835,6 +863,18 @@ func (m *Cluster) validateImageInfo(formats strfmt.Registry) error { return nil } +func (m *Cluster) validateIngressVip(formats strfmt.Registry) error { + if swag.IsZero(m.IngressVip) { // not required + return nil + } + + if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { + return err + } + + return nil +} + func (m *Cluster) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/api/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go b/api/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go index 3eeade9fcd..432ab0ed9a 100644 --- a/api/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go +++ b/api/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go @@ -24,6 +24,10 @@ type ClusterCreateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` + // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ + APIVip string `json:"api_vip,omitempty"` + // The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. APIVips []*APIVip `json:"api_vips"` @@ -72,6 +76,10 @@ type ClusterCreateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` + // (DEPRECATED) The virtual IP used for cluster ingress traffic. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ + IngressVip string `json:"ingress_vip,omitempty"` + // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -135,6 +143,10 @@ type ClusterCreateParams struct { func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateAPIVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -171,6 +183,10 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateIngressVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -217,6 +233,18 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { return nil } +func (m *ClusterCreateParams) validateAPIVip(formats strfmt.Registry) error { + if swag.IsZero(m.APIVip) { // not required + return nil + } + + if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { + return err + } + + return nil +} + func (m *ClusterCreateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -479,6 +507,18 @@ func (m *ClusterCreateParams) validateIgnitionEndpoint(formats strfmt.Registry) return nil } +func (m *ClusterCreateParams) validateIngressVip(formats strfmt.Registry) error { + if swag.IsZero(m.IngressVip) { // not required + return nil + } + + if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { + return err + } + + return nil +} + func (m *ClusterCreateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/api/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go b/api/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go index cf3edc1efc..27bc059850 100644 --- a/api/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go +++ b/api/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go @@ -24,6 +24,10 @@ type V2ClusterUpdateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` + // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ + APIVip *string `json:"api_vip,omitempty"` + // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -65,6 +69,10 @@ type V2ClusterUpdateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` + // (DEPRECATED) The virtual IP used for cluster ingress traffic. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ + IngressVip *string `json:"ingress_vip,omitempty"` + // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -123,6 +131,10 @@ type V2ClusterUpdateParams struct { func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateAPIVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -151,6 +163,10 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateIngressVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -193,6 +209,18 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { return nil } +func (m *V2ClusterUpdateParams) validateAPIVip(formats strfmt.Registry) error { + if swag.IsZero(m.APIVip) { // not required + return nil + } + + if err := validate.Pattern("api_vip", "body", *m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { + return err + } + + return nil +} + func (m *V2ClusterUpdateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -359,6 +387,18 @@ func (m *V2ClusterUpdateParams) validateIgnitionEndpoint(formats strfmt.Registry return nil } +func (m *V2ClusterUpdateParams) validateIngressVip(formats strfmt.Registry) error { + if swag.IsZero(m.IngressVip) { // not required + return nil + } + + if err := validate.Pattern("ingress_vip", "body", *m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { + return err + } + + return nil +} + func (m *V2ClusterUpdateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/client/vendor/github.com/openshift/assisted-service/models/cluster.go b/client/vendor/github.com/openshift/assisted-service/models/cluster.go index ed4f66367b..f996313bb3 100644 --- a/client/vendor/github.com/openshift/assisted-service/models/cluster.go +++ b/client/vendor/github.com/openshift/assisted-service/models/cluster.go @@ -30,6 +30,10 @@ type Cluster struct { // Format: uuid AmsSubscriptionID strfmt.UUID `json:"ams_subscription_id,omitempty"` + // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ + APIVip string `json:"api_vip,omitempty"` + // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -143,6 +147,10 @@ type Cluster struct { // reflect the actual cluster they represent Imported *bool `json:"imported,omitempty"` + // (DEPRECATED) The virtual IP used for cluster ingress traffic. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ + IngressVip string `json:"ingress_vip,omitempty"` + // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips" gorm:"foreignkey:ClusterID;references:ID"` @@ -281,6 +289,10 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateAPIVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -349,6 +361,10 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateIngressVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -443,6 +459,18 @@ func (m *Cluster) validateAmsSubscriptionID(formats strfmt.Registry) error { return nil } +func (m *Cluster) validateAPIVip(formats strfmt.Registry) error { + if swag.IsZero(m.APIVip) { // not required + return nil + } + + if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { + return err + } + + return nil +} + func (m *Cluster) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -835,6 +863,18 @@ func (m *Cluster) validateImageInfo(formats strfmt.Registry) error { return nil } +func (m *Cluster) validateIngressVip(formats strfmt.Registry) error { + if swag.IsZero(m.IngressVip) { // not required + return nil + } + + if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { + return err + } + + return nil +} + func (m *Cluster) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/client/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go b/client/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go index 3eeade9fcd..432ab0ed9a 100644 --- a/client/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go +++ b/client/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go @@ -24,6 +24,10 @@ type ClusterCreateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` + // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ + APIVip string `json:"api_vip,omitempty"` + // The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. APIVips []*APIVip `json:"api_vips"` @@ -72,6 +76,10 @@ type ClusterCreateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` + // (DEPRECATED) The virtual IP used for cluster ingress traffic. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ + IngressVip string `json:"ingress_vip,omitempty"` + // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -135,6 +143,10 @@ type ClusterCreateParams struct { func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateAPIVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -171,6 +183,10 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateIngressVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -217,6 +233,18 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { return nil } +func (m *ClusterCreateParams) validateAPIVip(formats strfmt.Registry) error { + if swag.IsZero(m.APIVip) { // not required + return nil + } + + if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { + return err + } + + return nil +} + func (m *ClusterCreateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -479,6 +507,18 @@ func (m *ClusterCreateParams) validateIgnitionEndpoint(formats strfmt.Registry) return nil } +func (m *ClusterCreateParams) validateIngressVip(formats strfmt.Registry) error { + if swag.IsZero(m.IngressVip) { // not required + return nil + } + + if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { + return err + } + + return nil +} + func (m *ClusterCreateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/client/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go b/client/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go index cf3edc1efc..27bc059850 100644 --- a/client/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go +++ b/client/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go @@ -24,6 +24,10 @@ type V2ClusterUpdateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` + // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ + APIVip *string `json:"api_vip,omitempty"` + // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -65,6 +69,10 @@ type V2ClusterUpdateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` + // (DEPRECATED) The virtual IP used for cluster ingress traffic. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ + IngressVip *string `json:"ingress_vip,omitempty"` + // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -123,6 +131,10 @@ type V2ClusterUpdateParams struct { func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateAPIVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -151,6 +163,10 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateIngressVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -193,6 +209,18 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { return nil } +func (m *V2ClusterUpdateParams) validateAPIVip(formats strfmt.Registry) error { + if swag.IsZero(m.APIVip) { // not required + return nil + } + + if err := validate.Pattern("api_vip", "body", *m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { + return err + } + + return nil +} + func (m *V2ClusterUpdateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -359,6 +387,18 @@ func (m *V2ClusterUpdateParams) validateIgnitionEndpoint(formats strfmt.Registry return nil } +func (m *V2ClusterUpdateParams) validateIngressVip(formats strfmt.Registry) error { + if swag.IsZero(m.IngressVip) { // not required + return nil + } + + if err := validate.Pattern("ingress_vip", "body", *m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { + return err + } + + return nil +} + func (m *V2ClusterUpdateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/cmd/agentbasedinstaller/register.go b/cmd/agentbasedinstaller/register.go index 87573e388a..a6ba697801 100644 --- a/cmd/agentbasedinstaller/register.go +++ b/cmd/agentbasedinstaller/register.go @@ -13,6 +13,7 @@ import ( "github.com/openshift/assisted-service/client" "github.com/openshift/assisted-service/client/installer" "github.com/openshift/assisted-service/client/manifests" + "github.com/openshift/assisted-service/internal/cluster/validations" "github.com/openshift/assisted-service/internal/controller/controllers" "github.com/openshift/assisted-service/internal/oc" "github.com/openshift/assisted-service/models" @@ -52,6 +53,26 @@ func RegisterCluster(ctx context.Context, log *log.Logger, bmInventory *client.A return nil, aciErr } + desiredApiVips, err := validations.HandleApiVipBackwardsCompatibility( + nil, + aci.Spec.APIVIP, + controllers.ApiVipsEntriesToArray(aci.Spec.APIVIPs)) + if err != nil { + return nil, err + } + aci.Spec.APIVIPs = controllers.ApiVipsArrayToStrings(desiredApiVips) + aci.Spec.APIVIP = "" + + desiredIngressVips, err := validations.HandleIngressVipBackwardsCompatibility( + nil, + aci.Spec.IngressVIP, + controllers.IngressVipsEntriesToArray(aci.Spec.IngressVIPs)) + if err != nil { + return nil, err + } + aci.Spec.IngressVIPs = controllers.IngressVipsArrayToStrings(desiredIngressVips) + aci.Spec.IngressVIP = "" + releaseImage, releaseError := getReleaseVersion(clusterImageSetPath) if releaseError != nil { return nil, releaseError diff --git a/internal/cluster/validations/validations.go b/internal/cluster/validations/validations.go index 93e3570a05..903b9d47c6 100644 --- a/internal/cluster/validations/validations.go +++ b/internal/cluster/validations/validations.go @@ -366,35 +366,35 @@ func ValidateVipDHCPAllocationWithIPv6(vipDhcpAllocation bool, machineNetworkCID return nil } -func HandleApiVipBackwardsCompatibility(clusterId strfmt.UUID, apiVip string, apiVips []*models.APIVip) ([]*models.APIVip, error) { +func HandleApiVipBackwardsCompatibility(clusterId *strfmt.UUID, apiVip string, apiVips []*models.APIVip) ([]*models.APIVip, error) { // APIVip provided, but APIVips were not. if apiVip != "" && len(apiVips) == 0 { - return []*models.APIVip{{IP: models.IP(apiVip), ClusterID: clusterId}}, nil + vips := []*models.APIVip{{IP: models.IP(apiVip)}} + if clusterId != nil { + vips[0].ClusterID = *clusterId + } + return vips, nil } // Both APIVip and APIVips were provided. if apiVip != "" && len(apiVips) > 0 && apiVip != string(apiVips[0].IP) { return nil, errors.New("apiVIP must be the same as the first element of apiVIPs") } - // APIVips were provided, but APIVip was not. - if apiVip == "" && apiVips != nil && len(apiVips) > 0 { - return nil, errors.New("request must include apiVIP alongside apiVIPs") - } return apiVips, nil } -func HandleIngressVipBackwardsCompatibility(clusterId strfmt.UUID, ingressVip string, ingressVips []*models.IngressVip) ([]*models.IngressVip, error) { +func HandleIngressVipBackwardsCompatibility(clusterId *strfmt.UUID, ingressVip string, ingressVips []*models.IngressVip) ([]*models.IngressVip, error) { // IngressVip provided, but IngressVips were not. if ingressVip != "" && len(ingressVips) == 0 { - return []*models.IngressVip{{IP: models.IP(ingressVip), ClusterID: clusterId}}, nil + vips := []*models.IngressVip{{IP: models.IP(ingressVip)}} + if clusterId != nil { + vips[0].ClusterID = *clusterId + } + return vips, nil } // Both IngressVip and IngressVips were provided. if ingressVip != "" && len(ingressVips) > 0 && ingressVip != string(ingressVips[0].IP) { return nil, errors.New("ingressVIP must be the same as the first element of ingressVIPs") } - // IngressVips were provided, but IngressVip was not. - if ingressVip == "" && ingressVips != nil && len(ingressVips) > 0 { - return nil, errors.New("request must include ingressVIP alongside ingressVIPs") - } return ingressVips, nil } diff --git a/internal/controller/controllers/clusterdeployments_controller.go b/internal/controller/controllers/clusterdeployments_controller.go index 7d60a0fd0a..9e34cd8221 100644 --- a/internal/controller/controllers/clusterdeployments_controller.go +++ b/internal/controller/controllers/clusterdeployments_controller.go @@ -929,23 +929,29 @@ func (r *ClusterDeploymentsReconciler) updateNetworkParams(clusterDeployment *hi // We must not run this reconciler in case VIPs are missing from the cluster spec as this can // indicate a scenario when backend calculates them automatically, e.g. SNO cluster. isDHCPEnabled := swag.BoolValue(cluster.VipDhcpAllocation) + if !isDHCPEnabled && (clusterInstall.Spec.APIVIP != "" || clusterInstall.Spec.IngressVIP != "" || len(clusterInstall.Spec.APIVIPs) > 0 || len(clusterInstall.Spec.IngressVIPs) > 0) { - desiredApiVips, _ := validations.HandleApiVipBackwardsCompatibility( - *cluster.ID, + desiredApiVips, err := validations.HandleApiVipBackwardsCompatibility( + cluster.ID, clusterInstall.Spec.APIVIP, - apiVipsEntriesToArray(clusterInstall.Spec.APIVIPs)) - - if clusterInstall.Spec.APIVIP != network.GetApiVipById(cluster, 0) || - !network.AreApiVipsIdentical(desiredApiVips, cluster.APIVips) { + ApiVipsEntriesToArray(clusterInstall.Spec.APIVIPs)) + if err != nil { + return nil, err + } + if !network.AreApiVipsIdentical(desiredApiVips, cluster.APIVips) { params.APIVips = desiredApiVips update = true } - desiredIngressVips, _ := validations.HandleIngressVipBackwardsCompatibility(*cluster.ID, + desiredIngressVips, err := validations.HandleIngressVipBackwardsCompatibility( + cluster.ID, clusterInstall.Spec.IngressVIP, - ingressVipsEntriesToArray(clusterInstall.Spec.IngressVIPs)) + IngressVipsEntriesToArray(clusterInstall.Spec.IngressVIPs)) + if err != nil { + return nil, err + } if clusterInstall.Spec.IngressVIP != network.GetIngressVipById(cluster, 0) || !network.AreIngressVipsIdentical(desiredIngressVips, cluster.IngressVips) { @@ -987,7 +993,7 @@ func (r *ClusterDeploymentsReconciler) updateIfNeeded(ctx context.Context, return cluster, errors.Wrap(err, "failed to update network params") } update = swag.BoolValue(shouldUpdateNetworkParams) || update - // Trim key before comapring as done in RegisterClusterInternal + // Trim key before comparing as done in RegisterClusterInternal sshPublicKey := strings.TrimSpace(clusterInstall.Spec.SSHPublicKey) updateString(sshPublicKey, cluster.SSHPublicKey, ¶ms.SSHPublicKey) @@ -1266,8 +1272,8 @@ func CreateClusterParams(clusterDeployment *hivev1.ClusterDeployment, clusterIns OlmOperators: nil, // TODO: handle operators PullSecret: swag.String(pullSecret), VipDhcpAllocation: swag.Bool(false), - APIVips: apiVipsEntriesToArray(clusterInstall.Spec.APIVIPs), - IngressVips: ingressVipsEntriesToArray(clusterInstall.Spec.IngressVIPs), + APIVips: ApiVipsEntriesToArray(clusterInstall.Spec.APIVIPs), + IngressVips: IngressVipsEntriesToArray(clusterInstall.Spec.IngressVIPs), SSHPublicKey: clusterInstall.Spec.SSHPublicKey, CPUArchitecture: releaseImageCPUArch, UserManagedNetworking: swag.Bool(isUserManagedNetwork(clusterInstall)), @@ -1712,8 +1718,8 @@ func (r *ClusterDeploymentsReconciler) updateStatus(ctx context.Context, log log } clusterInstall.Status.APIVIP = network.GetApiVipById(c, 0) clusterInstall.Status.IngressVIP = network.GetIngressVipById(c, 0) - clusterInstall.Status.APIVIPs = apiVipsArrayToStrings(c.APIVips) - clusterInstall.Status.IngressVIPs = ingressVipsArrayToStrings(c.IngressVips) + clusterInstall.Status.APIVIPs = ApiVipsArrayToStrings(c.APIVips) + clusterInstall.Status.IngressVIPs = IngressVipsArrayToStrings(c.IngressVips) clusterInstall.Status.UserManagedNetworking = c.UserManagedNetworking clusterInstall.Status.PlatformType = getPlatformType(c.Platform) status := *c.Status diff --git a/internal/controller/controllers/clusterdeployments_controller_test.go b/internal/controller/controllers/clusterdeployments_controller_test.go index 4117f5a769..b914d76092 100644 --- a/internal/controller/controllers/clusterdeployments_controller_test.go +++ b/internal/controller/controllers/clusterdeployments_controller_test.go @@ -117,8 +117,8 @@ func getDefaultAgentClusterInstallSpec(clusterName string) hiveext.AgentClusterI return hiveext.AgentClusterInstallSpec{ APIVIP: string(common.TestIPv4Networking.APIVips[0].IP), IngressVIP: string(common.TestIPv4Networking.IngressVips[0].IP), - APIVIPs: apiVipsArrayToStrings(common.TestIPv4Networking.APIVips), - IngressVIPs: ingressVipsArrayToStrings(common.TestIPv4Networking.IngressVips), + APIVIPs: ApiVipsArrayToStrings(common.TestIPv4Networking.APIVips), + IngressVIPs: IngressVipsArrayToStrings(common.TestIPv4Networking.IngressVips), Networking: hiveext.Networking{ MachineNetwork: nil, ClusterNetwork: clusterNetworksArrayToEntries(common.TestIPv4Networking.ClusterNetworks), diff --git a/internal/controller/controllers/common.go b/internal/controller/controllers/common.go index 9ae03bdb1b..6e9877d9fb 100644 --- a/internal/controller/controllers/common.go +++ b/internal/controller/controllers/common.go @@ -302,25 +302,25 @@ func machineNetworksEntriesToArray(entries []hiveext.MachineNetworkEntry) []*mod }).([]*models.MachineNetwork) } -func apiVipsArrayToStrings(vips []*models.APIVip) []string { +func ApiVipsArrayToStrings(vips []*models.APIVip) []string { return funk.Map(vips, func(vip *models.APIVip) string { return string(vip.IP) }).([]string) } -func apiVipsEntriesToArray(entries []string) []*models.APIVip { +func ApiVipsEntriesToArray(entries []string) []*models.APIVip { return funk.Map(entries, func(entry string) *models.APIVip { return &models.APIVip{IP: models.IP(entry)} }).([]*models.APIVip) } -func ingressVipsArrayToStrings(vips []*models.IngressVip) []string { +func IngressVipsArrayToStrings(vips []*models.IngressVip) []string { return funk.Map(vips, func(vip *models.IngressVip) string { return string(vip.IP) }).([]string) } -func ingressVipsEntriesToArray(entries []string) []*models.IngressVip { +func IngressVipsEntriesToArray(entries []string) []*models.IngressVip { return funk.Map(entries, func(entry string) *models.IngressVip { return &models.IngressVip{IP: models.IP(entry)} }).([]*models.IngressVip) diff --git a/models/cluster.go b/models/cluster.go index ed4f66367b..f996313bb3 100644 --- a/models/cluster.go +++ b/models/cluster.go @@ -30,6 +30,10 @@ type Cluster struct { // Format: uuid AmsSubscriptionID strfmt.UUID `json:"ams_subscription_id,omitempty"` + // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ + APIVip string `json:"api_vip,omitempty"` + // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -143,6 +147,10 @@ type Cluster struct { // reflect the actual cluster they represent Imported *bool `json:"imported,omitempty"` + // (DEPRECATED) The virtual IP used for cluster ingress traffic. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ + IngressVip string `json:"ingress_vip,omitempty"` + // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips" gorm:"foreignkey:ClusterID;references:ID"` @@ -281,6 +289,10 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateAPIVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -349,6 +361,10 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateIngressVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -443,6 +459,18 @@ func (m *Cluster) validateAmsSubscriptionID(formats strfmt.Registry) error { return nil } +func (m *Cluster) validateAPIVip(formats strfmt.Registry) error { + if swag.IsZero(m.APIVip) { // not required + return nil + } + + if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { + return err + } + + return nil +} + func (m *Cluster) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -835,6 +863,18 @@ func (m *Cluster) validateImageInfo(formats strfmt.Registry) error { return nil } +func (m *Cluster) validateIngressVip(formats strfmt.Registry) error { + if swag.IsZero(m.IngressVip) { // not required + return nil + } + + if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { + return err + } + + return nil +} + func (m *Cluster) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/models/cluster_create_params.go b/models/cluster_create_params.go index 3eeade9fcd..432ab0ed9a 100644 --- a/models/cluster_create_params.go +++ b/models/cluster_create_params.go @@ -24,6 +24,10 @@ type ClusterCreateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` + // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ + APIVip string `json:"api_vip,omitempty"` + // The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. APIVips []*APIVip `json:"api_vips"` @@ -72,6 +76,10 @@ type ClusterCreateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` + // (DEPRECATED) The virtual IP used for cluster ingress traffic. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ + IngressVip string `json:"ingress_vip,omitempty"` + // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -135,6 +143,10 @@ type ClusterCreateParams struct { func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateAPIVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -171,6 +183,10 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateIngressVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -217,6 +233,18 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { return nil } +func (m *ClusterCreateParams) validateAPIVip(formats strfmt.Registry) error { + if swag.IsZero(m.APIVip) { // not required + return nil + } + + if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { + return err + } + + return nil +} + func (m *ClusterCreateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -479,6 +507,18 @@ func (m *ClusterCreateParams) validateIgnitionEndpoint(formats strfmt.Registry) return nil } +func (m *ClusterCreateParams) validateIngressVip(formats strfmt.Registry) error { + if swag.IsZero(m.IngressVip) { // not required + return nil + } + + if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { + return err + } + + return nil +} + func (m *ClusterCreateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/models/v2_cluster_update_params.go b/models/v2_cluster_update_params.go index cf3edc1efc..27bc059850 100644 --- a/models/v2_cluster_update_params.go +++ b/models/v2_cluster_update_params.go @@ -24,6 +24,10 @@ type V2ClusterUpdateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` + // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ + APIVip *string `json:"api_vip,omitempty"` + // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -65,6 +69,10 @@ type V2ClusterUpdateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` + // (DEPRECATED) The virtual IP used for cluster ingress traffic. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ + IngressVip *string `json:"ingress_vip,omitempty"` + // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -123,6 +131,10 @@ type V2ClusterUpdateParams struct { func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateAPIVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -151,6 +163,10 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateIngressVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -193,6 +209,18 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { return nil } +func (m *V2ClusterUpdateParams) validateAPIVip(formats strfmt.Registry) error { + if swag.IsZero(m.APIVip) { // not required + return nil + } + + if err := validate.Pattern("api_vip", "body", *m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { + return err + } + + return nil +} + func (m *V2ClusterUpdateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -359,6 +387,18 @@ func (m *V2ClusterUpdateParams) validateIgnitionEndpoint(formats strfmt.Registry return nil } +func (m *V2ClusterUpdateParams) validateIngressVip(formats strfmt.Registry) error { + if swag.IsZero(m.IngressVip) { // not required + return nil + } + + if err := validate.Pattern("ingress_vip", "body", *m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { + return err + } + + return nil +} + func (m *V2ClusterUpdateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/restapi/embedded_spec.go b/restapi/embedded_spec.go index 0109b0b18a..54d14e9900 100644 --- a/restapi/embedded_spec.go +++ b/restapi/embedded_spec.go @@ -6009,6 +6009,11 @@ func init() { "type": "string", "format": "uuid" }, + "api_vip": { + "description": "(DEPRECATED) The virtual IP used to reach the OpenShift cluster's API.", + "type": "string", + "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$" + }, "api_vip_dns_name": { "description": "The domain name used to reach the OpenShift cluster API.", "type": "string", @@ -6200,6 +6205,11 @@ func init() { "type": "boolean", "default": false }, + "ingress_vip": { + "description": "(DEPRECATED) The virtual IP used for cluster ingress traffic.", + "type": "string", + "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$" + }, "ingress_vips": { "description": "The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", @@ -6433,6 +6443,11 @@ func init() { "type": "string", "x-nullable": true }, + "api_vip": { + "description": "(DEPRECATED) The virtual IP used to reach the OpenShift cluster's API.", + "type": "string", + "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$" + }, "api_vips": { "description": "The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", @@ -6517,6 +6532,11 @@ func init() { "description": "Explicit ignition endpoint overrides the default ignition endpoint.", "$ref": "#/definitions/ignition-endpoint" }, + "ingress_vip": { + "description": "(DEPRECATED) The virtual IP used for cluster ingress traffic.", + "type": "string", + "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$" + }, "ingress_vips": { "description": "The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", @@ -10025,6 +10045,12 @@ func init() { "type": "string", "x-nullable": true }, + "api_vip": { + "description": "(DEPRECATED) The virtual IP used to reach the OpenShift cluster's API.", + "type": "string", + "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$", + "x-nullable": true + }, "api_vip_dns_name": { "description": "The domain name used to reach the OpenShift cluster API.", "type": "string", @@ -10093,6 +10119,12 @@ func init() { "description": "Explicit ignition endpoint overrides the default ignition endpoint.", "$ref": "#/definitions/ignition-endpoint" }, + "ingress_vip": { + "description": "(DEPRECATED) The virtual IP used for cluster ingress traffic.", + "type": "string", + "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$", + "x-nullable": true + }, "ingress_vips": { "description": "The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", @@ -16461,6 +16493,11 @@ func init() { "type": "string", "format": "uuid" }, + "api_vip": { + "description": "(DEPRECATED) The virtual IP used to reach the OpenShift cluster's API.", + "type": "string", + "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$" + }, "api_vip_dns_name": { "description": "The domain name used to reach the OpenShift cluster API.", "type": "string", @@ -16652,6 +16689,11 @@ func init() { "type": "boolean", "default": false }, + "ingress_vip": { + "description": "(DEPRECATED) The virtual IP used for cluster ingress traffic.", + "type": "string", + "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$" + }, "ingress_vips": { "description": "The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", @@ -16885,6 +16927,11 @@ func init() { "type": "string", "x-nullable": true }, + "api_vip": { + "description": "(DEPRECATED) The virtual IP used to reach the OpenShift cluster's API.", + "type": "string", + "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$" + }, "api_vips": { "description": "The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", @@ -16969,6 +17016,11 @@ func init() { "description": "Explicit ignition endpoint overrides the default ignition endpoint.", "$ref": "#/definitions/ignition-endpoint" }, + "ingress_vip": { + "description": "(DEPRECATED) The virtual IP used for cluster ingress traffic.", + "type": "string", + "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$" + }, "ingress_vips": { "description": "The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", @@ -20416,6 +20468,12 @@ func init() { "type": "string", "x-nullable": true }, + "api_vip": { + "description": "(DEPRECATED) The virtual IP used to reach the OpenShift cluster's API.", + "type": "string", + "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$", + "x-nullable": true + }, "api_vip_dns_name": { "description": "The domain name used to reach the OpenShift cluster API.", "type": "string", @@ -20484,6 +20542,12 @@ func init() { "description": "Explicit ignition endpoint overrides the default ignition endpoint.", "$ref": "#/definitions/ignition-endpoint" }, + "ingress_vip": { + "description": "(DEPRECATED) The virtual IP used for cluster ingress traffic.", + "type": "string", + "pattern": "^(?:(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$", + "x-nullable": true + }, "ingress_vips": { "description": "The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks.", "type": "array", diff --git a/vendor/github.com/openshift/assisted-service/models/cluster.go b/vendor/github.com/openshift/assisted-service/models/cluster.go index ed4f66367b..f996313bb3 100644 --- a/vendor/github.com/openshift/assisted-service/models/cluster.go +++ b/vendor/github.com/openshift/assisted-service/models/cluster.go @@ -30,6 +30,10 @@ type Cluster struct { // Format: uuid AmsSubscriptionID strfmt.UUID `json:"ams_subscription_id,omitempty"` + // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ + APIVip string `json:"api_vip,omitempty"` + // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -143,6 +147,10 @@ type Cluster struct { // reflect the actual cluster they represent Imported *bool `json:"imported,omitempty"` + // (DEPRECATED) The virtual IP used for cluster ingress traffic. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ + IngressVip string `json:"ingress_vip,omitempty"` + // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips" gorm:"foreignkey:ClusterID;references:ID"` @@ -281,6 +289,10 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateAPIVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -349,6 +361,10 @@ func (m *Cluster) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateIngressVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -443,6 +459,18 @@ func (m *Cluster) validateAmsSubscriptionID(formats strfmt.Registry) error { return nil } +func (m *Cluster) validateAPIVip(formats strfmt.Registry) error { + if swag.IsZero(m.APIVip) { // not required + return nil + } + + if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { + return err + } + + return nil +} + func (m *Cluster) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -835,6 +863,18 @@ func (m *Cluster) validateImageInfo(formats strfmt.Registry) error { return nil } +func (m *Cluster) validateIngressVip(formats strfmt.Registry) error { + if swag.IsZero(m.IngressVip) { // not required + return nil + } + + if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { + return err + } + + return nil +} + func (m *Cluster) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go b/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go index 3eeade9fcd..432ab0ed9a 100644 --- a/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go +++ b/vendor/github.com/openshift/assisted-service/models/cluster_create_params.go @@ -24,6 +24,10 @@ type ClusterCreateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` + // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ + APIVip string `json:"api_vip,omitempty"` + // The virtual IPs used to reach the OpenShift cluster's API. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. APIVips []*APIVip `json:"api_vips"` @@ -72,6 +76,10 @@ type ClusterCreateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` + // (DEPRECATED) The virtual IP used for cluster ingress traffic. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$ + IngressVip string `json:"ingress_vip,omitempty"` + // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -135,6 +143,10 @@ type ClusterCreateParams struct { func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateAPIVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -171,6 +183,10 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateIngressVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -217,6 +233,18 @@ func (m *ClusterCreateParams) Validate(formats strfmt.Registry) error { return nil } +func (m *ClusterCreateParams) validateAPIVip(formats strfmt.Registry) error { + if swag.IsZero(m.APIVip) { // not required + return nil + } + + if err := validate.Pattern("api_vip", "body", m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { + return err + } + + return nil +} + func (m *ClusterCreateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -479,6 +507,18 @@ func (m *ClusterCreateParams) validateIgnitionEndpoint(formats strfmt.Registry) return nil } +func (m *ClusterCreateParams) validateIngressVip(formats strfmt.Registry) error { + if swag.IsZero(m.IngressVip) { // not required + return nil + } + + if err := validate.Pattern("ingress_vip", "body", m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))$`); err != nil { + return err + } + + return nil +} + func (m *ClusterCreateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil diff --git a/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go b/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go index cf3edc1efc..27bc059850 100644 --- a/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go +++ b/vendor/github.com/openshift/assisted-service/models/v2_cluster_update_params.go @@ -24,6 +24,10 @@ type V2ClusterUpdateParams struct { // A comma-separated list of NTP sources (name or IP) going to be added to all the hosts. AdditionalNtpSource *string `json:"additional_ntp_source,omitempty"` + // (DEPRECATED) The virtual IP used to reach the OpenShift cluster's API. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ + APIVip *string `json:"api_vip,omitempty"` + // The domain name used to reach the OpenShift cluster API. APIVipDNSName *string `json:"api_vip_dns_name,omitempty"` @@ -65,6 +69,10 @@ type V2ClusterUpdateParams struct { // Explicit ignition endpoint overrides the default ignition endpoint. IgnitionEndpoint *IgnitionEndpoint `json:"ignition_endpoint,omitempty" gorm:"embedded;embeddedPrefix:ignition_endpoint_"` + // (DEPRECATED) The virtual IP used for cluster ingress traffic. + // Pattern: ^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$ + IngressVip *string `json:"ingress_vip,omitempty"` + // The virtual IPs used for cluster ingress traffic. Enter one IP address for single-stack clusters, or up to two for dual-stack clusters (at most one IP address per IP stack used). The order of stacks should be the same as order of subnets in Cluster Networks, Service Networks, and Machine Networks. IngressVips []*IngressVip `json:"ingress_vips"` @@ -123,6 +131,10 @@ type V2ClusterUpdateParams struct { func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateAPIVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateAPIVips(formats); err != nil { res = append(res, err) } @@ -151,6 +163,10 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateIngressVip(formats); err != nil { + res = append(res, err) + } + if err := m.validateIngressVips(formats); err != nil { res = append(res, err) } @@ -193,6 +209,18 @@ func (m *V2ClusterUpdateParams) Validate(formats strfmt.Registry) error { return nil } +func (m *V2ClusterUpdateParams) validateAPIVip(formats strfmt.Registry) error { + if swag.IsZero(m.APIVip) { // not required + return nil + } + + if err := validate.Pattern("api_vip", "body", *m.APIVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { + return err + } + + return nil +} + func (m *V2ClusterUpdateParams) validateAPIVips(formats strfmt.Registry) error { if swag.IsZero(m.APIVips) { // not required return nil @@ -359,6 +387,18 @@ func (m *V2ClusterUpdateParams) validateIgnitionEndpoint(formats strfmt.Registry return nil } +func (m *V2ClusterUpdateParams) validateIngressVip(formats strfmt.Registry) error { + if swag.IsZero(m.IngressVip) { // not required + return nil + } + + if err := validate.Pattern("ingress_vip", "body", *m.IngressVip, `^(?:(?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:(?:[0-9a-fA-F]*:[0-9a-fA-F]*){2,}))?$`); err != nil { + return err + } + + return nil +} + func (m *V2ClusterUpdateParams) validateIngressVips(formats strfmt.Registry) error { if swag.IsZero(m.IngressVips) { // not required return nil From df11abb64ff192d354419a944e3c6eb54ebc3a30 Mon Sep 17 00:00:00 2001 From: Nir Magnezi Date: Wed, 22 Nov 2023 12:21:13 +0200 Subject: [PATCH 9/9] MGMT-14810: Fix cluster update validation flow --- internal/cluster/validations/validations.go | 25 +++++++++++++++--- .../clusterdeployments_controller.go | 4 +-- .../20221031103047_multiple_vips.go | 26 ------------------- 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/internal/cluster/validations/validations.go b/internal/cluster/validations/validations.go index 903b9d47c6..0440455560 100644 --- a/internal/cluster/validations/validations.go +++ b/internal/cluster/validations/validations.go @@ -456,8 +456,16 @@ func validateVIPsWithUMA(cluster *common.Cluster, params *models.V2ClusterUpdate } func ValidateClusterUpdateVIPAddresses(ipV6Supported bool, cluster *common.Cluster, params *models.V2ClusterUpdateParams) error { - var err error - targetConfiguration := common.Cluster{} + var ( + err error + targetConfiguration common.Cluster + apiVips []*models.APIVip + ingressVips []*models.IngressVip + ) + + apiVips = params.APIVips + ingressVips = params.IngressVips + if (len(params.APIVips) > 1 || len(params.IngressVips) > 1) && !featuresupport.IsFeatureAvailable(models.FeatureSupportLevelIDDUALSTACKVIPS, cluster.OpenshiftVersion, swag.String(cluster.CPUArchitecture)) { @@ -483,14 +491,23 @@ func ValidateClusterUpdateVIPAddresses(ipV6Supported bool, cluster *common.Clust if cluster.VipDhcpAllocation != nil && swag.BoolValue(cluster.VipDhcpAllocation) { // override VIPs that were allocated via DHCP params.APIVips = []*models.APIVip{} + apiVips = []*models.APIVip{} params.IngressVips = []*models.IngressVip{} + ingressVips = []*models.IngressVip{} + } else { + if params.APIVips == nil { + apiVips = cluster.APIVips + } + if params.IngressVips == nil { + ingressVips = cluster.IngressVips + } } } targetConfiguration.ID = cluster.ID targetConfiguration.VipDhcpAllocation = params.VipDhcpAllocation - targetConfiguration.APIVips = params.APIVips - targetConfiguration.IngressVips = params.IngressVips + targetConfiguration.APIVips = apiVips + targetConfiguration.IngressVips = ingressVips targetConfiguration.UserManagedNetworking = params.UserManagedNetworking targetConfiguration.HighAvailabilityMode = cluster.HighAvailabilityMode targetConfiguration.ClusterNetworks = params.ClusterNetworks diff --git a/internal/controller/controllers/clusterdeployments_controller.go b/internal/controller/controllers/clusterdeployments_controller.go index 9e34cd8221..d3357ea023 100644 --- a/internal/controller/controllers/clusterdeployments_controller.go +++ b/internal/controller/controllers/clusterdeployments_controller.go @@ -953,9 +953,7 @@ func (r *ClusterDeploymentsReconciler) updateNetworkParams(clusterDeployment *hi return nil, err } - if clusterInstall.Spec.IngressVIP != network.GetIngressVipById(cluster, 0) || - !network.AreIngressVipsIdentical(desiredIngressVips, cluster.IngressVips) { - + if !network.AreIngressVipsIdentical(desiredIngressVips, cluster.IngressVips) { params.IngressVips = desiredIngressVips update = true } diff --git a/internal/migrations/20221031103047_multiple_vips.go b/internal/migrations/20221031103047_multiple_vips.go index 2a930e68f8..40bdf48959 100644 --- a/internal/migrations/20221031103047_multiple_vips.go +++ b/internal/migrations/20221031103047_multiple_vips.go @@ -8,32 +8,6 @@ import ( func multipleVips() *gormigrate.Migration { migrate := func(tx *gorm.DB) error { - // WIP - - //dbClusters, err := common.GetClustersFromDBWhere(tx, common.UseEagerLoading, common.IncludeDeletedRecords) - //if err != nil { - // return err - //} - //for _, cluster := range dbClusters { - // if cluster.APIVip != "" { - // apiVIPs := &models.APIVip{ - // ClusterID: *cluster.ID, - // IP: models.IP(cluster.APIVip), - // } - // if err = tx.Save(apiVIPs).Error; err != nil { - // return err - // } - // } - // if cluster.IngressVip != "" { - // ingressVIPs := &models.IngressVip{ - // ClusterID: *cluster.ID, - // IP: models.IP(cluster.IngressVip), - // } - // if err = tx.Save(ingressVIPs).Error; err != nil { - // return err - // } - // } - //} return nil }