kadalu / moana

Moana is a frontend for the Kadalu Storage / GlusterFS. Moana provides tools for setting up and managing the Kadalu Storage / Gluster pools.
GNU General Public License v3.0
18 stars 7 forks source link

Remove Rebalance status file before start #289

Closed aravindavk closed 1 year ago

aravindavk commented 1 year ago

Before starting the rebalance process(Fix layout or Migrate data), remove the status file because Rebalance process will not start if complete: true.

Reproduce:

kadalu volume create dev/vol1 kadalu-dev:/exports/vol1/s1
mkdir -p /mnt/vol1
kadalu mount dev/vol1 /mnt/vol1
mkdir -p /mnt/vol1/d1/d2/d3
kadalu volume expand dev/vol1 kadalu-dev:/exports/vol1/s2
ls /exports/vol1/s2
# Run expand again
kadalu volume expand dev/vol1 kadalu-dev:/exports/vol1/s3
ls /exports/vol1/s3 # <- No Rebalance is run because previous status file is not removed.
vatsa287 commented 1 year ago

Cool will send fix to delete the status file for particular volume only if status complete: true.

vatsa287 commented 1 year ago

Guess this should work,

def status_file_check(rollback_volume)
  workdir = "/var/lib/kadalu"
  status_file = reb.status_file("fix-layout")
  fix_layout_status_file_path = Path[workdir].join("rebalance-fix-layout-#{rollback_volume.not_nil!.distribute_groups[0].storage_units[0].path.gsub("/", "%2F")}.json")
  if File.exists?(fix_layout_status_file_path)
    data = MoanaTypes::FixLayoutRebalanceStatus.from_json(File.read(fix_layout_status_file_path))
    FileUtils.rm(fix_layout_status_file_path) if data.complete
  end
end

But as of now manage_services node action is made to run on all unique nodes, But adding this to that node action will add additional complexity of checking for status file in every node.

aravindavk commented 1 year ago

Before start of {fix-layout|migrate-data} rebalance, remove the status file. No need to check for the complete state.

https://github.com/kadalu/moana/blob/main/mgr/src/server/plugins/volume_utils.cr#L139

aravindavk commented 1 year ago

Change this id to match the status file path. https://github.com/kadalu/moana/blob/main/mgr/src/server/services/fix_layout.cr#L13

So that you can delete the status file as

      elsif svc.name == "fixlayoutservice" || svc.name == "migratedataservice"
        status_file = "/var/lib/kadalu/#{svc.id}.json"
        FileUtils.rm(status_file) if File.exists?(status_file)
        svc.start