Re: [ovs-dev] [PATCH ovs]: lib/db-ctl-base.c: Check that --all or records argument provided

2021-03-25 Thread Ben Pfaff
On Thu, Mar 25, 2021 at 09:18:19PM +0200, Alexey Roytman wrote:
> From: Alexey Roytman 
> 
> ovn-nbctl and  ovn-sbctl CLI utilities allow destroying the entire
> table or some records from the given table.
> However, either the --all option or the deleted records should be provided.
> This patch adds the test.
> 
> Signed-off-by: Alexey Roytman 
>
> ---
>  lib/db-ctl-base.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c
> index e95c77da2..81ade7abc 100644
> --- a/lib/db-ctl-base.c
> +++ b/lib/db-ctl-base.c
> @@ -1823,6 +1823,11 @@ cmd_destroy(struct ctl_context *ctx)
>  return;
>  }
> 
> +if (!delete_all && ctx->argc == 2) {
> +ctl_error(ctx, "either --all or records argument should be 
> specified");
> +return;
> +}

I can see why this is worth warning about, but a fatal error seems like
overkill.  I'd use VLOG_WARN here.

I'd also add a test.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH ovs]: lib/db-ctl-base.c: Check that --all or records argument provided

2021-03-25 Thread Alexey Roytman
From: Alexey Roytman 

ovn-nbctl and  ovn-sbctl CLI utilities allow destroying the entire
table or some records from the given table.
However, either the --all option or the deleted records should be provided.
This patch adds the test.

Signed-off-by: Alexey Roytman 
---
 lib/db-ctl-base.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c
index e95c77da2..81ade7abc 100644
--- a/lib/db-ctl-base.c
+++ b/lib/db-ctl-base.c
@@ -1823,6 +1823,11 @@ cmd_destroy(struct ctl_context *ctx)
 return;
 }

+if (!delete_all && ctx->argc == 2) {
+ctl_error(ctx, "either --all or records argument should be specified");
+return;
+}
+
 if (delete_all) {
 const struct ovsdb_idl_row *row;
 const struct ovsdb_idl_row *next_row;
-- 
2.25.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev