---
# Tasks file for slurm-primary-crons


# https://jira.zooxlabs.com/browse/INFRA-7772
- block:
  - name: Reboot sla-gpu901
    cron:
      name: reboot-sla-gpu901
      cron_file: reboot-cron
      user: root
      job: "sudo scontrol reboot ASAP nextstate=resume reason=INFRA-7772 sla-gpu901"
      weekday: "0,3"  # Sunday & Wednesday
      hour: 5         # 5AM

  - name: Reboot sla-gpu902
    cron:
      name: reboot-sla-gpu902
      cron_file: reboot-cron
      user: root
      job: "sudo scontrol reboot ASAP nextstate=resume reason=INFRA-7772 sla-gpu902"
      weekday: "2,5"  # Tuesday & Friday
      hour: 5         # 5AM
  become: yes
  when: slurm_primary_environment == "production"

# Autotune - add cron on Production2 slurm primary controller
- block:
  - name: Autotune - Setup hourly cron job
    cron:
      name: autotune
      minute: "*/10"
      job: "/opt/zoox/autotune/autotune.py --priority=1500 --cluster production2"
      user: root
    tags: autotune
    become: yes
  when: slurm_primary_environment == "production2"

  # Autotune - add cron on Production slurm primary controller
- block:
  - name: Autotune - Setup hourly cron job
    cron:
      name: autotune
      minute: "*/10"
      job: "/opt/zoox/autotune/autotune.py --priority=1500"
      user: root
    tags: autotune
    become: yes
  when: slurm_primary_environment == "production"

# Autotune - add cron on Staging slurm primary controller
- block:
  - name: Autotune - Setup hourly cron job
    cron:
      name: autotune
      minute: "*/10"
      job: "/opt/zoox/autotune/autotune.py --priority=1500 --cluster staging"
      user: root
    tags: autotune
    become: yes
  when: slurm_primary_environment == "staging"

# Autotune - add cron on Staging2 slurm primary controller
- block:
  - name: Autotune - Setup hourly cron job
    cron:
      name: autotune
      minute: "*/10"
      job: "/opt/zoox/autotune/autotune.py --priority=1500 --cluster staging2"
      user: root
    tags: autotune
    become: yes
  when: slurm_primary_environment == "staging2"

- block:
  - name: Setup cron to manage state transitions for cloud burst nodes
    cron:
      name: "State transition graph for cloud burst nodes"
      user: root
      job: "run-one /usr/local/etc/cloud_burst_state_graph.py >> /var/log/slurm/cloud_burst_state_graph.log 2>&1"
      minute: "*/10"
  tags:
    - slurm-reconfigure
    - cloud-burst
  become: yes
