You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
3.0 KiB
93 lines
3.0 KiB
From 8b5b3b247a00515d3188453c27b0ba749e93d325 Mon Sep 17 00:00:00 2001 |
|
From: Aravinda VK <avishwan@redhat.com> |
|
Date: Tue, 26 Mar 2019 13:20:13 +0530 |
|
Subject: [PATCH 339/344] geo-rep: fix integer config validation |
|
|
|
ssh-port validation is mentioned as `validation=int` in template |
|
`gsyncd.conf`, but not handled this during geo-rep config set. |
|
|
|
upstream patch: |
|
https://review.gluster.org/#/c/glusterfs/+/22418/ |
|
Backport of: |
|
|
|
>Fixes: bz#1692666 |
|
>Change-Id: I3f19d9b471b0a3327e4d094dfbefcc58ed2c34f6 |
|
>Signed-off-by: Aravinda VK <avishwan@redhat.com> |
|
>Signed-off-by: Sunny Kumar <sunkumar@redhat.com> |
|
|
|
BUG: 1782162 |
|
Change-Id: I3f19d9b471b0a3327e4d094dfbefcc58ed2c34f6 |
|
Signed-off-by: Sunny Kumar <sunkumar@redhat.com> |
|
Reviewed-on: https://code.engineering.redhat.com/gerrit/187533 |
|
Tested-by: RHGS Build Bot <nigelb@redhat.com> |
|
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com> |
|
--- |
|
geo-replication/syncdaemon/gsyncdconfig.py | 23 ++++++++++++++++++----- |
|
tests/00-geo-rep/georep-basic-dr-rsync.t | 3 +++ |
|
2 files changed, 21 insertions(+), 5 deletions(-) |
|
|
|
diff --git a/geo-replication/syncdaemon/gsyncdconfig.py b/geo-replication/syncdaemon/gsyncdconfig.py |
|
index f823311..8848071 100644 |
|
--- a/geo-replication/syncdaemon/gsyncdconfig.py |
|
+++ b/geo-replication/syncdaemon/gsyncdconfig.py |
|
@@ -329,6 +329,9 @@ class Gconf(object): |
|
if item["validation"] == "unixtime": |
|
return validate_unixtime(value) |
|
|
|
+ if item["validation"] == "int": |
|
+ return validate_int(value) |
|
+ |
|
return False |
|
|
|
def _is_config_changed(self): |
|
@@ -381,6 +384,14 @@ def config_upgrade(config_file, ret): |
|
config.write(configfile) |
|
|
|
|
|
+def validate_int(value): |
|
+ try: |
|
+ _ = int(value) |
|
+ return True |
|
+ except ValueError: |
|
+ return False |
|
+ |
|
+ |
|
def validate_unixtime(value): |
|
try: |
|
y = datetime.fromtimestamp(int(value)).strftime("%Y") |
|
@@ -393,11 +404,13 @@ def validate_unixtime(value): |
|
|
|
|
|
def validate_minmax(value, minval, maxval): |
|
- value = int(value) |
|
- minval = int(minval) |
|
- maxval = int(maxval) |
|
- |
|
- return value >= minval and value <= maxval |
|
+ try: |
|
+ value = int(value) |
|
+ minval = int(minval) |
|
+ maxval = int(maxval) |
|
+ return value >= minval and value <= maxval |
|
+ except ValueError: |
|
+ return False |
|
|
|
|
|
def validate_choice(value, allowed_values): |
|
diff --git a/tests/00-geo-rep/georep-basic-dr-rsync.t b/tests/00-geo-rep/georep-basic-dr-rsync.t |
|
index b432635..b6fbf18 100644 |
|
--- a/tests/00-geo-rep/georep-basic-dr-rsync.t |
|
+++ b/tests/00-geo-rep/georep-basic-dr-rsync.t |
|
@@ -71,6 +71,9 @@ EXPECT_WITHIN $GEO_REP_TIMEOUT 4 check_status_num_rows "Created" |
|
#Config gluster-command-dir |
|
TEST $GEOREP_CLI $master $slave config gluster-command-dir ${GLUSTER_CMD_DIR} |
|
|
|
+#Config Set ssh-port to validate int validation |
|
+TEST $GEOREP_CLI $master $slave config ssh-port 22 |
|
+ |
|
#Config gluster-command-dir |
|
TEST $GEOREP_CLI $master $slave config slave-gluster-command-dir ${GLUSTER_CMD_DIR} |
|
|
|
-- |
|
1.8.3.1 |
|
|
|
|