Skip to content

Commit 716446e

Browse files
committed
Revert "wip"
This reverts commit c7807ca.
1 parent 1742abd commit 716446e

File tree

5 files changed

+12
-274
lines changed

5 files changed

+12
-274
lines changed

pkg/client/client.go

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -65,68 +65,6 @@ func (a *IONOSClient) GetServer(ctx context.Context, providerID string) (*cloudp
6565
return a.convertServerToInstanceMetadata(ctx, &server)
6666
}
6767

68-
func (a *IONOSClient) AttachIPToNode(ctx context.Context, loadBalancerIP, providerID string) (bool, error) {
69-
if a.client == nil {
70-
return false, errors.New("client isn't initialized")
71-
}
72-
73-
serverReq := a.client.NetworkInterfacesApi.DatacentersServersNicsGet(ctx, a.DatacenterId, providerID)
74-
nics, req, err := serverReq.Depth(3).Execute()
75-
if req != nil && req.StatusCode == 404 {
76-
return false, err
77-
}
78-
79-
if !nics.HasItems() {
80-
return false, nil
81-
}
82-
83-
primaryNic := (*nics.Items)[0]
84-
ips := *primaryNic.Properties.Ips
85-
ips = append(ips, loadBalancerIP)
86-
87-
_, _, err = a.client.NetworkInterfacesApi.DatacentersServersNicsPatch(ctx, a.DatacenterId, providerID, *primaryNic.Id).Nic(ionoscloud.NicProperties{
88-
Ips: &ips,
89-
}).Execute()
90-
91-
return err != nil, err
92-
}
93-
94-
func (a *IONOSClient) GetServerByIP(ctx context.Context, loadBalancerIP string) (*string, error) {
95-
if a.client == nil {
96-
return nil, errors.New("client isn't initialized")
97-
}
98-
99-
serverReq := a.client.ServersApi.DatacentersServersGet(ctx, a.DatacenterId)
100-
servers, req, err := serverReq.Depth(3).Execute()
101-
if err != nil || req != nil && req.StatusCode == 404 {
102-
if err != nil {
103-
return nil, nil
104-
}
105-
return nil, err
106-
}
107-
108-
if !servers.HasItems() {
109-
return nil, nil
110-
}
111-
112-
for _, server := range *servers.Items {
113-
if !server.Entities.HasNics() {
114-
continue
115-
}
116-
for _, nic := range *server.Entities.Nics.Items {
117-
if nic.Properties.HasIps() {
118-
for _, ip := range *nic.Properties.Ips {
119-
if loadBalancerIP == ip {
120-
return server.Properties.Name, nil
121-
}
122-
}
123-
}
124-
}
125-
}
126-
127-
return nil, nil
128-
}
129-
13068
func (a *IONOSClient) datacenterLocation(ctx context.Context) (string, error) {
13169
if a.client == nil {
13270
return "", errors.New("client isn't initialized")

pkg/ionos/cloud.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,19 @@ func newProvider(config config.Config) cloudprovider.Interface {
3434
return IONOS{
3535
config: config,
3636
instances: instances{
37-
ionosClients: map[string]*client2.IONOSClient{},
38-
},
39-
loadbalancer: loadbalancer{
40-
ionosClients: map[string]*client2.IONOSClient{},
37+
clients: map[string]*client2.IONOSClient{},
4138
},
4239
}
4340
}
4441

4542
func (p IONOS) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, _ <-chan struct{}) {
4643
ctx := context.Background()
47-
k8sClient, err := clientBuilder.Client(config.ClientName)
44+
client, err := clientBuilder.Client(config.ClientName)
4845
if err != nil {
4946
klog.Errorf("Kubernetes Client Init Failed: %v", err)
5047
return
5148
}
52-
secret, err := k8sClient.CoreV1().Secrets(p.config.TokenSecretNamespace).Get(ctx, p.config.TokenSecretName, metav1.GetOptions{})
49+
secret, err := client.CoreV1().Secrets(p.config.TokenSecretNamespace).Get(ctx, p.config.TokenSecretName, metav1.GetOptions{})
5350
if err != nil {
5451
klog.Errorf("Failed to get secret %s/%s: %v", p.config.TokenSecretNamespace, p.config.TokenSecretName, err)
5552
return
@@ -61,17 +58,12 @@ func (p IONOS) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, _
6158
klog.Errorf("Failed to create client for datacenter %s: %v", key, err)
6259
return
6360
}
64-
65-
err = p.loadbalancer.AddClient(key, token)
66-
if err != nil {
67-
klog.Errorf("Failed to create client for datacenter %s: %v", key, err)
68-
return
69-
}
7061
}
7162
}
7263

7364
func (p IONOS) LoadBalancer() (cloudprovider.LoadBalancer, bool) {
74-
return p.loadbalancer, true
65+
klog.Warning("The IONOS cloud provider does not support load balancers")
66+
return nil, false
7567
}
7668

7769
func (p IONOS) Instances() (cloudprovider.Instances, bool) {

pkg/ionos/instances.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ func GetUUIDFromNode(node *v1.Node) string {
2323
}
2424

2525
func (i instances) AddClient(datacenterId string, token []byte) error {
26-
if i.ionosClients[datacenterId] == nil {
26+
if i.clients[datacenterId] == nil {
2727
c, err := client2.New(datacenterId, token)
2828
if err != nil {
2929
return err
3030
}
31-
i.ionosClients[datacenterId] = &c
31+
i.clients[datacenterId] = &c
3232
}
3333
return nil
3434
}
3535

3636
// no caching
3737
func (i instances) discoverNode(ctx context.Context, node *v1.Node) (*cloudprovider.InstanceMetadata, error) {
38-
for _, client := range i.ionosClients {
38+
for _, client := range i.clients {
3939
var err error
4040
var server *cloudprovider.InstanceMetadata
4141
providerID := GetUUIDFromNode(node)

pkg/ionos/loadbalancer.go

Lines changed: 0 additions & 187 deletions
This file was deleted.

pkg/ionos/types.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@ import (
66
)
77

88
type IONOS struct {
9-
config config.Config
10-
instances instances
11-
loadbalancer loadbalancer
12-
client *client.IONOSClient
9+
config config.Config
10+
instances instances
11+
client *client.IONOSClient
1312
}
1413

1514
type instances struct {
16-
ionosClients map[string]*client.IONOSClient
17-
}
18-
19-
type loadbalancer struct {
20-
ionosClients map[string]*client.IONOSClient
15+
clients map[string]*client.IONOSClient
2116
}

0 commit comments

Comments
 (0)