-
Notifications
You must be signed in to change notification settings - Fork 4
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
YDBOPS-10613 Dynconfigs #62
base: main
Are you sure you want to change the base?
Changes from 11 commits
ddf842f
40ac992
49a3e08
6c94806
19d5474
216f617
41b0151
568a24f
a31e4c4
4962326
744b9c2
101028a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from ansible.module_utils.basic import AnsibleModule | ||
from ansible_collections.ydb_platform.ydb.plugins.module_utils import cli | ||
|
||
|
||
def main(): | ||
argument_spec=dict( | ||
config=dict(type='str', default=""), | ||
) | ||
cli.YDB.add_arguments(argument_spec) | ||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False) | ||
configFilename = module.params.get('config') | ||
result = {'changed': False} | ||
try: | ||
ydb_cli = cli.YDB.from_module(module) | ||
rc, stdout, stderr = ydb_cli(['admin', 'config', 'replace','-f',configFilename]) | ||
if rc != 0: | ||
result['msg'] = f'command: "ydb admin config replace" failed' | ||
result['stderr'] = stderr | ||
module.fail_json(**result) | ||
|
||
result['msg'] = 'command: "ydb admin config replace" succeeded' | ||
module.exit_json(**result) | ||
|
||
except Exception as e: | ||
result['msg'] = f'unexpected exception: {e}' | ||
module.fail_json(**result) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import re | ||
|
||
# | ||
# This module returns current version of dynamic config | ||
# The result is stored in 'version' variable of returning dict | ||
|
||
from ansible.module_utils.basic import AnsibleModule | ||
from ansible_collections.ydb_platform.ydb.plugins.module_utils import cli | ||
|
||
def main(): | ||
argument_spec=dict( | ||
timeout=dict(type='int', default=180), | ||
) | ||
cli.YDB.add_arguments(argument_spec) | ||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False) | ||
result = {'changed': False, 'version': 0} | ||
try: | ||
ydb_cmd = ['admin', 'config', 'fetch'] | ||
ydb_cli = cli.YDB.from_module(module) | ||
rc, stdout, stderr = ydb_cli(ydb_cmd) | ||
if rc != 0: | ||
# We get 1 exit code if no YAML config in cluster | ||
result['msg'] = f'command: "ydb admin config fetch" failed' | ||
else: | ||
match = re.search(r'version:\s*(\d+)', stdout) | ||
if match: | ||
version = int(match.group(1)) | ||
result['version'] = version | ||
result['msg'] = '' | ||
module.exit_json(**result) | ||
|
||
except Exception as e: | ||
result['msg'] = f'unexpected exception: {e}' | ||
module.fail_json(**result) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
ydb_database_groups: 1 | ||
ydb_request_client_certificate: false | ||
# ydb_use_dynamic_config - define how to configure dynamic nodes - static or dynamic configs | ||
# Default value: false | ||
ydb_use_dynamic_config: false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
ydb_allow_format_drives: false | ||
ydb_skip_data_loss_confirmation_prompt: false | ||
ydb_enforce_user_token_requirement: true | ||
# ydb_use_dynamic_config - define how to configure dynamic nodes - static or dynamic configs | ||
# Default value: false | ||
ydb_use_dynamic_config: false | ||
|
||
# ydb_dynamic_config - path to a custom dynamic config file | ||
# Default value: ansible/roles/ydb_static/ydb-din-config.yaml.j2 | ||
ydb_dynamic_config: ydbd-dyn-config.yaml.j2 | ||
Comment on lines
+8
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's drop this setting because it'd limit the evolution of how all this is implemented under the hood. For instance, you don't really need a template here, you could just have the same object constructed in memory and then serialized to yaml. Otherwise, LGTM. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's designed to have possibility to adjust dynamic config for user needs until we have possibility to change all setting by ansible. Right not we do not provide a way to define labels or other requirements for dynamic nodes. IMHO it will be required by users for there production needs. That's why I think we must let them define their own config. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
metadata: | ||
cluster: "" | ||
version: {{ ydb_dynconfig_info['version'] }} | ||
config: | ||
# This parameter must be set in 'true' | ||
yaml_config_enabled: true | ||
actor_system_config: | ||
# Auto configure node by using number of CPU cores | ||
use_auto_config: true | ||
# Type of the node (HYBRID, COMPUTE, STORAGE) | ||
node_type: COMPUTE | ||
# Number of CPU cores | ||
cpu_count: {{ ydb_cores_dynamic }} | ||
{{ lookup('ansible.builtin.template', '{{ ydb_config }}') | indent( width=2, first=True) }} | ||
allowed_labels: {} | ||
selector_config: [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's time to introduce the concept of playbook feature flags. I don't think we'd want to keep this setting around long-term: it's more like to test this new approach, make it default at some point and then deprecate the current approach. So it could be like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good idea for single roles, but we might have problems in our structure
playbook1 (feature_flag: feature1, feature3) -> role1 (feature_flag: feature1)
playbook1 (feature_flag: feature1, feature3) -> role2 (feature_flag: feature1, feature2)
in this case role2 will lost feature2 default value