Skip to content

Commit 219b4b7

Browse files
authored
Release 2.0.0 (#72)
Compatible release of operator for Netris Controller v3.1
1 parent 2a088b6 commit 219b4b7

26 files changed

+136
-425
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ Netris Operator managing resources samples are available in the `samples/` [fold
3232
| Operator version | Controller version |
3333
| -----------------| -------------------|
3434
| `v0.X` | `v2.9.X` |
35-
| `v1.X` | `v3.X` |
35+
| `v1.X` | `v3.0.X` |
36+
| `v2.X` | `v3.1.X` |
37+
3638

3739
## Features
3840
* Managing Netris Controller via CRD

api/v1alpha1/vnet_types.go

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ type VNetSpec struct {
8181

8282
GuestTenants []string `json:"guestTenants"`
8383
Sites []VNetSite `json:"sites"`
84+
VlanID string `json:"vlanId,omitempty"`
8485
}
8586

8687
// VNetSite .

api/v1alpha1/vnetmeta_types.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type VNetMetaSpec struct {
4141
VaMode bool `json:"vaMode"`
4242
VaNativeVLAN int `json:"vaNativeVlan"`
4343
VaVLANs string `json:"vaVlans"`
44+
VlanID string `json:"vlanid"`
4445
}
4546

4647
// VNetMetaSite .
@@ -51,15 +52,12 @@ type VNetMetaSite struct {
5152

5253
// VNetMetaMember .
5354
type VNetMetaMember struct {
54-
ChildPort int `json:"childPort"`
55-
LACP string `json:"lacp"`
56-
MemberState string `json:"member_state"`
57-
ParentPort int `json:"parentPort"`
58-
PortIsUntagged bool `json:"portIsUntagged"`
59-
PortID int `json:"port_id"`
60-
PortName string `json:"port_name"`
61-
TenantID int `json:"tenant_id"`
62-
VLANID int `json:"vlan_id"`
55+
Name string `json:"name"`
56+
Access bool `json:"access"`
57+
ID int `json:"id"`
58+
Lacp string `json:"lacp"`
59+
State string `json:"state"`
60+
Vlan string `json:"vlan"`
6361
}
6462

6563
// VNetMetaGateway .

config/crd/bases/k8s.netris.ai_vnetmeta.yaml

+15-21
Original file line numberDiff line numberDiff line change
@@ -65,34 +65,25 @@ spec:
6565
items:
6666
description: VNetMetaMember .
6767
properties:
68-
childPort:
68+
access:
69+
type: boolean
70+
id:
6971
type: integer
7072
lacp:
7173
type: string
72-
member_state:
74+
name:
7375
type: string
74-
parentPort:
75-
type: integer
76-
port_id:
77-
type: integer
78-
port_name:
76+
state:
77+
type: string
78+
vlan:
7979
type: string
80-
portIsUntagged:
81-
type: boolean
82-
tenant_id:
83-
type: integer
84-
vlan_id:
85-
type: integer
8680
required:
87-
- childPort
81+
- access
82+
- id
8883
- lacp
89-
- member_state
90-
- parentPort
91-
- portIsUntagged
92-
- port_id
93-
- port_name
94-
- tenant_id
95-
- vlan_id
84+
- name
85+
- state
86+
- vlan
9687
type: object
9788
type: array
9889
name:
@@ -125,6 +116,8 @@ spec:
125116
type: integer
126117
vaVlans:
127118
type: string
119+
vlanid:
120+
type: string
128121
vnetGeneration:
129122
format: int64
130123
type: integer
@@ -145,6 +138,7 @@ spec:
145138
- vaMode
146139
- vaNativeVlan
147140
- vaVlans
141+
- vlanid
148142
- vnetGeneration
149143
- vnetName
150144
type: object

config/crd/bases/k8s.netris.ai_vnets.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ spec:
107107
- active
108108
- disabled
109109
type: string
110+
vlanId:
111+
type: string
110112
required:
111113
- guestTenants
112114
- ownerTenant

controllers/allocation_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func (r *AllocationReconciler) deleteAllocation(allocation *k8sv1alpha1.Allocati
182182
if err != nil {
183183
return ctrl.Result{}, err
184184
}
185-
if !resp.IsSuccess && resp.Meta.StatusCode != 400 {
185+
if !resp.IsSuccess && resp.Meta.StatusCode != 404 {
186186
return ctrl.Result{}, fmt.Errorf("{deleteAllocation} %s", fmt.Errorf(resp.Message))
187187
}
188188
}

controllers/allocationmeta_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (r *AllocationMetaReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err
129129
}
130130
logger.Info("Allocation Created")
131131
} else {
132-
if apiAllocation, ok := r.NStorage.SubnetsStorage.FindByID(allocationMeta.Spec.ID); ok {
132+
if apiAllocation, ok := r.NStorage.SubnetsStorage.FindByID(allocationMeta.Spec.ID, "allocation"); ok {
133133

134134
debugLogger.Info("Comparing AllocationMeta with Netris Allocation")
135135
if ok := compareAllocationMetaAPIEAllocation(allocationMeta, apiAllocation, u); ok {

controllers/api_handler.go

+18-28
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ package controllers
1818

1919
import (
2020
"fmt"
21+
"strconv"
2122
"time"
2223

2324
k8sv1alpha1 "github.com/netrisai/netris-operator/api/v1alpha1"
2425
"github.com/netrisai/netris-operator/configloader"
2526
"github.com/netrisai/netris-operator/netrisstorage"
26-
"github.com/netrisai/netriswebapi/v1/types/vnet"
27+
"github.com/netrisai/netriswebapi/v2/types/vnet"
2728
)
2829

2930
func init() {
@@ -35,15 +36,11 @@ func init() {
3536

3637
func (r *VNetReconciler) getPortsMeta(portNames []k8sv1alpha1.VNetSwitchPort) ([]k8sv1alpha1.VNetMetaMember, error) {
3738
members := []k8sv1alpha1.VNetMetaMember{}
38-
hwPorts := make(map[string]*vnet.VNetMember)
39-
portIsUntagged := false
39+
hwPorts := make(map[string]*vnet.VNetAddPort)
4040
for _, port := range portNames {
41-
vlanID := 1
42-
if port.VlanID > 0 {
43-
vlanID = port.VlanID
44-
}
45-
if vlanID == 1 {
46-
portIsUntagged = true
41+
vlanID := "1"
42+
if port.VlanID > 1 {
43+
vlanID = strconv.Itoa(port.VlanID)
4744
}
4845

4946
state := "active"
@@ -53,37 +50,30 @@ func (r *VNetReconciler) getPortsMeta(portNames []k8sv1alpha1.VNetSwitchPort) ([
5350
}
5451
}
5552

56-
hwPorts[port.Name] = &vnet.VNetMember{
57-
VLANID: vlanID,
58-
PortIsUntagged: portIsUntagged,
59-
MemberState: state,
53+
hwPorts[port.Name] = &vnet.VNetAddPort{
54+
Vlan: vlanID,
55+
Lacp: "off",
56+
State: state,
6057
}
6158

6259
}
6360
for portName := range hwPorts {
6461
if port, yes := r.NStorage.PortsStorage.FindByName(portName); yes {
65-
hwPorts[portName].PortID = port.ID
66-
hwPorts[portName].PortName = portName
67-
hwPorts[portName].TenantID = port.Tenant.ID
68-
hwPorts[portName].LACP = "off"
69-
hwPorts[portName].ParentPort = port.ParentPort
70-
// hwPorts[portName].Name = port.SlavePortName
62+
hwPorts[portName].ID = port.ID
63+
hwPorts[portName].Name = portName
64+
hwPorts[portName].Lacp = "off"
7165
} else {
7266
return members, fmt.Errorf("port '%s' not found", portName)
7367
}
7468
}
7569

7670
for _, member := range hwPorts {
7771
members = append(members, k8sv1alpha1.VNetMetaMember{
78-
ChildPort: member.ChildPort,
79-
LACP: member.LACP,
80-
MemberState: member.MemberState,
81-
ParentPort: member.ParentPort,
82-
PortIsUntagged: member.PortIsUntagged,
83-
PortID: member.PortID,
84-
PortName: member.PortName,
85-
TenantID: member.TenantID,
86-
VLANID: member.VLANID,
72+
Name: member.Name,
73+
Lacp: member.Lacp,
74+
State: member.State,
75+
ID: member.ID,
76+
Vlan: member.Vlan,
8777
})
8878
}
8979
return members, nil

controllers/controller_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func (r *ControllerReconciler) deleteController(controller *k8sv1alpha1.Controll
185185
if err != nil {
186186
return ctrl.Result{}, err
187187
}
188-
if !resp.IsSuccess && resp.Meta.StatusCode != 400 {
188+
if !resp.IsSuccess && resp.Meta.StatusCode != 404 {
189189
return ctrl.Result{}, fmt.Errorf("{deleteController} %s", fmt.Errorf(resp.Message))
190190
}
191191
}

controllers/l4lb_translations.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
"strings"
2525

2626
k8sv1alpha1 "github.com/netrisai/netris-operator/api/v1alpha1"
27-
"github.com/netrisai/netriswebapi/v1/types/l4lb"
2827
"github.com/netrisai/netriswebapi/v2/types/ipam"
28+
"github.com/netrisai/netriswebapi/v2/types/l4lb"
2929
"github.com/r3labs/diff/v2"
3030
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3131
)
@@ -324,7 +324,6 @@ func L4LBMetaToNetrisUpdate(l4lbMeta *k8sv1alpha1.L4LBMeta) (*l4lb.LoadBalancerU
324324
}
325325

326326
l4lbUpdate := &l4lb.LoadBalancerUpdate{
327-
ID: l4lbMeta.Spec.ID,
328327
Name: l4lbMeta.Spec.L4LBName,
329328
TenantID: l4lbMeta.Spec.Tenant,
330329
SiteID: l4lbMeta.Spec.SiteID,

controllers/l4lbmeta_controller.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ import (
3333
k8sv1alpha1 "github.com/netrisai/netris-operator/api/v1alpha1"
3434
"github.com/netrisai/netris-operator/netrisstorage"
3535
"github.com/netrisai/netriswebapi/http"
36-
"github.com/netrisai/netriswebapi/v1/types/l4lb"
3736
api "github.com/netrisai/netriswebapi/v2"
37+
"github.com/netrisai/netriswebapi/v2/types/l4lb"
3838
)
3939

4040
// L4LBMetaReconciler reconciles a L4LBMeta object
@@ -151,7 +151,7 @@ func (r *L4LBMetaReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
151151
logger.Error(fmt.Errorf("{VnetMetaToNetrisUpdate} %s", err), "")
152152
return u.patchL4LBStatus(l4lbCR, "Failure", err.Error())
153153
}
154-
if _, err, errMsg := r.updateL4LB(l4lbUpdate); err != nil {
154+
if _, err, errMsg := r.updateL4LB(l4lbMeta.Spec.ID, l4lbUpdate); err != nil {
155155
logger.Error(fmt.Errorf("{updateL4LB} %s", err), "")
156156
return u.patchL4LBStatus(l4lbCR, "Failure", errMsg.Error())
157157
}
@@ -225,8 +225,8 @@ func (r *L4LBMetaReconciler) createL4LB(l4lbMeta *k8sv1alpha1.L4LBMeta) (ctrl.Re
225225
return ctrl.Result{}, nil, nil
226226
}
227227

228-
func (r *L4LBMetaReconciler) updateL4LB(l4lb *l4lb.LoadBalancerUpdate) (ctrl.Result, error, error) {
229-
reply, err := r.Cred.L4LB().Update(l4lb)
228+
func (r *L4LBMetaReconciler) updateL4LB(id int, l4lb *l4lb.LoadBalancerUpdate) (ctrl.Result, error, error) {
229+
reply, err := r.Cred.L4LB().Update(id, l4lb)
230230
if err != nil {
231231
return ctrl.Result{}, fmt.Errorf("{updateL4LB} %s", err), err
232232
}

controllers/site_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func (r *SiteReconciler) deleteSite(site *k8sv1alpha1.Site, siteMeta *k8sv1alpha
177177
if err != nil {
178178
return ctrl.Result{}, err
179179
}
180-
if !resp.IsSuccess {
180+
if !resp.IsSuccess && resp.Meta.StatusCode != 404 {
181181
return ctrl.Result{}, fmt.Errorf("{deleteSite} %s", fmt.Errorf(resp.Message))
182182
}
183183
}

controllers/softgate_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func (r *SoftgateReconciler) deleteSoftgate(softgate *k8sv1alpha1.Softgate, soft
185185
if err != nil {
186186
return ctrl.Result{}, err
187187
}
188-
if !resp.IsSuccess && resp.Meta.StatusCode != 400 {
188+
if !resp.IsSuccess && resp.Meta.StatusCode != 404 {
189189
return ctrl.Result{}, fmt.Errorf("{deleteSoftgate} %s", fmt.Errorf(resp.Message))
190190
}
191191
}

controllers/subnet_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func (r *SubnetReconciler) deleteSubnet(subnet *k8sv1alpha1.Subnet, subnetMeta *
182182
if err != nil {
183183
return ctrl.Result{}, err
184184
}
185-
if !resp.IsSuccess && resp.Meta.StatusCode != 400 {
185+
if !resp.IsSuccess && resp.Meta.StatusCode != 404 {
186186
return ctrl.Result{}, fmt.Errorf("{deleteSubnet} %s", fmt.Errorf(resp.Message))
187187
}
188188
}

controllers/subnetmeta_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (r *SubnetMetaReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)
132132
}
133133
logger.Info("Subnet Created")
134134
} else {
135-
if apiSubnet, ok := r.NStorage.SubnetsStorage.FindByID(subnetMeta.Spec.ID); ok {
135+
if apiSubnet, ok := r.NStorage.SubnetsStorage.FindByID(subnetMeta.Spec.ID, "subnet"); ok {
136136
debugLogger.Info("Comparing SubnetMeta with Netris Subnet")
137137
if ok := compareSubnetMetaAPIESubnet(subnetMeta, apiSubnet, u); ok {
138138
debugLogger.Info("Nothing Changed")

controllers/switch_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func (r *SwitchReconciler) deleteSwitch(switchH *k8sv1alpha1.Switch, switchMeta
185185
if err != nil {
186186
return ctrl.Result{}, err
187187
}
188-
if !resp.IsSuccess && resp.Meta.StatusCode != 400 {
188+
if !resp.IsSuccess && resp.Meta.StatusCode != 404 {
189189
return ctrl.Result{}, fmt.Errorf("{deleteSwitch} %s", fmt.Errorf(resp.Message))
190190
}
191191
}

0 commit comments

Comments
 (0)