Skip to content

Commit 1f85460

Browse files
Janraj CJJanraj CJ
authored andcommitted
Citrix Node Controller Version 2.0.0
1 parent ad308ed commit 1f85460

File tree

4 files changed

+33
-32
lines changed

4 files changed

+33
-32
lines changed

build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ COPY version/ version
55
COPY vendor/ vendor
66
RUN go build -o /go/bin/citrix-node-controller ./cmd/citrix-node-controller/
77

8-
FROM quay.io/chorus/chorus-kube-router:latest
8+
FROM quay.io/chorus/chorus-kube-router:1.8.0
99
COPY --from=builder /go/bin/citrix-node-controller /go/bin/citrix-node-controller
1010
COPY build/start.sh /go/bin/start.sh
1111
RUN ["chmod", "+x", "/go/bin/start.sh"]

cmd/citrix-node-controller/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
func InitCitrixNodeController() error {
88
klog.InitFlags(nil)
9-
klog.Info("Initializing CNC")
9+
klog.Info("[INFO] Initializing CNC")
1010
InitPrefixMaskTable()
1111
return nil
1212
}

cmd/citrix-node-controller/netScalerInterface.go

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func createResponseHandler(resp *http.Response) ([]byte, error) {
6060
"404 Not Found", "405 Method Not Allowed", "406 Not Acceptable",
6161
"503 Service Unavailable", "599 Netscaler specific error":
6262
body, _ := ioutil.ReadAll(resp.Body)
63-
klog.Info("[INFO] go-nitro: error = " + string(body))
63+
klog.Info("[INFO] GO-NITRO: error = " + string(body))
6464
return body, errors.New("failed: " + resp.Status + " (" + string(body) + ")")
6565
default:
6666
body, err := ioutil.ReadAll(resp.Body)
@@ -97,19 +97,19 @@ func (c *NitroClient) doHTTPRequest(method string, url string, bytes *bytes.Buff
9797
if err != nil {
9898
return []byte{}, err
9999
}
100-
klog.Info("[DEBUG] go-nitro: response Status:", resp.Status)
100+
klog.Info("[DEBUG] GO-NITRO: response Status:", resp.Status)
101101
return respHandler(resp)
102102
}
103103

104104
func (c *NitroClient) createResource(resourceType string, resourceJSON []byte, operation string) ([]byte, error) {
105-
klog.Info("[DEBUG] go-nitro: Creating resource of type ", resourceType)
105+
klog.Info("[DEBUG] GO-NITRO: Creating resource of type ", resourceType)
106106
url := c.url + resourceType
107107
if operation == "unset" {
108108
url = url + "?action=unset"
109109
} else if strings.Contains(resourceType, "netprofile") {
110110
url = url + "?idempotent=yes"
111111
}
112-
klog.Info("[TRACE] go-nitro: url is ", url)
112+
klog.Info("[TRACE] GO-NITRO: url is ", url)
113113
return c.doHTTPRequest("POST", url, bytes.NewBuffer(resourceJSON), createResponseHandler)
114114
}
115115

@@ -120,14 +120,14 @@ func (c *NitroClient) AddResource(resourceType string, name string, resourceStru
120120

121121
resourceJSON, err := JSONMarshal(nsResource)
122122
if err != nil {
123-
return "", fmt.Errorf("[ERROR] go-nitro: Failed to create resource of type %s, name=%s, err=%s", resourceType, name, err)
123+
return "", fmt.Errorf("[ERROR] GO-NITRO: Failed to create resource of type %s, name=%s, err=%s", resourceType, name, err)
124124
}
125125

126-
klog.Info("[TRACE] go-nitro: Resourcejson is " + string(resourceJSON))
126+
klog.Info("[TRACE] GO-NITRO: Resourcejson is " + string(resourceJSON))
127127

128128
body, err := c.createResource(resourceType, resourceJSON, operation)
129129
if err != nil {
130-
return "", fmt.Errorf("[ERROR] go-nitro: Failed to create resource of type %s, name=%s, err=%s", resourceType, name, err)
130+
return "", fmt.Errorf("[ERROR] GO-NITRO: Failed to create resource of type %s, name=%s, err=%s", resourceType, name, err)
131131
}
132132
_ = body
133133

@@ -260,6 +260,7 @@ func NsInterfaceAddRoute(client *NitroClient, input *ControllerInput, node *Node
260260

261261
func NsInterfaceDeleteRoute(client *NitroClient, nodeinfo *Node) {
262262
var argsBundle = map[string]string{"network": nodeinfo.PodNetwork, "netmask": nodeinfo.PodNetMask, "gateway": nodeinfo.PodAddress}
263+
263264
err2 := client.DeleteResourceWithArgsMap("route", "", argsBundle)
264265
if err2 != nil {
265266
fmt.Println(err2)
@@ -281,27 +282,27 @@ func (c *NitroClient) DeleteResourceWithArgsMap(resourceType string, resourceNam
281282

282283
_, err := c.listResourceWithArgsMap(resourceType, resourceName, args)
283284
if err == nil { // resource exists
284-
klog.Infof("[INFO] go-nitro: DeleteResource found resource of type %s: %s", resourceType, resourceName)
285+
klog.Infof("[INFO] GO-NITRO: DeleteResource found resource of type %s: %s", resourceType, resourceName)
285286
_, err = c.deleteResourceWithArgsMap(resourceType, resourceName, args)
286287
if err != nil {
287-
klog.Errorf("[ERROR] go-nitro: Failed to delete resourceType %s: %s, err=%s", resourceType, resourceName, err)
288+
klog.Errorf("[ERROR] GO-NITRO: Failed to delete resourceType %s: %s, err=%s", resourceType, resourceName, err)
288289
return err
289290
}
290291
} else {
291-
klog.Infof("[INFO] go-nitro: Resource %s already deleted ", resourceName)
292+
klog.Infof("[INFO] GO-NITRO: Resource %s already deleted ", resourceName)
292293
}
293294
return nil
294295
}
295296
func (c *NitroClient) deleteResourceWithArgs(resourceType string, resourceName string, args []string) ([]byte, error) {
296-
klog.Info("[DEBUG] go-nitro: Deleting resource of type ", resourceType, "with args ", args)
297+
klog.Info("[DEBUG] GO-NITRO: Deleting resource of type ", resourceType, "with args ", args)
297298
var url string
298299
if resourceName != "" {
299300
url = c.url + fmt.Sprintf("%s/%s?args=", resourceType, resourceName)
300301
} else {
301302
url = c.url + fmt.Sprintf("%s?args=", resourceType)
302303
}
303304
url = url + strings.Join(args, ",")
304-
klog.Info("[TRACE] go-nitro: url is ", url)
305+
klog.Info("[TRACE] GO-NITRO: url is ", url)
305306

306307
return c.doHTTPRequest("DELETE", url, bytes.NewBuffer([]byte{}), deleteResponseHandler)
307308

@@ -328,7 +329,7 @@ func (c *NitroClient) listResourceWithArgsMap(resourceType string, resourceName
328329

329330
}
330331
func (c *NitroClient) listResourceWithArgs(resourceType string, resourceName string, args []string) ([]byte, error) {
331-
klog.Info("[DEBUG] go-nitro: listing resource of type ", resourceType, ", name: ", resourceName, ", args:", args)
332+
klog.Info("[DEBUG] GO-NITRO: listing resource of type ", resourceType, ", name: ", resourceName, ", args:", args)
332333
var url string
333334

334335
if resourceName != "" {
@@ -338,11 +339,11 @@ func (c *NitroClient) listResourceWithArgs(resourceType string, resourceName str
338339
}
339340
strArgs := strings.Join(args, ",")
340341
url2 := url + "?args=" + strArgs
341-
klog.Info("[TRACE] go-nitro: url is ", url)
342+
klog.Info("[TRACE] GO-NITRO: url is ", url)
342343

343344
data, err := c.doHTTPRequest("GET", url2, bytes.NewBuffer([]byte{}), readResponseHandler)
344345
if err != nil {
345-
klog.Info("[DEBUG] go-nitro: error listing with args, trying filter")
346+
klog.Info("[DEBUG] GO-NITRO: error listing with args, trying filter")
346347
url2 = url + "?filter=" + strArgs
347348
return c.doHTTPRequest("GET", url2, bytes.NewBuffer([]byte{}), readResponseHandler)
348349
}
@@ -356,17 +357,17 @@ func readResponseHandler(resp *http.Response) ([]byte, error) {
356357
return body, nil
357358
case "404 Not Found":
358359
body, _ := ioutil.ReadAll(resp.Body)
359-
klog.Info("[DEBUG] go-nitro: read: 404 not found")
360-
return body, errors.New("go-nitro: read: 404 not found: ")
360+
klog.Info("[DEBUG] GO-NITRO: read: 404 not found")
361+
return body, errors.New("GO-NITRO: read: 404 not found: ")
361362
case "400 Bad Request", "401 Unauthorized", "403 Forbidden",
362363
"405 Method Not Allowed", "406 Not Acceptable",
363364
"409 Conflict", "503 Service Unavailable", "599 Netscaler specific error":
364365
body, _ := ioutil.ReadAll(resp.Body)
365-
klog.Info("[INFO] go-nitro: read: error = " + string(body))
366-
return body, errors.New("[INFO] go-nitro: failed read: " + resp.Status + " (" + string(body) + ")")
366+
klog.Info("[INFO] GO-NITRO: read: error = " + string(body))
367+
return body, errors.New("[INFO] GO-NITRO: failed read: " + resp.Status + " (" + string(body) + ")")
367368
default:
368369
body, err := ioutil.ReadAll(resp.Body)
369-
klog.Info("[INFO] go-nitro: read error = " + string(body))
370+
klog.Info("[INFO] GO-NITRO: read error = " + string(body))
370371
return body, err
371372

372373
}
@@ -381,7 +382,7 @@ func deleteResponseHandler(resp *http.Response) ([]byte, error) {
381382
"405 Method Not Allowed", "406 Not Acceptable",
382383
"409 Conflict", "503 Service Unavailable", "599 Netscaler specific error":
383384
body, _ := ioutil.ReadAll(resp.Body)
384-
klog.Info("[INFO] go-nitro: delete: error = " + string(body))
385+
klog.Info("[INFO] GO-NITRO: delete: error = " + string(body))
385386
return body, errors.New("[INFO] delete failed: " + resp.Status + " (" + string(body) + ")")
386387
default:
387388
body, err := ioutil.ReadAll(resp.Body)
@@ -397,11 +398,11 @@ func getNetScalerDefaultGateway(IngressDeviceClient *NitroClient) string {
397398

398399
result, err := IngressDeviceClient.doHTTPRequest("GET", url, bytes.NewBuffer([]byte{}), readResponseHandler)
399400
if err != nil {
400-
klog.Info("[DEBUG] go-nitro: error listing with args, trying filter")
401+
klog.Info("[DEBUG] GO-NITRO: error listing with args, trying filter")
401402
return "error"
402403
}
403404
if err = json.Unmarshal(result, &data); err != nil {
404-
klog.Info("[ERROR] go-nitro: FindResourceArray: Failed to unmarshal Netscaler Response!", err, data)
405+
klog.Info("[ERROR] GO-NITRO: FindResourceArray: Failed to unmarshal Netscaler Response!", err, data)
405406
return "error"
406407
}
407408
rsrcs, ok := data["route"]
@@ -427,10 +428,10 @@ func getDefaultDatewayInterface(IngressDeviceClient *NitroClient, gateway string
427428

428429
result, err := IngressDeviceClient.doHTTPRequest("GET", url, bytes.NewBuffer([]byte{}), readResponseHandler)
429430
if err != nil {
430-
log.Println("[DEBUG] go-nitro: error listing with args, trying filter")
431+
log.Println("[DEBUG] GO-NITRO: error listing with args, trying filter")
431432
}
432433
if err = json.Unmarshal(result, &arpdata); err != nil {
433-
klog.Info("[ERROR] go-nitro: FindResourceArray: Failed to unmarshal Netscaler Response!", err, arpdata)
434+
klog.Info("[ERROR] GO-NITRO: FindResourceArray: Failed to unmarshal Netscaler Response!", err, arpdata)
434435
return "error"
435436
}
436437
rsrcs, ok := arpdata["arp"]
@@ -456,10 +457,10 @@ func getInterfaceMac(IngressDeviceClient *NitroClient, ifnum string) string {
456457

457458
result, err := IngressDeviceClient.doHTTPRequest("GET", url, bytes.NewBuffer([]byte{}), readResponseHandler)
458459
if err != nil {
459-
log.Println("[DEBUG] go-nitro: error listing with args, trying filter")
460+
log.Println("[DEBUG] GO-NITRO: error listing with args, trying filter")
460461
}
461462
if err = json.Unmarshal(result, &ifdata); err != nil {
462-
klog.Info("[ERROR] go-nitro: FindResourceArray: Failed to unmarshal Netscaler Response!", err, ifdata)
463+
klog.Info("[ERROR] GO-NITRO: FindResourceArray: Failed to unmarshal Netscaler Response!", err, ifdata)
463464
return "error"
464465
}
465466
rsrcs, ok := ifdata["Interface"]
@@ -497,10 +498,10 @@ func getPrimaryNodeIP(IngressDeviceClient *NitroClient) string {
497498

498499
result, err := IngressDeviceClient.doHTTPRequest("GET", url, bytes.NewBuffer([]byte{}), readResponseHandler)
499500
if err != nil {
500-
log.Println("[DEBUG] go-nitro: error listing with args, trying filter")
501+
log.Println("[DEBUG] GO-NITRO: error listing with args, trying filter")
501502
}
502503
if err = json.Unmarshal(result, &hanode); err != nil {
503-
klog.Info("[ERROR] go-nitro: FindResourceArray: Failed to unmarshal Netscaler Response!", err, hanode)
504+
klog.Info("[ERROR] GO-NITRO: FindResourceArray: Failed to unmarshal Netscaler Response!", err, hanode)
504505
return "error"
505506
}
506507
rsrcs, ok := hanode["hanode"]

deploy/citrix-k8s-node-controller.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ spec:
6262
serviceAccountName: citrix-node-controller
6363
containers:
6464
- name: citrix-node-controller
65-
image: "quay.io/citrix/citrix-k8s-node-controller:beta-v5"
65+
image: "quay.io/citrix/citrix-k8s-node-controller:beta-v7"
6666
imagePullPolicy: Always
6767
env:
6868
- name: NS_IP

0 commit comments

Comments
 (0)