Skip to content

Commit cac97a6

Browse files
Calico Integration minor fixes (#36)
* fix: bgp: set default transport to 'port' * fix: calico: use patch method for annotating the nodes * preparation for new release Co-authored-by: Artashes Balabekyan <[email protected]>
1 parent 8910574 commit cac97a6

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

calicowatcher/main.go

+24-3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"go.uber.org/zap/zapcore"
3838
v1 "k8s.io/api/core/v1"
3939
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
40+
"k8s.io/apimachinery/pkg/types"
4041
"k8s.io/client-go/kubernetes"
4142
"k8s.io/client-go/rest"
4243
ctrl "sigs.k8s.io/controller-runtime"
@@ -297,7 +298,13 @@ func (w *Watcher) deleteNodesASNs() error {
297298
if as >= w.data.asnStart && as <= w.data.asnEnd {
298299
delete(anns, "projectcalico.org/ASNumber")
299300
node.SetAnnotations(anns)
300-
_, err := w.clientset.CoreV1().Nodes().Update(ctx, node.DeepCopy(), metav1.UpdateOptions{})
301+
payload := []patchStringValue{{
302+
Op: "remove",
303+
Path: "/metadata/annotations/projectcalico.org~1ASNumber",
304+
Value: asn,
305+
}}
306+
payloadBytes, _ := json.Marshal(payload)
307+
_, err := w.clientset.CoreV1().Nodes().Patch(ctx, node.Name, types.JSONPatchType, payloadBytes, metav1.PatchOptions{})
301308
if err != nil {
302309
return err
303310
}
@@ -627,14 +634,21 @@ func (w *Watcher) fillNodesASNs() error {
627634
if !asnMap[asn] {
628635
anns["projectcalico.org/ASNumber"] = asn
629636
node.SetAnnotations(anns)
637+
payload := []patchStringValue{{
638+
Op: "replace",
639+
Path: "/metadata/annotations/projectcalico.org~1ASNumber",
640+
Value: asn,
641+
}}
642+
payloadBytes, _ := json.Marshal(payload)
630643
ctx, cancel := context.WithTimeout(cntxt, contextTimeout)
631-
_, err := w.clientset.CoreV1().Nodes().Update(ctx, node.DeepCopy(), metav1.UpdateOptions{})
644+
_, err := w.clientset.CoreV1().Nodes().Patch(ctx, node.Name, types.JSONPatchType, payloadBytes, metav1.PatchOptions{})
632645
if err != nil {
633646
cancel()
634647
return err
635648
}
636-
cancel()
637649
asnMap[asn] = true
650+
cancel()
651+
break
638652
}
639653
}
640654
} else {
@@ -773,3 +787,10 @@ func (w *Watcher) validateASNRange(asns string) (int, int, error) {
773787

774788
return a, b, nil
775789
}
790+
791+
// patchStringValue specifies a patch operation for a string.
792+
type patchStringValue struct {
793+
Op string `json:"op"`
794+
Path string `json:"path"`
795+
Value string `json:"value"`
796+
}

controllers/bgp_translations.go

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ func (r *BGPReconciler) BGPToBGPMeta(bgp *k8sv1alpha1.BGP) (*k8sv1alpha1.BGPMeta
8181
terminateOnSwitch = "yes"
8282
}
8383

84+
if bgp.Spec.Transport.Type == "" {
85+
bgp.Spec.Transport.Type = "port"
86+
}
87+
8488
if bgp.Spec.Transport.Type == "port" {
8589
if port, ok := r.NStorage.BGPStorage.FindPort(siteID, bgp.Spec.Transport.Name); ok {
8690
portID = port.PortID

deploy/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ All resources are included in a single YAML manifest file:
1111
1) Install the CustomResourceDefinitions and netris-operator itself:
1212

1313
```
14-
kubectl apply -f https://github.com/netrisai/netris-operator/releases/download/v0.4.3/netris-operator.yaml
14+
kubectl apply -f https://github.com/netrisai/netris-operator/releases/download/v0.4.4/netris-operator.yaml
1515
```
1616

1717

deploy/charts/netris-operator/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.3.5
18+
version: 0.3.6
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
23-
appVersion: v0.4.3
23+
appVersion: v0.4.4
2424
home: https://github.com/netrisai/netris-operator
2525
icon: https://www.netris.ai/wp-content/uploads/2020/05/logo-600.png # [todo] Change url to permalink
2626
keywords:

0 commit comments

Comments
 (0)