@@ -52,6 +52,10 @@ en_sync_from_sb_get_input_data(struct engine_node *node,
EN_OVSDB_GET(engine_get_input("SB_port_binding", node));
data->sb_ha_ch_grp_table =
EN_OVSDB_GET(engine_get_input("SB_ha_chassis_group", node));
+ data->sbrec_service_monitor_by_service_type =
+ engine_ovsdb_node_get_index(
+ engine_get_input("SB_service_monitor", node),
+ "sbrec_service_monitor_by_service_type");
}
enum engine_node_state
@@ -7,6 +7,9 @@ struct en_sync_from_sb_data {
/* Southbound table references */
const struct sbrec_port_binding_table *sb_pb_table;
const struct sbrec_ha_chassis_group_table *sb_ha_ch_grp_table;
+
+ /* Indexes */
+ struct ovsdb_idl_index *sbrec_service_monitor_by_service_type;
};
void *en_sync_from_sb_init(struct engine_node *, struct engine_arg *);
@@ -465,6 +465,7 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
sync_from_sb_northd_handler);
engine_add_input(&en_sync_from_sb, &en_sb_port_binding, NULL);
engine_add_input(&en_sync_from_sb, &en_sb_ha_chassis_group, NULL);
+ engine_add_input(&en_sync_from_sb, &en_sb_service_monitor, NULL);
engine_add_input(&en_northd_output, &en_acl_id, NULL);
engine_add_input(&en_northd_output, &en_sync_from_sb, NULL);
@@ -580,6 +581,13 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
"sbrec_service_monitor_by_learned_type",
sbrec_service_monitor_by_learned_type);
+ struct ovsdb_idl_index *sbrec_service_monitor_by_service_type
+ = ovsdb_idl_index_create1(sb->idl,
+ &sbrec_service_monitor_col_type);
+ engine_ovsdb_node_add_index(&en_sb_service_monitor,
+ "sbrec_service_monitor_by_service_type",
+ sbrec_service_monitor_by_service_type);
+
struct ed_type_global_config *global_config =
engine_get_internal_data(&en_global_config);
unixctl_command_register("debug/chassis-features-list", "", 0, 0,
@@ -20809,6 +20809,46 @@ handle_port_binding_changes(
hmapx_destroy(&lr_groups);
}
+static void
+handle_service_monitor_changes(
+ struct ovsdb_idl_index *sbrec_service_monitor_by_service_type,
+ const struct hmap *ls_ports)
+{
+ const struct sbrec_service_monitor *sbrec_mon;
+ struct sbrec_service_monitor *key =
+ sbrec_service_monitor_index_init_row(
+ sbrec_service_monitor_by_service_type);
+
+ sbrec_service_monitor_set_type(key, "logical-switch-port");
+
+ SBREC_SERVICE_MONITOR_FOR_EACH_EQUAL (sbrec_mon, key,
+ sbrec_service_monitor_by_service_type) {
+
+ struct ovn_port *op = ovn_port_find(ls_ports, sbrec_mon->logical_port);
+ if (!op) {
+ continue;
+ }
+
+ ovs_assert(op->nbsp && op->nbsp->n_health_checks);
+
+ for (size_t i = 0; i < op->nbsp->n_health_checks; i++) {
+ const struct nbrec_logical_switch_port_health_check *lsp_hc =
+ op->nbsp->health_checks[i];
+
+ const char *desired_status = sbrec_mon->status;
+ if (desired_status) {
+ if (!lsp_hc->status ||
+ strcmp(lsp_hc->status, desired_status)) {
+ nbrec_logical_switch_port_health_check_set_status(
+ lsp_hc, sbrec_mon->status);
+ }
+ }
+ }
+ }
+
+ sbrec_service_monitor_index_destroy_row(key);
+}
+
/* Handle a fairly small set of changes in the southbound database. */
void
ovnsb_db_run(struct ovsdb_idl_txn *ovnsb_txn,
@@ -20826,6 +20866,11 @@ ovnsb_db_run(struct ovsdb_idl_txn *ovnsb_txn,
&northd_data->lr_ports,
&ha_ref_chassis_map);
+ handle_service_monitor_changes(
+ sync_from_sb_data->sbrec_service_monitor_by_service_type,
+ &northd_data->ls_ports);
+
+
update_sb_ha_group_ref_chassis(sync_from_sb_data->sb_ha_ch_grp_table,
&ha_ref_chassis_map);
@@ -1,7 +1,7 @@
{
"name": "OVN_Northbound",
- "version": "7.15.0",
- "cksum": "42875815 44684",
+ "version": "7.16.0",
+ "cksum": "1566377856 44897",
"tables": {
"NB_Global": {
"columns": {
@@ -260,6 +260,10 @@
"addresses": {"type": {"key": "string",
"min": 0,
"max": "unlimited"}},
+ "status": {
+ "type": {"key": {"type": "string",
+ "enum": ["set", ["online", "offline", "error"]]},
+ "min": 0, "max": 1}},
"options": {
"type": {"key": "string",
"value": "string",
@@ -2205,6 +2205,11 @@
health check will use all addresses configured on logical switch port.
</column>
+ <column name="status">
+ Health status synchronized from the <code>status</code> field of
+ corresponding service monitor in the southbound database.
+ </column>
+
<column name="options" key="interval" type='{"type": "integer"}'>
The interval, in seconds, between service monitor checks.
</column>
@@ -19329,26 +19329,40 @@ OVS_WAIT_UNTIL([
# Wait until the services are set to online.
wait_row_count Service_Monitor 1 status=online
-# Create one more health check on logical switch port
-NETNS_DAEMONIZE([lport], [nc -l -k 192.168.0.10 4041], [lport_tcp.pid])
+# Check status
+check_column "online" nb:Logical_Switch_Port_Health_Check status protocol=icmp
+# Check tcp monitor
check ovn-nbctl lsp-hc-add lport tcp 192.168.0.255 4041
lport1_uuid2=$(fetch_column nb:Logical_Switch_Port_Health_Check _uuid protocol=tcp)
check_row_count sb:Service_Monitor 2
+ovn-sbctl list service_monitor
+
+check_column "offline" nb:Logical_Switch_Port_Health_Check status protocol=tcp
+
+# Create one more health check on logical switch port
+NETNS_DAEMONIZE([lport], [nc -l -k 192.168.0.10 4041], [lport_tcp.pid])
+
# Wait until the services are set to online.
wait_row_count Service_Monitor 2 status=online
-NETNS_DAEMONIZE([lport], [nc -ulp 4042], [lport_udp.pid])
+check_column "online" nb:Logical_Switch_Port_Health_Check status protocol=tcp
check ovn-nbctl lsp-hc-add lport udp 192.168.0.255 4042
lport1_uuid3=$(fetch_column nb:Logical_Switch_Port_Health_Check _uuid protocol=udp)
+check_column "offline" nb:Logical_Switch_Port_Health_Check status protocol=udp
+
+NETNS_DAEMONIZE([lport], [nc -ulp 4042], [lport_udp.pid])
+
check_row_count sb:Service_Monitor 3
# Wait until the services are set to online.
wait_row_count Service_Monitor 3 status=online
+check_column "online" nb:Logical_Switch_Port_Health_Check status protocol=udp
+
AT_CLEANUP
])
This commit implements synchronization of health check for logical switch port status from SB Service_Monitor table to NB Logical_Switch_Port_Health_Check table. Signed-off-by: Alexandra Rukomoinikova <arukomoinikova@k2.cloud> --- northd/en-sync-from-sb.c | 4 ++++ northd/en-sync-from-sb.h | 3 +++ northd/inc-proc-northd.c | 8 +++++++ northd/northd.c | 45 ++++++++++++++++++++++++++++++++++++++++ ovn-nb.ovsschema | 8 +++++-- ovn-nb.xml | 5 +++++ tests/system-ovn.at | 20 +++++++++++++++--- 7 files changed, 88 insertions(+), 5 deletions(-)