Skip to content

Commit f70dc3a

Browse files
jaimecbsk4zuzu
andauthored
F #129: Add Rank and DRS scheduler support (#130)
Signed-off-by: Jaime Conchello <[email protected]> Signed-off-by: Michal Opala <[email protected]> Co-authored-by: Michal Opala <[email protected]>
1 parent f47e94d commit f70dc3a

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed

roles/opennebula/server/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Role Variables
2626
| `db_password` | `str` | `opennebula` | | Password used by OpenNebula to authenticate the user. |
2727
| `gate_endpoint` | `str` | conditional | (check below) | An URL used to reach the OneGate endpoint (HTTP). |
2828
| `admin_pubkey` | `str` | loaded | (check below) | SSH pubkey loaded from `/var/lib/one/.ssh/id_rsa.pub`, provided by the user (as string) or ignored when `null`. |
29+
| `sched_rank` | `dict` | undefined | (check below) | Rank scheduler configuration. |
30+
| `sched_drs` | `dict` | undefined | (check below) | OpenNebula Distributed Resource Scheduler configuration. |
2931

3032
Dependencies
3133
------------
@@ -39,6 +41,35 @@ Example Playbook
3941
vars:
4042
gate_endpoint: "http://10.11.12.13:5030"
4143
admin_pubkey: null # ignore it
44+
45+
sched_rank:
46+
DIFFERENT_VNETS: false
47+
48+
DEFAULT_SCHED:
49+
POLICY: 3
50+
RANK: "- (RUNNING_VMS * 50 + FREE_CPU)"
51+
52+
sched_drs:
53+
PREDICTIVE: 0.3
54+
MEMORY_SYSTEM_DS_SCALE: 0
55+
DIFFERENT_VNETS: true
56+
DEFAULT_SCHED:
57+
SOLVER: "CBC"
58+
SOLVER_PATH: "/usr/lib/one/python/pulp/solverdir/cbc/linux/64/cbc"
59+
60+
PLACE:
61+
POLICY: "PACK"
62+
63+
OPTIMIZE:
64+
POLICY: "BALANCE"
65+
MIGRATION_THRESHOLD: 10
66+
WEIGHTS:
67+
CPU_USAGE: 0.2
68+
CPU: 0.2
69+
MEMORY: 0.4
70+
DISK: 0.1
71+
NET: 0.1
72+
4273
roles:
4374
- role: opennebula.deploy.helper.facts
4475
- role: opennebula.deploy.database

