[BUG] salt schedule does not work masterless, `offline` required
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
Salt scheduler does not work when minion configured in masterless, in order to add a job to schedule the offline: true argument is required in the state. Despite that, once added, in order to list the job with salt-call offline=true is needed but is not possible to run the job on demand, for schedule.run_job offline is not a valid argument.
The job is not found. schedule.show_next_fire_time also does not work.
And also it seems it's not executed on scheduled time either.
PS C:\Windows\system32> salt-call schedule.list offline=true
local:
schedule:
schedule_temp_folder_fix:
args:
- myapp.myapp_temp_folder
enabled: true
function: state.sls
jid_include: true
kwargs:
queue: true
saltenv: base
maxrunning: 1
name: schedule_temp_folder_fix
return_job: false
saved: true
when:
- Wednesday 11:55am
PS C:\Windows\system32> salt-call schedule.run_job schedule_temp_folder_fix
local:
----------
comment:
Job schedule_temp_folder_fix does not exist.
result:
False
PS C:\Windows\system32> salt-call schedule.run_job schedule_temp_folder_fix offline=true
The following keyword arguments are not valid: offline=True
schedule.show_next_fire_time does not work either:
PS C:\Windows\system32> salt-call schedule.add schedule_temp_folder_fix function='state.sls' args='["tanium.tanium_temp_folder"]' kwargs='{"saltenv": "base", "queue": true}' maxrunning=1 when='Tuesday 6:50am' offline=true
local:
----------
changes:
----------
schedule_temp_folder_fix:
added
comment:
Added job: schedule_temp_folder_fix to schedule.
result:
True
PS C:\Windows\system32> salt-call schedule.show_next_fire_time schedule_temp_folder_fix
Passed invalid arguments: argument of type 'NoneType' is not iterable.
Usage:
Show the next fire time for scheduled job
.. versionadded:: 2018.3.0
CLI Example:
.. code-block:: bash
salt '*' schedule.show_next_fire_time job_name
Setup
minion in masterless setup with schedule job
file_client: local
use_master_when_local: false
file_roots:
base:
- 'G:\\salt\\states'
log_level_logfile: debug
scheduler_before_connect: true
Steps to Reproduce the behavior
- Configure minion in masterless
- Run state to add job or add it with salt-call, without
offline=trueit fails
PS C:\Windows\system32> salt-call schedule.add schedule_temp_folder_fix function='state.sls' args='["myapp.myapp_temp_folder"]' kwargs='{"saltenv": "base", "queue": true}' maxrunning=1 when='Wednesday 11:55am'
local:
----------
changes:
----------
comment:
Failed to add job schedule_temp_folder_fix to schedule.
result:
False
{%- set schedule_date_time = 'Wednesday 11:55am' %}
{%- set state_file_path = 'myapp.myapp_temp_folder' %}
{%- set job_kwargs = {} %}
{%- do job_kwargs.update({'saltenv': 'base','queue': True}) %}
schedule_temp_folder_fix:
schedule.present:
- function: state.sls
- job_args:
- {{ state_file_path }}
- job_kwargs: {{ job_kwargs }}
- enabled: true
- return_job: false
- offline: true #OFFLINE TRUE
- when:
- {{schedule_date_time }}
salt-call schedule.add schedule_temp_folder_fix function='state.sls' args='["myapp.myapp_temp_folder"]' kwargs='{"saltenv": "base", "queue": true}' maxrunning=1 when='Wednesday 11:55am' offline=true
Expected behavior
Given the minion is already set in masterless, I would expect offline to not be required. And more important, the schedule job should run on demand, which it seems not possible due schedule.run_job does not accept offline arg.
Versions Report
3006.7 at leasst
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the masterless setup with the listed salt-call schedule.add, schedule.list, schedule.run_job, and schedule.show_next_fire_time commands, including offline=true. Trace the scheduler handling for these entry points and the schedule.present state. Done means jobs can be added, listed, inspected, run on demand, and executed on schedule without requiring offline in an already masterless configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli, devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100