Skip to content

Commit

Permalink
Merge pull request #36 from open-traffic-generator/dev-liveness-check
Browse files Browse the repository at this point in the history
Add liveness check for license server
  • Loading branch information
biplamal authored Jan 17, 2024
2 parents d747a49 + 4f1892f commit cbe46ad
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 24 deletions.
13 changes: 8 additions & 5 deletions controllers/ixiatg_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,6 @@ func (r *IxiaTGReconciler) containersForController(ctx context.Context, ixia *ne
var containers []corev1.Container
var newGNMI bool
var err error
var pbHdlr corev1.ProbeHandler
lic_found := false
lic_container := corev1.Container{}
var lic_server_image, lic_server_secret bool
Expand Down Expand Up @@ -1187,6 +1186,7 @@ func (r *IxiaTGReconciler) containersForController(ctx context.Context, ixia *ne
lic_server_secret = true
}
for key, comp := range componentDep[release].Controller.Containers {
var pbHdlr *corev1.ProbeHandler = nil
if key == IMAGE_LICENSE_SERVER && lic_server_secret {
// Secrets based image takes precedence
continue
Expand Down Expand Up @@ -1222,7 +1222,7 @@ func (r *IxiaTGReconciler) containersForController(ctx context.Context, ixia *ne
}
if name == GNMI_NAME {
tcpSock := corev1.TCPSocketAction{Port: intstr.IntOrString{IntVal: CTRL_GNMI_PORT}}
pbHdlr = corev1.ProbeHandler{TCPSocket: &tcpSock}
pbHdlr = &corev1.ProbeHandler{TCPSocket: &tcpSock}
newGNMI, err = versionLaterOrEqual(GNMI_NEW_BASE_VERSION, comp.Tag)
if err != nil {
log.Error(err)
Expand All @@ -1235,19 +1235,22 @@ func (r *IxiaTGReconciler) containersForController(ctx context.Context, ixia *ne
}
} else if name == CONTROLLER_NAME {
tcpSock := corev1.TCPSocketAction{Port: intstr.IntOrString{IntVal: CTRL_GRPC_PORT}}
pbHdlr = corev1.ProbeHandler{TCPSocket: &tcpSock}
pbHdlr = &corev1.ProbeHandler{TCPSocket: &tcpSock}
if _, ok := resRequest["cpu"]; !ok {
resRequest["cpu"] = resource.MustParse(MIN_CPU_CONTROLLER)
}
if _, ok := resRequest["memory"]; !ok {
resRequest["memory"] = resource.MustParse(MIN_MEM_CONTROLLER)
}
} else if name == LICENSE_NAME {
tcpSock := corev1.TCPSocketAction{Port: intstr.IntOrString{IntVal: CTRL_LICENSE_PORT}}
pbHdlr = &corev1.ProbeHandler{TCPSocket: &tcpSock}
}
container.Resources.Requests = resRequest

if comp.LiveNessEnable == nil || *comp.LiveNessEnable {
if pbHdlr != nil && (comp.LiveNessEnable == nil || *comp.LiveNessEnable) {
probe := corev1.Probe{
ProbeHandler: pbHdlr,
ProbeHandler: *pbHdlr,
InitialDelaySeconds: comp.LiveNessDelay,
PeriodSeconds: comp.LiveNessPeriod,
FailureThreshold: comp.LiveNessFailure,
Expand Down
50 changes: 32 additions & 18 deletions operator-tests/py/default/test_liveness_default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def test_liveness_default_config():
Delete b2b kne topology,
- namespace - 1: ixia-c
Validate,
- default liveness parameters for protocol engines
- default liveness parameters for all ixia-c components
- no flakiness for default deployment of all components
"""
namespace1 = 'ixia-c'
namespace1_config = 'ixia_c_default_config.txt'
Expand All @@ -23,29 +24,42 @@ def test_liveness_default_config():
'-protocol-engine',
'-traffic-engine'
]
lic_path = 'docker-local-athena.artifactory.it.keysight.com/keng-license-server'
lic_tag = '0.0.1-32'
count = 30
try:
op_rscount = utils.get_operator_restart_count()
print("[Namespace:{}]Deploying KNE topology".format(
namespace1
))
utils.create_kne_config(namespace1_config, namespace1)
utils.ixia_c_pods_ok(namespace1, expected_pods)
utils.check_liveness_data('ixia-c', expected_pods[0], namespace1, True, 1, 10, 6)
utils.check_liveness_data('gnmi', expected_pods[0], namespace1, True, 1, 10, 6)
utils.check_liveness_data(expected_pods[1]+container_extensions[0], expected_pods[1], namespace1, True, 1, 10, 6)
utils.check_liveness_data(expected_pods[1]+container_extensions[1], expected_pods[1], namespace1, True, 1, 10, 6)
utils.check_liveness_data(expected_pods[2]+container_extensions[0], expected_pods[2], namespace1, True, 1, 10, 6)
utils.check_liveness_data(expected_pods[2]+container_extensions[1], expected_pods[2], namespace1, True, 1, 10, 6)
op_rscount = utils.ixia_c_operator_ok(op_rscount)
utils.load_license_configmap("", lic_path, lic_tag)
for iter in range(count):
print("Iteration: {}".format(iter))
print("[Namespace:{}]Deploying KNE topology".format(
namespace1
))
utils.create_kne_config(namespace1_config, namespace1)
utils.ixia_c_pods_ok(namespace1, expected_pods)
utils.check_liveness_data('ixia-c', expected_pods[0], namespace1, True, 1, 10, 6)
utils.check_liveness_data('gnmi', expected_pods[0], namespace1, True, 1, 10, 6)
utils.check_liveness_data('license-server', expected_pods[0], namespace1, True, 1, 10, 6)
utils.check_liveness_data(expected_pods[1]+container_extensions[0], expected_pods[1], namespace1, True, 1, 10, 6)
utils.check_liveness_data(expected_pods[1]+container_extensions[1], expected_pods[1], namespace1, True, 1, 10, 6)
utils.check_liveness_data(expected_pods[2]+container_extensions[0], expected_pods[2], namespace1, True, 1, 10, 6)
utils.check_liveness_data(expected_pods[2]+container_extensions[1], expected_pods[2], namespace1, True, 1, 10, 6)
op_rscount = utils.ixia_c_operator_ok(op_rscount)

print("[Namespace:{}]Deleting KNE topology".format(
namespace1
))
utils.delete_kne_config(namespace1_config, namespace1)
utils.ixia_c_pods_ok(namespace1, [])
print("[Namespace:{}]Deleting KNE topology".format(
namespace1
))
utils.delete_kne_config(namespace1_config, namespace1)
utils.ixia_c_pods_ok(namespace1, [])
utils.wait_for(
lambda: utils.topology_deleted(namespace1),
'topology deleted',
timeout_seconds=30
)
op_rscount = utils.ixia_c_operator_ok(op_rscount)

finally:
utils.reset_configmap()
utils.delete_kne_config(namespace1_config, namespace1)
utils.ixia_c_pods_ok(namespace1, [])

Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.14
0.3.15

0 comments on commit cbe46ad

Please sign in to comment.