roles/opennebula/server/tasks/config.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,99 @@
126126
MONITOR_ADDRESS\g<1>= "{{ one_vip }}"\g<2>
127127
notify:
128128
- Restart OpenNebula
129+
130+
- when: sched_drs is mapping
131+
block:
132+
- name: Check if drs configuration exists
133+
ansible.builtin.stat:
134+
path: /etc/one/schedulers/one_drs.conf
135+
get_attributes: false
136+
get_checksum: false
137+
get_mime: false
138+
register: stat_drs_conf
139+
140+
# NOTE: Adding global unknown/custom options has no effect!
141+
- name: Configure drs scheduler
142+
ansible.builtin.replace:
143+
path: /etc/one/schedulers/one_drs.conf
144+
regexp: '^{{ item.key }}:[\s\S]*?(?=\n^\w+:|\Z)'
145+
replace: "{{ {item.key: item.value} | to_nice_yaml(indent=2) }}"
146+
loop: "{{ sched_drs | dict2items }}"
147+
when: stat_drs_conf.stat.exists is true
148+
149+
- when: sched_rank is mapping
150+
block:
151+
- name: Check if rank configuration exists
152+
ansible.builtin.stat:
153+
path: /etc/one/schedulers/rank.conf
154+
get_attributes: false
155+
get_checksum: false
156+
get_mime: false
157+
register: stat_rank_conf
158+
159+
# NOTE: Adding global unknown/custom options has no effect!
160+
- name: Configure rank scheduler
161+
ansible.builtin.replace:
162+
path: /etc/one/schedulers/rank.conf
163+
regexp: "{{ item.regexp | d(omit) }}"
164+
replace: "{{ item.replace | d(omit) }}"
165+
loop: "{{ _rank_config | selectattr('update') | list }}"
166+
vars:
167+
_rank_config:
168+
- regexp: 'MEMORY_SYSTEM_DS_SCALE( *)= *.*([\s])$'
169+
update: "{{ sched_rank.MEMORY_SYSTEM_DS_SCALE is defined }}"
170+
replace: >-
171+
MEMORY_SYSTEM_DS_SCALE\g<1>= {{ sched_rank.MEMORY_SYSTEM_DS_SCALE | d(omit) }}\g<2>
172+
- regexp: 'MAX_HOST( *)= *.*([\s])$'
173+
update: "{{ sched_rank.MAX_HOST is defined }}"
174+
replace: >-
175+
MAX_HOST\g<1>= {{ sched_rank.MAX_HOST | d(omit) }}\g<2>
176+
- regexp: 'DIFFERENT_VNETS( *)= *.*([\s])$'
177+
update: "{{ sched_rank.DIFFERENT_VNETS is defined }}"
178+
replace: >-
179+
DIFFERENT_VNETS\g<1>= {{ ("YES" if (sched_rank.DIFFERENT_VNETS | d(omit) | bool) else "NO") }}\g<2>
180+
- regexp: '^(DEFAULT_SCHED( *)= *\[)[\S\s]*?(\])$'
181+
update: "{{ sched_rank.DEFAULT_SCHED is defined }}"
182+
replace: |-
183+
\g<1>
184+
{% if sched_rank.DEFAULT_SCHED.POLICY | d(false) %}
185+
POLICY = {{ sched_rank.DEFAULT_SCHED.POLICY | d(omit) }}
186+
{% endif %}
187+
{% if sched_rank.DEFAULT_SCHED.RANK | d(false) %}
188+
RANK = "{{ sched_rank.DEFAULT_SCHED.RANK | d(omit) }}"
189+
{% endif %}
190+
\g<3>
191+
- regexp: '^(DEFAULT_DS_SCHED( *)= *\[)[\S\s]*?(\])$'
192+
update: "{{ sched_rank.DEFAULT_DS_SCHED is defined }}"
193+
replace: |-
194+
\g<1>
195+
{% if sched_rank.DEFAULT_DS_SCHED.POLICY | d(false) %}
196+
POLICY = {{ sched_rank.DEFAULT_DS_SCHED.POLICY | d(omit) }}
197+
{% endif %}
198+
{% if sched_rank.DEFAULT_DS_SCHED.RANK | d(false) %}
199+
RANK = "{{ sched_rank.DEFAULT_DS_SCHED.RANK | d(omit) }}"
200+
{% endif %}
201+
\g<3>
202+
- regexp: '^(DEFAULT_NIC_SCHED( *)= *\[)[\S\s]*?(\])$'
203+
update: "{{ sched_rank.DEFAULT_NIC_SCHED is defined }}"
204+
replace: |-
205+
\g<1>
206+
{% if sched_rank.DEFAULT_NIC_SCHED.POLICY | d(false) %}
207+
POLICY = {{ sched_rank.DEFAULT_NIC_SCHED.POLICY | d(omit) }}
208+
{% endif %}
209+
{% if sched_rank.DEFAULT_NIC_SCHED.RANK | d(false) %}
210+
RANK = "{{ sched_rank.DEFAULT_NIC_SCHED.RANK | d(omit) }}"
211+
{% endif %}
212+
\g<3>
213+
- regexp: '^(LOG( *)= *\[)[\S\s]*?(\])$'
214+
update: "{{ sched_rank.LOG is defined }}"
215+
replace: |-
216+
\g<1>
217+
{% if sched_rank.LOG.SYSTEM | d(false) %}
218+
SYSTEM = "{{ sched_rank.LOG.SYSTEM | d(omit) }}"
219+
{% endif %}
220+
{% if sched_rank.LOG.DEBUG_LEVEL | d(false) %}
221+
DEBUG_LEVEL = {{ sched_rank.LOG.DEBUG_LEVEL | d(omit) }}
222+
{% endif %}
223+
\g<3>
224+
when: stat_rank_conf.stat.exists is true

0 commit comments

Comments
 (0)