Skip to content

Commit d91c434

Browse files
committed
Merge branch 'bugfix_2025030300107382933' into 'master'
新增组件时,如果目录被占用,不应该提示用户使用deploy -f来重新部署 See merge request oceanbase/ob-deploy!357
2 parents 6d098cf + e0167b8 commit d91c434

File tree

11 files changed

+33
-31
lines changed

11 files changed

+33
-31
lines changed

core.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,10 +1809,12 @@ def _deploy_cluster(self, deploy, repositories, dump=True):
18091809

18101810
# Get the client
18111811
ssh_clients = self.get_clients(deploy_config, repositories)
1812-
1812+
components_kwargs = {}
1813+
for repository in repositories:
1814+
components_kwargs[repository.name] = {"source_option": "deploy"}
18131815
deploy_config.disable_encrypt_dump()
18141816
workflows = self.get_workflows('init')
1815-
if not self.run_workflow(workflows):
1817+
if not self.run_workflow(workflows, **components_kwargs):
18161818
return False
18171819
deploy_config.enable_encrypt_dump()
18181820

plugins/grafana/7.5.17/init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def critical(*arg, **kwargs):
2727
stdio.error(*arg, **kwargs)
2828

2929

30-
def init(plugin_context, *args, **kwargs):
30+
def init(plugin_context, source_option=None, *args, **kwargs):
3131
global stdio, force
3232
cluster_config = plugin_context.cluster_config
3333
clients = plugin_context.clients
@@ -103,7 +103,7 @@ def init(plugin_context, *args, **kwargs):
103103
ret = client.execute_command('ls %s' % target_path)
104104
if not ret or ret.stdout.strip():
105105
critical(EC_FAIL_TO_INIT_PATH.format(server=server, key=k, msg=InitDirFailedErrorMessage.NOT_EMPTY.format(path=target_path)))
106-
critical(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
106+
source_option == "deploy" and critical(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
107107
mkdir_ret = False
108108
continue
109109
client.execute_command("if [ ! '%s' -ef '%s' ]; then ln -sf %s %s; fi" % (target_path, link_path, target_path, link_path))

plugins/ob-configserver/1.0.0/init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def clean_home_path(home_path, client):
4040
return client.execute_command('rm -fr %s' % home_path, timeout=-1)
4141

4242

43-
def init(plugin_context, *args, **kwargs):
43+
def init(plugin_context, source_option=None, *args, **kwargs):
4444
cluster_config = plugin_context.cluster_config
4545
clients = plugin_context.clients
4646
stdio = plugin_context.stdio
@@ -68,7 +68,7 @@ def init(plugin_context, *args, **kwargs):
6868
else:
6969
global_ret = False
7070
stdio.error(EC_FAIL_TO_INIT_PATH.format(server=server, key='home path', msg=InitDirFailedErrorMessage.NOT_EMPTY.format(path=home_path)))
71-
stdio.error(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
71+
source_option == "deploy" and stdio.error(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
7272

7373
if global_ret and not client.execute_command(f"""bash -c 'mkdir -p {os.path.join(home_path, '{run,bin,conf,log}')}'"""):
7474
stdio.error(EC_FAIL_TO_INIT_PATH.format(server=server, key='home path',msg=InitDirFailedErrorMessage.PERMISSION_DENIED.format(path=home_path)))

plugins/obagent/0.1/init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from _errno import EC_FAIL_TO_INIT_PATH, InitDirFailedErrorMessage, EC_COMPONENT_DIR_NOT_EMPTY
1919

2020

21-
def init(plugin_context, *args, **kwargs):
21+
def init(plugin_context, source_option=None, *args, **kwargs):
2222
cluster_config = plugin_context.cluster_config
2323
clients = plugin_context.clients
2424
stdio = plugin_context.stdio
@@ -66,7 +66,7 @@ def init(plugin_context, *args, **kwargs):
6666
if not ret or ret.stdout.strip():
6767
global_ret = False
6868
stdio.error(EC_FAIL_TO_INIT_PATH.format(server=server, key='home path', msg=InitDirFailedErrorMessage.NOT_EMPTY.format(path=home_path)))
69-
stdio.error(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
69+
source_option == "deploy" and stdio.error(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
7070
continue
7171
else:
7272
global_ret = False

plugins/obbinlog-ce/4.0.1/init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from _errno import EC_FAIL_TO_INIT_PATH, InitDirFailedErrorMessage, EC_COMPONENT_DIR_NOT_EMPTY
1818

1919

20-
def init(plugin_context, *args, **kwargs):
20+
def init(plugin_context, source_option=None, *args, **kwargs):
2121
def critical(*arg, **kwargs):
2222
nonlocal global_ret
2323
global_ret = False
@@ -72,7 +72,7 @@ def critical(*arg, **kwargs):
7272
if not ret or ret.stdout.strip():
7373
global_ret = False
7474
critical(EC_FAIL_TO_INIT_PATH.format(server=server, key='home path', msg=InitDirFailedErrorMessage.NOT_EMPTY.format(path=home_path)))
75-
critical(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
75+
source_option == "deploy" and critical(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
7676
continue
7777
else:
7878
critical(EC_FAIL_TO_INIT_PATH.format(server=server, key='home path', msg=InitDirFailedErrorMessage.CREATE_FAILED.format(path=home_path)))

plugins/oblogproxy/2.0.0/init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from _errno import EC_FAIL_TO_INIT_PATH, InitDirFailedErrorMessage, EC_COMPONENT_DIR_NOT_EMPTY
1818

1919

20-
def init(plugin_context, *args, **kwargs):
20+
def init(plugin_context, source_option=None, *args, **kwargs):
2121
def critical(*arg, **kwargs):
2222
nonlocal global_ret
2323
global_ret = False
@@ -72,7 +72,7 @@ def critical(*arg, **kwargs):
7272
if not ret or ret.stdout.strip():
7373
global_ret = False
7474
critical(EC_FAIL_TO_INIT_PATH.format(server=server, key='home path', msg=InitDirFailedErrorMessage.NOT_EMPTY.format(path=home_path)))
75-
critical(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
75+
source_option == "deploy" and critical(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
7676
continue
7777
else:
7878
critical(EC_FAIL_TO_INIT_PATH.format(server=server, key='home path', msg=InitDirFailedErrorMessage.CREATE_FAILED.format(path=home_path)))

plugins/obproxy/3.1.0/init.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from _errno import EC_FAIL_TO_INIT_PATH, InitDirFailedErrorMessage, EC_COMPONENT_DIR_NOT_EMPTY
1818

1919

20-
def init(plugin_context, *args, **kwargs):
20+
def init(plugin_context, source_option=None, *args, **kwargs):
2121
cluster_config = plugin_context.cluster_config
2222
clients = plugin_context.clients
2323
stdio = plugin_context.stdio
@@ -62,7 +62,7 @@ def init(plugin_context, *args, **kwargs):
6262
if client.execute_command('bash -c \'if [[ "$(ls -d {0} 2>/dev/null)" != "" ]]; then exit 0; else exit 1; fi\''.format(home_path)):
6363
global_ret = False
6464
stdio.error(EC_FAIL_TO_INIT_PATH.format(server=server, key='home path', msg=InitDirFailedErrorMessage.NOT_EMPTY.format(path=home_path)))
65-
stdio.error(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
65+
source_option == "deploy" and stdio.error(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
6666
continue
6767

6868
if not client.execute_command("bash -c 'mkdir -p %s/{run,bin,lib}'" % home_path):

plugins/oceanbase/3.1.0/init.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def init_dir(server, client, key, path, deploy_name, link_path=None):
4040
ret = client.execute_command('ls %s' % (path))
4141
if not ret or ret.stdout.strip():
4242
critical(EC_FAIL_TO_INIT_PATH.format(server=server, key='%s path' % key, msg=InitDirFailedErrorMessage.NOT_EMPTY.format(path=path)))
43-
critical(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
43+
source_option == "deploy" and critical(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
4444
return False
4545
else:
4646
critical(EC_FAIL_TO_INIT_PATH.format(server=server, key='%s path' % key, msg=InitDirFailedErrorMessage.CREATE_FAILED.format(path=path)))
@@ -55,7 +55,7 @@ def init_dir(server, client, key, path, deploy_name, link_path=None):
5555
return False
5656

5757

58-
def init(plugin_context, *args, **kwargs):
58+
def init(plugin_context, source_option=None, *args, **kwargs):
5959
global stdio, force
6060
cluster_config = plugin_context.cluster_config
6161
clients = plugin_context.clients
@@ -126,7 +126,7 @@ def init(plugin_context, *args, **kwargs):
126126
ret = client.execute_command('ls %s' % (home_path))
127127
if not ret or ret.stdout.strip():
128128
critical(EC_FAIL_TO_INIT_PATH.format(server=server, key='home path', msg=InitDirFailedErrorMessage.NOT_EMPTY.format(path=home_path)))
129-
critical(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
129+
source_option == "deploy" and critical(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
130130
continue
131131
else:
132132
critical(EC_FAIL_TO_INIT_PATH.format(server=server, key='home path', msg=InitDirFailedErrorMessage.CREATE_FAILED.format(path=home_path)))
@@ -144,7 +144,7 @@ def init(plugin_context, *args, **kwargs):
144144
ret = client.execute_command('ls %s' % (data_path))
145145
if not ret or ret.stdout.strip():
146146
critical(EC_FAIL_TO_INIT_PATH.format(server=server, key='data dir', msg=InitDirFailedErrorMessage.NOT_EMPTY.format(path=data_path)))
147-
critical(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
147+
source_option == "deploy" and critical(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
148148
continue
149149
else:
150150
critical(EC_FAIL_TO_INIT_PATH.format(server=server, key='data dir', msg=InitDirFailedErrorMessage.CREATE_FAILED.format(path=data_path)))
@@ -165,7 +165,7 @@ def init(plugin_context, *args, **kwargs):
165165
ret = client.execute_command('ls %s' % (log_dir))
166166
if not ret or ret.stdout.strip():
167167
critical(EC_FAIL_TO_INIT_PATH.format(server=server, key='%s dir' % key, msg=InitDirFailedErrorMessage.NOT_EMPTY.format(path=log_dir)))
168-
critical(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
168+
source_option == "deploy" and critical(EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
169169
continue
170170
else:
171171
critical(EC_FAIL_TO_INIT_PATH.format(server=server, key='%s dir' % key, msg=InitDirFailedErrorMessage.CREATE_FAILED.format(path=log_dir)))

plugins/ocp-express/1.0/init.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _clean(server, client, path, stdio=None):
3030
return True
3131

3232

33-
def init(plugin_context, *args, **kwargs):
33+
def init(plugin_context, source_option=None, *args, **kwargs):
3434
cluster_config = plugin_context.cluster_config
3535
clients = plugin_context.clients
3636
stdio = plugin_context.stdio
@@ -84,7 +84,7 @@ def init(plugin_context, *args, **kwargs):
8484
if not ret or ret.stdout.strip():
8585
global_ret = False
8686
stdio.error(err.EC_FAIL_TO_INIT_PATH.format(server=server, key='home path', msg=err.InitDirFailedErrorMessage.NOT_EMPTY.format(path=home_path)))
87-
stdio.error(err.EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
87+
source_option == "deploy" and stdio.error(err.EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
8888
continue
8989
else:
9090
global_ret = False
@@ -100,7 +100,7 @@ def init(plugin_context, *args, **kwargs):
100100
if not ret or ret.stdout.strip():
101101
global_ret = False
102102
stdio.error(err.EC_FAIL_TO_INIT_PATH.format(server=server, key='log dir', msg=err.InitDirFailedErrorMessage.NOT_EMPTY.format(path=log_dir)))
103-
stdio.error(err.EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
103+
source_option == "deploy" and stdio.error(err.EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
104104
continue
105105
else:
106106
global_ret = False
@@ -111,7 +111,7 @@ def init(plugin_context, *args, **kwargs):
111111
if not client.execute_command('mkdir -p %s' % log_dir):
112112
global_ret = False
113113
stdio.error(err.EC_FAIL_TO_INIT_PATH.format(server=server, key='log dir', msg=err.InitDirFailedErrorMessage.NOT_EMPTY.format(path=log_dir)))
114-
stdio.error(err.EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
114+
source_option == "deploy" and stdio.error(err.EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
115115
continue
116116
link_path = os.path.join(home_path, 'log')
117117
client.execute_command("if [ ! '%s' -ef '%s' ]; then ln -sf %s %s; fi" % (log_dir, link_path, log_dir, link_path))

plugins/ocp-server/4.2.1/init.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def add_pkg(name, version=None, release=None, arch=None):
9494
plugin_context.set_variable('ob_with_opti_pkgs', ob_with_opti_pkgs)
9595

9696

97-
def init(plugin_context, upgrade=False, *args, **kwargs):
97+
def init(plugin_context, upgrade=False, source_option=None, *args, **kwargs):
9898
cluster_config = plugin_context.cluster_config
9999
clients = plugin_context.clients
100100
stdio = plugin_context.stdio
@@ -161,7 +161,7 @@ def init(plugin_context, upgrade=False, *args, **kwargs):
161161
if not ret or ret.stdout.strip():
162162
global_ret = False
163163
stdio.error(err.EC_FAIL_TO_INIT_PATH.format(server=server, key='home path', msg=err.InitDirFailedErrorMessage.NOT_EMPTY.format(path=home_path)))
164-
stdio.error(err.EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
164+
source_option == "deploy" and stdio.error(err.EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
165165
continue
166166
else:
167167
global_ret = False
@@ -177,7 +177,7 @@ def init(plugin_context, upgrade=False, *args, **kwargs):
177177
if not ret or ret.stdout.strip():
178178
global_ret = False
179179
stdio.error(err.EC_FAIL_TO_INIT_PATH.format(server=server, key='log dir', msg=err.InitDirFailedErrorMessage.NOT_EMPTY.format(path=log_dir)))
180-
stdio.error(err.EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
180+
source_option == "deploy" and stdio.error(err.EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
181181
continue
182182
else:
183183
global_ret = False
@@ -188,7 +188,7 @@ def init(plugin_context, upgrade=False, *args, **kwargs):
188188
if not client.execute_command('mkdir -p -m 775 %s' % log_dir):
189189
global_ret = False
190190
stdio.error(err.EC_FAIL_TO_INIT_PATH.format(server=server, key='log dir', msg=err.InitDirFailedErrorMessage.NOT_EMPTY.format(path=log_dir)))
191-
stdio.error(err.EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
191+
source_option == "deploy" and stdio.error(err.EC_COMPONENT_DIR_NOT_EMPTY.format(deploy_name=deploy_name), _on_exit=True)
192192
continue
193193
link_path = os.path.join(home_path, 'log')
194194
client.execute_command("if [ ! '%s' -ef '%s' ]; then ln -sf %s %s; fi" % (log_dir, link_path, log_dir, link_path))

0 commit comments

Comments
 (0)