{"action":"created","issue":{"url":"https://api.github.com/repos/saltstack/salt/issues/24502","labels_url":"https://api.github.com/repos/saltstack/salt/issues/24502/labels{/name}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/24502/comments","events_url":"https://api.github.com/repos/saltstack/salt/issues/24502/events","html_url":"https://github.com/saltstack/salt/issues/24502","id":86224084,"number":24502,"title":"schedule.present state do not persist to disk on minion","user":{"login":"Grokzen","id":892309,"avatar_url":"https://avatars.githubusercontent.com/u/892309?v=3","gravatar_id":"","url":"https://api.github.com/users/Grokzen","html_url":"https://github.com/Grokzen","followers_url":"https://api.github.com/users/Grokzen/followers","following_url":"https://api.github.com/users/Grokzen/following{/other_user}","gists_url":"https://api.github.com/users/Grokzen/gists{/gist_id}","starred_url":"https://api.github.com/users/Grokzen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Grokzen/subscriptions","organizations_url":"https://api.github.com/users/Grokzen/orgs","repos_url":"https://api.github.com/users/Grokzen/repos","events_url":"https://api.github.com/users/Grokzen/events{/privacy}","received_events_url":"https://api.github.com/users/Grokzen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/saltstack/salt/labels/Bug","name":"Bug","color":"e11d21"},{"url":"https://api.github.com/repos/saltstack/salt/labels/Core","name":"Core","color":"006b75"},{"url":"https://api.github.com/repos/saltstack/salt/labels/High%20Severity","name":"High Severity","color":"ff9143"},{"url":"https://api.github.com/repos/saltstack/salt/labels/P2","name":"P2","color":"155fb5"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/saltstack/salt/milestones/13","html_url":"https://github.com/saltstack/salt/milestones/Approved","labels_url":"https://api.github.com/repos/saltstack/salt/milestones/13/labels","id":9265,"number":13,"title":"Approved","description":"All issues that are ready to be worked on, both bugs and features.","creator":{"login":"thatch45","id":507599,"avatar_url":"https://avatars.githubusercontent.com/u/507599?v=3","gravatar_id":"","url":"https://api.github.com/users/thatch45","html_url":"https://github.com/thatch45","followers_url":"https://api.github.com/users/thatch45/followers","following_url":"https://api.github.com/users/thatch45/following{/other_user}","gists_url":"https://api.github.com/users/thatch45/gists{/gist_id}","starred_url":"https://api.github.com/users/thatch45/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thatch45/subscriptions","organizations_url":"https://api.github.com/users/thatch45/orgs","repos_url":"https://api.github.com/users/thatch45/repos","events_url":"https://api.github.com/users/thatch45/events{/privacy}","received_events_url":"https://api.github.com/users/thatch45/received_events","type":"User","site_admin":false},"open_issues":2355,"closed_issues":2141,"state":"open","created_at":"2011-05-14T04:00:56Z","updated_at":"2015-06-11T23:31:53Z","due_on":null,"closed_at":null},"comments":7,"created_at":"2015-06-08T15:32:04Z","updated_at":"2015-06-11T23:35:31Z","closed_at":null,"body":"If i have the following state on my master:\r\n\r\n```yaml\r\ncheck:\r\n  schedule.present:\r\n    - function: test.ping\r\n    - seconds: 30\r\n    - splay: 8\r\n    - return_job: true\r\n```\r\n\r\nand i run `state.highstate` on a fresh minion on a fresh machine that has never runned it before, the state will write the file `/etc/salt/minion.d/_schedule.conf` containing the new schedule.\r\n\r\nAfter that i decided that i wanted to change the time to some other values, for example: \r\n\r\n```yaml\r\ncheck:\r\n  schedule.present:\r\n    - function: test.ping\r\n    - seconds: 60\r\n    - splay: 12\r\n    - return_job: true\r\n```\r\n\r\nand i again run `state.highstate` i will get the following output \r\n\r\n```\r\n          ID: check\r\n    Function: schedule.present\r\n      Result: True\r\n     Comment: Modifying job check in schedule\r\n     Started: 17:08:23.806123\r\n    Duration: 40.089 ms\r\n     Changes:   \r\n              ----------\r\n              diff:\r\n                  --- \r\n                  +++ \r\n                  @@ -3,5 +3,5 @@\r\n                   maxrunning:1\r\n                   name:check\r\n                   return_job:True\r\n                  -seconds:30\r\n                  -splay:8\r\n                  +seconds:60\r\n                  +splay:12\r\n```\r\n\r\nbut the problem is that the file `/etc/salt/minion.d/_schedule.conf` is never written again so when i restart the minion it will default back to the original schedule item that was written the first time and i have to run `state.highstate` again for the schedule to again be updated and used.\r\n\r\nThe strange thing is that the schedule is updated after the highstate and it is using the new config that is somehow stored in runtime but not on disk.\r\n\r\nAfter some digging in the schedule module i see that it is only persisting to disk in `add_job()` https://github.com/saltstack/salt/blob/develop/salt/utils/schedule.py#L403 but in other functions like https://github.com/saltstack/salt/blob/develop/salt/utils/schedule.py#L441 i see no `persist()` call.\r\n\r\nExpected result would be that it should write down the config to disk because highstate returns that config was changed.\r\n\r\nWorkaround i have found so far is that once you have added a job and you want to update a job is to acctually go into the minion and edit `/etc/salt/minion.d/_schedule.conf` and remove the line with the old job and then rerun `state.highstate` again to push out the new job. I guess this can be done with some other fancy cmd.run state to remove it. Not even `salt '*' state.single schedule.absent check` removes the job from the persisted file, even if the state says it was removed and when the minion is restarted again the schedule starts again.\r\n\r\n```\r\n# salt --versions-report\r\n           Salt: 2015.5.1\r\n         Python: 2.7.9 (default, May 20 2015, 09:02:19)\r\n         Jinja2: 2.7.2\r\n       M2Crypto: 0.22\r\n msgpack-python: 0.4.6\r\n   msgpack-pure: Not Installed\r\n       pycrypto: 2.6.1\r\n        libnacl: Not Installed\r\n         PyYAML: 3.11\r\n          ioflo: Not Installed\r\n          PyZMQ: 14.0.1\r\n           RAET: Not Installed\r\n            ZMQ: 4.0.3\r\n           Mako: Not Installed\r\n```"},"comment":{"url":"https://api.github.com/repos/saltstack/salt/issues/comments/111306878","html_url":"https://github.com/saltstack/salt/issues/24502#issuecomment-111306878","issue_url":"https://api.github.com/repos/saltstack/salt/issues/24502","id":111306878,"user":{"login":"garethgreenaway","id":718525,"avatar_url":"https://avatars.githubusercontent.com/u/718525?v=3","gravatar_id":"","url":"https://api.github.com/users/garethgreenaway","html_url":"https://github.com/garethgreenaway","followers_url":"https://api.github.com/users/garethgreenaway/followers","following_url":"https://api.github.com/users/garethgreenaway/following{/other_user}","gists_url":"https://api.github.com/users/garethgreenaway/gists{/gist_id}","starred_url":"https://api.github.com/users/garethgreenaway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garethgreenaway/subscriptions","organizations_url":"https://api.github.com/users/garethgreenaway/orgs","repos_url":"https://api.github.com/users/garethgreenaway/repos","events_url":"https://api.github.com/users/garethgreenaway/events{/privacy}","received_events_url":"https://api.github.com/users/garethgreenaway/received_events","type":"User","site_admin":false},"created_at":"2015-06-11T23:35:30Z","updated_at":"2015-06-11T23:35:30Z","body":"@dragonpaw My mistake.  There a function in the schedule module but looks like I didn't add the ability to save for the state module.  Will add that in.  Also makes sense that the other functions should persist too just like add_job."}}