Acked-by: Justin Pettit <jpet...@nicira.com> --Justin
> On Jul 28, 2015, at 8:44 AM, Ben Pfaff <b...@nicira.com> wrote: > > Until now, if the chassis id was missing, ovn-controller exited. This > commit makes ovn-controller wait for it to return. > > Signed-off-by: Ben Pfaff <b...@nicira.com> > --- > ovn/controller/binding.c | 3 +++ > ovn/controller/chassis.c | 4 ++++ > ovn/controller/ovn-controller.c | 38 +++++++++++++++++++++----------------- > 3 files changed, 28 insertions(+), 17 deletions(-) > > diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c > index b6b345e..4cf8636 100644 > --- a/ovn/controller/binding.c > +++ b/ovn/controller/binding.c > @@ -135,6 +135,9 @@ binding_cleanup(struct controller_ctx *ctx, const char > *chassis_id) > return false; > } > > + if (!chassis_id) { > + return true; > + } > const struct sbrec_chassis *chassis_rec > = get_chassis_by_name(ctx->ovnsb_idl, chassis_id); > if (!chassis_rec) { > diff --git a/ovn/controller/chassis.c b/ovn/controller/chassis.c > index 511d5c9..2dfce19 100644 > --- a/ovn/controller/chassis.c > +++ b/ovn/controller/chassis.c > @@ -104,6 +104,10 @@ chassis_run(struct controller_ctx *ctx, const char > *chassis_id) > bool > chassis_cleanup(struct controller_ctx *ctx, const char *chassis_id) > { > + if (!chassis_id) { > + return true; > + } > + > /* Delete Chassis row. */ > const struct sbrec_chassis *chassis_rec > = get_chassis_by_name(ctx->ovnsb_idl, chassis_id); > diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c > index d7ab7a3..2746407 100644 > --- a/ovn/controller/ovn-controller.c > +++ b/ovn/controller/ovn-controller.c > @@ -86,6 +86,13 @@ get_bridge(struct controller_ctx *ctx, const char *name) > return NULL; > } > > +static const char * > +get_chassis_id(const struct ovsdb_idl *ovs_idl) > +{ > + const struct ovsrec_open_vswitch *cfg = > ovsrec_open_vswitch_first(ovs_idl); > + return cfg ? smap_get(&cfg->external_ids, "system-id") : NULL; > +} > + > /* Retrieve the OVN integration bridge from the "external-ids:ovn-bridge" > * key, the remote location from the "external-ids:ovn-remote" key, and > * the chassis name from the "external-ids:system-id" key in the > @@ -94,8 +101,7 @@ get_bridge(struct controller_ctx *ctx, const char *name) > * xxx ovn-controller does not support changing any of these mid-run, > * xxx but that should be addressed later. */ > static void > -get_core_config(struct controller_ctx *ctx, char **br_int_namep, > - char **chassis_idp) > +get_core_config(struct controller_ctx *ctx, char **br_int_namep) > { > while (1) { > ovsdb_idl_run(ctx->ovs_idl); > @@ -108,7 +114,7 @@ get_core_config(struct controller_ctx *ctx, char > **br_int_namep, > exit(EXIT_FAILURE); > } > > - const char *remote, *system_id, *br_int_name; > + const char *remote, *br_int_name; > > br_int_name = smap_get(&cfg->external_ids, "ovn-bridge"); > if (!br_int_name) { > @@ -121,14 +127,7 @@ get_core_config(struct controller_ctx *ctx, char > **br_int_namep, > goto try_again; > } > > - system_id = smap_get(&cfg->external_ids, "system-id"); > - if (!system_id) { > - VLOG_INFO("system-id not specified. Waiting..."); > - goto try_again; > - } > - > ovnsb_remote = xstrdup(remote); > - *chassis_idp = xstrdup(system_id); > *br_int_namep = xstrdup(br_int_name); > return; > > @@ -256,8 +255,8 @@ main(int argc, char *argv[]) > > get_initial_snapshot(ctx.ovs_idl); > > - char *br_int_name, *chassis_id; > - get_core_config(&ctx, &br_int_name, &chassis_id); > + char *br_int_name; > + get_core_config(&ctx, &br_int_name); > > ctx.ovnsb_idl = ovsdb_idl_create(ovnsb_remote, &sbrec_idl_class, > true, true); > @@ -273,15 +272,20 @@ main(int argc, char *argv[]) > ctx.ovs_idl_txn = idl_loop_run(&ovs_idl_loop); > > const struct ovsrec_bridge *br_int = get_bridge(&ctx, br_int_name); > + const char *chassis_id = get_chassis_id(ctx.ovs_idl); > > - chassis_run(&ctx, chassis_id); > - encaps_run(&ctx, br_int, chassis_id); > - binding_run(&ctx, br_int, chassis_id); > + if (chassis_id) { > + chassis_run(&ctx, chassis_id); > + encaps_run(&ctx, br_int, chassis_id); > + binding_run(&ctx, br_int, chassis_id); > + } > > if (br_int) { > struct hmap flow_table = HMAP_INITIALIZER(&flow_table); > pipeline_run(&ctx, &flow_table); > - physical_run(&ctx, br_int, chassis_id, &flow_table); > + if (chassis_id) { > + physical_run(&ctx, br_int, chassis_id, &flow_table); > + } > ofctrl_run(br_int, &flow_table); > hmap_destroy(&flow_table); > } > @@ -309,6 +313,7 @@ main(int argc, char *argv[]) > ctx.ovs_idl_txn = idl_loop_run(&ovs_idl_loop); > > const struct ovsrec_bridge *br_int = get_bridge(&ctx, br_int_name); > + const char *chassis_id = get_chassis_id(ctx.ovs_idl); > > /* Run all of the cleanup functions, even if one of them returns > false. > * We're done if all of them return true. */ > @@ -332,7 +337,6 @@ main(int argc, char *argv[]) > idl_loop_destroy(&ovnsb_idl_loop); > > free(br_int_name); > - free(chassis_id); > free(ovnsb_remote); > free(ovs_remote); > > -- > 2.1.3 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev