Skip to content
This repository was archived by the owner on Jan 1, 2024. It is now read-only.

Commit faaa513

Browse files
authored
Remove old configs before loading a new one (#407)
Closes #406 Before the patch, the new config was loaded into the `/tmp` folder and stayed there. As a result, when loading the folder config with the old name, there were files from the old config that were deleted in the new config. Now all configs are loaded into the `/tmp/tarantool.cartridge.configs/` folder, which allows to remove previous configs before loading a new one.
1 parent c9a5824 commit faaa513

File tree

8 files changed

+34
-5
lines changed

8 files changed

+34
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ Please update `ansible-galaxy install` command in
1010
README.md to use the newest tag with new release
1111
-->
1212

13+
### Fixed
14+
15+
- Remove old app configurations before uploading a new one
16+
1317
## [1.12.0] - 2022-03-03
1418

1519
### Added

library/cartridge_apply_app_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
argument_spec = {
1212
'local_config_path': {'required': True, 'type': 'str'},
13-
'remote_dir': {'required': False, 'type': 'str', 'default': '/tmp/'},
13+
'remote_dir': {'required': False, 'type': 'str', 'default': '/tmp/tarantool.cartridge.configs/'},
1414
'upload_mode': {'required': False, 'type': 'str'},
1515
'console_sock': {'required': False, 'type': 'str'},
1616
'upload_url': {'required': False, 'type': 'str'},
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

molecule/config_upload_tdg/converge.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22

3+
# We have configs in subfolders with the same names "config" to check the replacement of temporary folders
4+
35
- name: 'Test file config'
46
hosts: cluster
57
become: true
@@ -34,7 +36,7 @@
3436
import_role:
3537
name: ansible-cartridge
3638
vars:
37-
cartridge_app_config_path: './configs/config-yml'
39+
cartridge_app_config_path: './configs/config-yml/config'
3840
expected_test_section: {config-dir-key: yml}
3941

4042
# Folder config
@@ -43,13 +45,30 @@
4345
import_role:
4446
name: ansible-cartridge
4547
vars:
46-
cartridge_app_config_path: './configs/config-yml-avsc'
48+
cartridge_app_config_path: './configs/config-yml-avsc/config'
4749
expected_test_section: {config-dir-key: yml-avsc}
4850

4951
###############
5052
# ERROR CASES #
5153
###############
5254

55+
# Folder config with "model.avsc" to test incorrect folder configs with the same names
56+
57+
- name: 'Upload folder config with "model.avsc" only'
58+
ignore_errors: true
59+
import_role:
60+
name: ansible-cartridge
61+
vars:
62+
cartridge_app_config_path: './configs/config-avsc/config'
63+
- name: 'Check upload config failed'
64+
assert:
65+
fail_msg: 'Upload config without config.yml should fail, but config.yml was not removed from previous upload'
66+
success_msg: 'Upload config without config.yml to TDG failed'
67+
that:
68+
- apply_app_config_res.failed
69+
- "'No such file or directory' in apply_app_config_res.msg"
70+
run_once: true
71+
5372
# YAML file config
5473

5574
- name: 'Upload YAML config'

tasks/steps/upload_app_config.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,21 @@
1010
when: cartridge_app_config_path is not none
1111
tags: cartridge-config
1212
block:
13+
- name: 'Remove previously configs'
14+
ansible.builtin.file:
15+
path: '/tmp/tarantool.cartridge.configs/'
16+
state: absent
17+
1318
- name: 'Copy application config on remote host'
1419
any_errors_fatal: true
1520
copy:
1621
src: '{{ cartridge_app_config_path }}'
17-
dest: '/tmp/'
22+
dest: '/tmp/tarantool.cartridge.configs/'
1823

1924
- name: 'Apply application config'
2025
cartridge_apply_app_config:
2126
local_config_path: '{{ cartridge_app_config_path }}'
22-
remote_dir: '/tmp/'
27+
remote_dir: '/tmp/tarantool.cartridge.configs/'
2328
upload_mode: '{{ cartridge_app_config_upload_mode }}'
2429
console_sock: '{{ control_instance.console_sock }}'
2530
upload_url: '{{

0 commit comments

Comments
 (0)