diff options
author | Atin Mukherjee <amukherj@redhat.com> | 2018-11-20 12:32:32 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-12-05 21:36:25 +0000 |
commit | d4723bdd30f0955ca68fec8c01bc87229c6a24c0 (patch) | |
tree | 378ba7553b0f43e9de5d9a7139420e53fca48f47 /xlators/mgmt/glusterd/src/glusterd.c | |
parent | afc3006b46bf9d6eb05e39af68bcd81041761a9c (diff) |
glusterd: glusterd to regenerate volfiles when GD_OP_VERSION_MAX changes
While glusterd has an infra to allow post install of spec to bring it up
in the interim upgrade mode to allow all the volfiles to be regenerated
with the latest executable, in container world the same methodology is
not followed as container image always point to the specific gluster rpm
and gluster rpm doesn't go through an upgrade process.
This fix does the following:
1. If glusterd.upgrade file doesn't exist, regenerate the volfiles
2. If maximum-operating-version read from glusterd.upgrade doesn't match
with GD_OP_VERSION_MAX, glusterd detects it to be a version where new
options are introduced and regenerate the volfiles.
Tests done:
1. Bring up glusterd, check if glusterd.upgrade file has been created
with GD_OP_VERSION_MAX value.
2. Post 1, restart glusterd and check glusterd hasn't regenerated the
volfiles as there's is no change in the GD_OP_VERSION_MAX vs the
op_version read from the file.
3. Bump up the GD_OP_VERSION_MAX in the code by 1 and post compilation
restart glusterd where the volfiles should be again regenerated.
Note: The old way of having volfiles regenerated during an rpm upgrade
is kept as it is for now but eventually this can be sunset later.
Change-Id: I75b49a1601c71e99f6a6bc360dd12dd03a96414b
Fixes: bz#1651463
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index b1fa6247ee1..a3082717c27 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -1404,6 +1404,7 @@ init(xlator_t *this) gf_boolean_t downgrade = _gf_false; char *localtime_logging = NULL; int32_t len = 0; + int op_version = 0; #ifndef GF_DARWIN_HOST_OS { @@ -1979,17 +1980,33 @@ init(xlator_t *this) } GF_ATOMIC_INIT(conf->blockers, 0); + ret = glusterd_handle_upgrade_downgrade(this->options, conf, upgrade, + downgrade); + if (ret) + goto out; + + ret = glusterd_retrieve_max_op_version(this, &op_version); + /* first condition indicates file isn't present which means this code + * change is hitting for the first time or someone has deleted it from the + * backend.second condition is when max op_version differs, in both cases + * volfiles should be regenerated + */ + if (op_version == 0 || op_version != GD_OP_VERSION_MAX) { + gf_log(this->name, GF_LOG_INFO, + "Regenerating volfiles due to a max op-version mismatch or " + "glusterd.upgrade file not being present, op_version retrieved:" + "%d, max op_version: %d", + op_version, GD_OP_VERSION_MAX); + glusterd_recreate_volfiles(conf); + ret = glusterd_store_max_op_version(this); + } + /* If the peer count is less than 2 then this would be the best time to * spawn process/bricks that may need (re)starting since last time * (this) glusterd was up. */ if (glusterd_get_peers_count() < 2) glusterd_launch_synctask(glusterd_spawn_daemons, NULL); - ret = glusterd_handle_upgrade_downgrade(this->options, conf, upgrade, - downgrade); - if (ret) - goto out; - ret = glusterd_hooks_spawn_worker(this); if (ret) goto out; |