Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backup #202

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion simplyblock_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ def __init__(self):
'Create an new cluster with this node as mgmt (local run)')
sub_command.add_argument(
"--blk_size", help='The block size in bytes', type=int, choices=[512, 4096], default=512)
sub_command.add_argument(
"--backup", help='adding this flag enables cluster backup service',action='store_true'
)

sub_command.add_argument(
"--page_size", help='The size of a data page in bytes', type=int, default=2097152)
Expand Down Expand Up @@ -958,6 +961,7 @@ def run(self):
elif args.command == 'cluster':
sub_command = args_dict[args.command]
if sub_command == 'create':

ret = self.cluster_create(args)
elif sub_command == 'add':
ret = self.cluster_add(args)
Expand Down Expand Up @@ -1331,14 +1335,15 @@ def cluster_create(self, args):
inflight_io_threshold = args.inflight_io_threshold
enable_qos = args.enable_qos
strict_node_anti_affinity = args.strict_node_anti_affinity
backup = args.backup


return cluster_ops.create_cluster(
blk_size, page_size_in_blocks,
CLI_PASS, cap_warn, cap_crit, prov_cap_warn, prov_cap_crit,
ifname, log_del_interval, metrics_retention_period, contact_point, grafana_endpoint,
distr_ndcs, distr_npcs, distr_bs, distr_chunk_bs, ha_type, enable_node_affinity,
qpair_count, max_queue_size, inflight_io_threshold, enable_qos, strict_node_anti_affinity)
qpair_count, max_queue_size, inflight_io_threshold, enable_qos, strict_node_anti_affinity,backup)


def query_yes_no(self, question, default="yes"):
Expand Down
6 changes: 4 additions & 2 deletions simplyblock_core/cluster_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _add_graylog_input(cluster_ip, password):
def create_cluster(blk_size, page_size_in_blocks, cli_pass,
cap_warn, cap_crit, prov_cap_warn, prov_cap_crit, ifname, log_del_interval, metrics_retention_period,
contact_point, grafana_endpoint, distr_ndcs, distr_npcs, distr_bs, distr_chunk_bs, ha_type,
enable_node_affinity, qpair_count, max_queue_size, inflight_io_threshold, enable_qos, strict_node_anti_affinity):
enable_node_affinity, qpair_count, max_queue_size, inflight_io_threshold, enable_qos, strict_node_anti_affinity,backup):

logger.info("Installing dependencies...")
ret = scripts.install_deps()
Expand Down Expand Up @@ -179,6 +179,8 @@ def create_cluster(blk_size, page_size_in_blocks, cli_pass,
c.inflight_io_threshold = inflight_io_threshold
c.enable_qos = enable_qos
c.strict_node_anti_affinity = strict_node_anti_affinity
c.backup = backup
print (backup)

alerts_template_folder = os.path.join(TOP_DIR, "simplyblock_core/scripts/alerting/")
alert_resources_file = "alert_resources.yaml"
Expand Down Expand Up @@ -221,7 +223,7 @@ def create_cluster(blk_size, page_size_in_blocks, cli_pass,
logger.info("Deploying swarm stack ...")
log_level = "DEBUG" if constants.LOG_WEB_DEBUG else "INFO"
ret = scripts.deploy_stack(cli_pass, DEV_IP, constants.SIMPLY_BLOCK_DOCKER_IMAGE, c.secret, c.uuid,
log_del_interval, metrics_retention_period, log_level, c.grafana_endpoint)
log_del_interval, metrics_retention_period, log_level, c.grafana_endpoint,backup)
logger.info("Deploying swarm stack > Done")

if ret == 0:
Expand Down
6 changes: 3 additions & 3 deletions simplyblock_core/env_var
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SIMPLY_BLOCK_COMMAND_NAME=sbcli-dev
SIMPLY_BLOCK_VERSION=10.6.4
SIMPLY_BLOCK_COMMAND_NAME=sbcli-mig
SIMPLY_BLOCK_VERSION=1.0.338

SIMPLY_BLOCK_DOCKER_IMAGE=simplyblock/simplyblock:main
SIMPLY_BLOCK_DOCKER_IMAGE=simplyblock/simplyblock:backup
DOCKER_USER=hamdysimplyblock
1 change: 1 addition & 0 deletions simplyblock_core/models/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Cluster(BaseModel):
secret: str = ""
strict_node_anti_affinity: bool = False
tls: bool = False
backup: bool = False

def get_status_code(self):
if self.status in self.STATUS_CODE_MAP:
Expand Down
4 changes: 2 additions & 2 deletions simplyblock_core/scripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ def configure_docker(docker_ip):


def deploy_stack(cli_pass, dev_ip, image_name, graylog_password, cluster_id,
log_del_interval, metrics_retention_period, log_level, grafana_endpoint):
log_del_interval, metrics_retention_period, log_level, grafana_endpoint,backup):
pass_hash = hashlib.sha256(graylog_password.encode('utf-8')).hexdigest()
return __run_script(
['sudo', 'bash', '-x', os.path.join(DIR_PATH, 'deploy_stack.sh'), cli_pass, dev_ip, image_name, pass_hash,
graylog_password, cluster_id, log_del_interval, metrics_retention_period, log_level, grafana_endpoint])
graylog_password, cluster_id, log_del_interval, metrics_retention_period, log_level, grafana_endpoint,str(backup)])


def deploy_cleaner():
Expand Down
11 changes: 10 additions & 1 deletion simplyblock_core/scripts/deploy_stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export LOG_DELETION_INTERVAL=$7
export RETENTION_PERIOD=$8
export LOG_LEVEL=$9
export GRAFANA_ENDPOINT=${10}
export BACKUP=${11}
export DIR="$(dirname "$(realpath "$0")")"

if [ -s "/etc/foundationdb/fdb.cluster" ]
Expand All @@ -30,14 +31,22 @@ else
exit 1
fi




docker network create monitoring-net -d overlay --attachable

docker stack deploy --compose-file="$DIR"/docker-compose-swarm-monitoring.yml monitoring

# wait for the services to become online
bash "$DIR"/stack_deploy_wait.sh monitoring

docker stack deploy --compose-file="$DIR"/docker-compose-swarm.yml app
if $BACKUP;then
docker stack deploy --compose-file="$DIR"/docker-compose-swarm-withbackup.yml app
else
docker stack deploy --compose-file="$DIR"/docker-compose-swarm.yml app
fi


# wait for the services to become online
bash "$DIR"/stack_deploy_wait.sh app
Expand Down
Loading
Loading