Skip to content

Commit

Permalink
ovsdb-client: Fix needs-conversion when SERVER is explicitly specified.
Browse files Browse the repository at this point in the history
When you try to specify `SERVER` to the 'ovsdb-client needs-conversion'
command, it interprets the `SERVER` parameter as the path to the schema
and returns an error.
This PR fixes it.

Fixes: 1b1d2e6 ("ovsdb: Introduce experimental support for clustered databases.")
Submitted-at: openvswitch#347
Signed-off-by: Alexey Roytman <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
roytman authored and igsilya committed Feb 19, 2021
1 parent 46299c1 commit 0f475a5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ovsdb/ovsdb-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1571,14 +1571,15 @@ static void
do_needs_conversion(struct jsonrpc *rpc, const char *database_ OVS_UNUSED,
int argc OVS_UNUSED, char *argv[])
{
const char *schema_file_name = argv[argc - 1];
struct ovsdb_schema *schema1;
check_ovsdb_error(ovsdb_schema_from_file(argv[0], &schema1));
check_ovsdb_error(ovsdb_schema_from_file(schema_file_name, &schema1));

char *database = schema1->name;
open_rpc(1, NEED_DATABASE, argc, argv, &rpc, &database);

if (is_database_clustered(rpc, database)) {
ovsdb_schema_persist_ephemeral_columns(schema1, argv[0]);
ovsdb_schema_persist_ephemeral_columns(schema1, schema_file_name);
}

struct ovsdb_schema *schema2 = fetch_schema(rpc, schema1->name);
Expand Down
24 changes: 24 additions & 0 deletions tests/ovsdb-client.at
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,30 @@ AT_CHECK([ovsdb-client get-schema-cksum unix:socket ordinals], [0], [12345678 9
OVSDB_SERVER_SHUTDOWN
AT_CLEANUP

AT_SETUP([ovsdb-client needs-conversion (no conversion needed)])
AT_KEYWORDS([ovsdb client file positive])
ordinal_schema > schema
touch .db.~lock~
AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore])
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db], [0], [ignore], [ignore])
AT_CHECK([ovsdb-client needs-conversion unix:socket schema], [0], [no
])
OVSDB_SERVER_SHUTDOWN
AT_CLEANUP

AT_SETUP([ovsdb-client needs-conversion (conversion needed)])
AT_KEYWORDS([ovsdb client file positive])
ordinal_schema > schema
touch .db.~lock~
AT_CHECK([ovsdb-tool create db schema], [0], [], [ignore])
AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --remote=punix:socket db], [0], [ignore], [ignore])
sed 's/5\.1\.3/5.1.4/' < schema > schema2
AT_CHECK([diff schema schema2], [1], [ignore])
AT_CHECK([ovsdb-client needs-conversion unix:socket schema2], [0], [yes
])
OVSDB_SERVER_SHUTDOWN
AT_CLEANUP

AT_SETUP([ovsdb-client backup and restore])
AT_KEYWORDS([ovsdb client positive])

Expand Down

0 comments on commit 0f475a5

Please sign in to comment.