-
Notifications
You must be signed in to change notification settings - Fork 26
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
Schedule module: creating an excess task #23
Comments
So far, I've solved the problem by adding a task that will delete all the schedules before adding them, but this is a temporary crutch, and not a normal solution, as it seems to me. - name: proxysql - clean proxysql scheduler
community.mysql.mysql_query:
login_user: "{{ proxysql.admin.user }}"
login_password: "{{ proxysql.admin.password }}"
login_host: 127.0.0.1
login_port: "{{ proxysql.admin.listen.port.plain | int }}"
query:
- "DELETE FROM scheduler"
- "SAVE SCHEDULER TO DISK"
tags:
- proxysql-scheduler
- name: proxysql - configure scheduler
proxysql_scheduler:
login_user: "{{ proxysql.admin.user }}"
login_password: "{{ proxysql.admin.password }}"
login_port: "{{ proxysql.admin.listen.port.plain | int }}"
filename: "{{ proxysql.path.lib }}/{{ item.bin }}"
interval_ms: "{{ item.interval }}"
...
|
SELECT count(*) AS `schedule_count`
FROM scheduler
WHERE active = %s
AND interval_ms = %s
AND filename = %s""" so when you request the same task-parameters just with current scheduler table looks like this CREATE TABLE scheduler (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1,
interval_ms INTEGER CHECK (interval_ms>=100 AND interval_ms<=100000000) NOT NULL,
filename VARCHAR NOT NULL,
arg1 VARCHAR,
arg2 VARCHAR,
arg3 VARCHAR,
arg4 VARCHAR,
arg5 VARCHAR,
comment VARCHAR NOT NULL DEFAULT '') say you got this
and request - name: some scheduler task
proxysql_scheduler:
filename: /opt/lib/proxysql/replica_check
interval_ms: 5000
arg1: "127.0.0.1"
arg2: 7030
arg3: 2
arg4: error
arg5: /opt/log/proxysql/replica_check.log
state: present
active: yes
load_to_runtime: true
save_to_disk: true it is undefined if you want a)
or b)
the current implementation treats Another possibility is to abuse the Any other ideas or opinions about this? @akimrx @Andersson007 |
CC @bmildren |
Can we:
|
True. And update a scheduler task happens only when an |
or when a user defined it originally (is it possible to set it when creating the task?), they can manipulate tasks using those ids later |
But it's always a good idea to have info modules. It's also possible to create one |
I'm personally in favor of one module like |
Yes, I think it is possible. I just wanted to point out, if the |
Yes and, imo, it should be reflected in the documentation |
Do we still need a - name: Add a schedule
community.proxysql.proxysql_scheduler:
login_user: 'admin'
login_password: 'admin'
interval_ms: 1000
filename: "/opt/maintenance.py"
state: present
load_to_runtime: False
- name: readout
community.proxysql.proxysql_info:
login_user: admin
login_password: admin
register: proxysql_information
- debug:
var: proxysql_information.scheduler
results in
So the only task here is to fix the module itself, and not to add a _info module. |
Sounds very sensible to me |
here we discussed the behaviour of adding or updating schedule tasks and decided to fallback to a new Say now, we ended up here
and we'll request (basically from the example section) - name: remove scheduler task
proxysql_scheduler:
filename: /opt/lib/proxysql/replica_check
config_file: '~/proxysql.cnf'
state: absent Currently the module will fail because it found more than one rule. https://github.com/ansible-collections/community.proxysql/blob/main/plugins/modules/proxysql_scheduler.py#L391 To keep backwards compatiblity, we must create a 2nd And maybe we should think about to deprecate the current |
is this possible? |
|
SUMMARY
Hi there. As you can see, I have only one scheduled task in the playbook and I just wanted to turn it off. Instead of updating an existing task, the module created a new one. This, unfortunately, does not have the effect that would be expected from disabling, because the old job still exists.
Also, if I want to change, for example, the interval for a task, the module will simply create a new one, thus generating exactly the same task and now it will be executed even more often.
The task I'm running:
Task result:
Scheduler table from ProxySQL:
ISSUE TYPE
COMPONENT NAME
proxysql_scheduler
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Darwin macbook-pro 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64
RECOMMENDATIONS
I think it is necessary to add the
id
for the scheduled task. That is, just as it is done in the query rules module --rule_id
.That is:
The text was updated successfully, but these errors were encountered: