kubernetes-sigs / cluster-api-provider-openstack

Cluster API implementation for OpenStack
https://cluster-api-openstack.sigs.k8s.io/
Apache License 2.0
297 stars 256 forks source link

Flag `--lb-provider=ovn` does not work properly when set. #1472

Closed Jeremy-Boyle closed 1 year ago

Jeremy-Boyle commented 1 year ago

/kind bug

What steps did you take and what happened: It does not seem that the provider id is being set, when flag --lb-provider=ovn is being sent properly to octavia api.

ERROR:

I0212 19:02:55.248980       1 loadbalancer.go:167] "Creating load balancer in subnet: \"91402434-8ba8-4304-a81a-0a302b163a2c\"" controller="openstackcluster" controllerGroup="infrastructure.cluster.x-k8s.io" controllerKind="OpenStackCluster" OpenStackCluster="openstack/mgt" namespace="openstack" reconcileID=94399840-66bc-4e7a-b461-99e1db6e3275 cluster="mgt" name="k8s-clusterapi-cluster-openstack-mgt-kubeapi"
I0212 19:02:55.249069       1 provider.go:127] OpenStack Request URL: POST https://SOME-OPENSTACK-URL.com:9876/v2.0/lbaas/loadbalancers
I0212 19:02:55.249086       1 provider.go:127] OpenStack Request Headers:
Accept: application/json
Content-Type: application/json
User-Agent: gophercloud/2.0.0
X-Auth-Token: ***
I0212 19:02:55.249120       1 provider.go:127] OpenStack Request Body: {
  "loadbalancer": {
    "description": "Created by cluster-api-provider-openstack cluster openstack-mgt",
    "name": "k8s-clusterapi-cluster-openstack-mgt-kubeapi",
    "vip_subnet_id": "91402434-8ba8-4304-a81a-0a302b163a2c"
  }
}
I0212 19:02:56.833037       1 provider.go:127] OpenStack Response Code: 400
I0212 19:02:56.833080       1 provider.go:127] OpenStack Response Headers:
Content-Length: 95
Content-Type: application/json
Date: Sun, 12 Feb 2023 19:02:55 GMT
Server: Apache/2.4.52 (Ubuntu)
X-Openstack-Request-Id: req-39f960f4-27a6-43f7-9287-c28f0077db2b
I0212 19:02:56.833144       1 provider.go:127] OpenStack Response Body: {
  "debuginfo": null,
  "faultcode": "Client",
  "faultstring": "Provider 'amphora' is not enabled."
}
I0212 19:02:56.833577       1 recorder.go:103] "events: Failed to create load balancer k8s-clusterapi-cluster-openstack-mgt-kubeapi: Bad request with: [POST https://SOME-OPENSTACK-URL.com:9876/v2.0/lbaas/loadbalancers], error message: {\"faultcode\": \"Client\", \"faultstring\": \"Provider 'amphora' is not enabled.\", \"debuginfo\": null}" type="Warning" object={Kind:OpenStackCluster Namespace:openstack Name:mgt UID:a0411a15-0ab0-4472-998b-588cc4e3fe7a APIVersion:infrastructure.cluster.x-k8s.io/v1alpha6 ResourceVersion:5154 FieldPath:} reason="Failedcreateloadbalancer"
I0212 19:02:56.833601       1 request.go:1073] Request Body: {"count":15,"lastTimestamp":"2023-02-12T19:02:56Z","message":"Failed to create load balancer k8s-clusterapi-cluster-openstack-mgt-kubeapi: Bad request with: [POST https://SOME-OPENSTACK-URL.com:9876/v2.0/lbaas/loadbalancers], error message: {\"faultcode\": \"Client\", \"faultstring\": \"Provider 'amphora' is not enabled.\", \"debuginfo\": null}"}

I believe the issue is in the POST not providing the key provider correctly. https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/61a1650d39faba33348f7a57ccca4f7868ff1d05/pkg/cloud/services/loadbalancer/loadbalancer.go#L170-L177

Adding the following to octavia.conf file fixes this issue.

[api_settings]
bind_host = 10.30.0.4
bind_port = 9876
enabled_provider_drivers = amphora:Amphora provider, ovn:OVN provider
default_provider_driver = ovn

Additionally, Per OVN docs, flag LBMethodRoundRobin, is not a valid function that is currently supported.

Docs

ISSUE: (value is not configurable): https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/61a1650d39faba33348f7a57ccca4f7868ff1d05/pkg/cloud/services/loadbalancer/loadbalancer.go#L318

ERROR:

I0212 19:30:12.521139       1 http.go:143] "controller-runtime/webhook/webhooks: wrote response" webhook="/validate-infrastructure-cluster-x-k8s-io-v1alpha6-openstackcluster" code=200 reason= UID=c9df0d5b-58b3-4b51-bb33-810c9619658f allowed=true
E0212 19:30:12.532814       1 controller.go:326] "Reconciler error" err=<
    failed to reconcile load balancer: Expected HTTP response code [201 202] when accessing [POST https:///SOME-OPENSTACK-URL.comx:9876/v2.0/lbaas/pools], but got 501 instead
    {"faultcode": "Server", "faultstring": "Provider 'ovn' does not support a requested option: OVN provider does not support ROUND_ROBIN algorithm", "debuginfo": null}

Seems something would need to be done to automatically detect the feature flag is being used and change the option to LBMethodSourceIp, preferably this would be a flag that can be changed via a CRD option, verus a flag that cannot be dynamically changed.OpenStackCluster.spec.apiServerLoadBalancer.provider

Example CRD:

apiVersion: infrastructure.cluster.x-k8s.io/v1alpha6
kind: OpenStackCluster
metadata:
  name: mgt
  namespace: openstack
spec:
  apiServerLoadBalancer:
    enabled: true
    provider: ovn

What did you expect to happen: When lb-provider=ovn is enabled users will be able to create clusters properly.

Environment:

Jeremy-Boyle commented 1 year ago

/kind bug

Jeremy-Boyle commented 1 year ago

Can we cut a release for this @ching-kuo

ching-kuo commented 1 year ago

I'm not handling the release. @mdbooth Is there any plan on when the next version will be release? Thanks!

mdbooth commented 1 year ago

It could be a while, I'm afraid: we have multiple backwards-incompatible API changes incoming.

I've added it to the agenda of today's office hours meeting: https://docs.google.com/document/d/1hzi6nr04mhQYBKrwL2NDTNPvgI4RgO9a-gqmk31kXMA/edit#

Jeremy-Boyle commented 1 year ago

Thanks for the update @mdbooth ,

Maybe a Release Candidate might be appropriate. Ill take a look at the nightly builds for the time being, I would really like to implement these changes.

ching-kuo commented 1 year ago

@Jeremy-Boyle FYI, there's a discussion on slack about OVN releases. Looks like @mkjpryor is working on back porting the changes to v1alpha6.

https://kubernetes.slack.com/archives/CFKJB65G9/p1682078907625039

Jeremy-Boyle commented 1 year ago

Backport work:

https://github.com/kubernetes-sigs/cluster-api-provider-openstack/pull/1529

https://github.com/kubernetes-sigs/cluster-api-provider-openstack/pull/1530