Skip to content

Commit

Permalink
Merge pull request #416 from spinolacastro/fix_labels
Browse files Browse the repository at this point in the history
Fix node labeling. Issue #305
  • Loading branch information
wshearn committed Aug 13, 2015
2 parents d307f71 + 7a12b21 commit cd989f6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
11 changes: 11 additions & 0 deletions filter_plugins/oo_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ def oo_combine_key_value(data, joiner='='):
rval.append("%s%s%s" % (item['key'], joiner, item['value']))

return rval

@staticmethod
def oo_combine_dict(data, in_joiner='=', out_joiner=' '):
'''Take a dict in the form of { 'key': 'value', 'key': 'value' } and
arrange them as a string 'key=value key=value'
'''
if not issubclass(type(data), dict):
raise errors.AnsibleFilterError("|failed expects first param is a dict")

return out_joiner.join([ in_joiner.join([k, v]) for k, v in data.items() ])

@staticmethod
def oo_ami_selector(data, image_name):
Expand Down Expand Up @@ -309,6 +319,7 @@ def filters(self):
"oo_ami_selector": self.oo_ami_selector,
"oo_ec2_volume_definition": self.oo_ec2_volume_definition,
"oo_combine_key_value": self.oo_combine_key_value,
"oo_combine_dict": self.oo_combine_dict,
"oo_split": self.oo_split,
"oo_filter_list": self.oo_filter_list,
"oo_parse_heat_stack_outputs": self.oo_parse_heat_stack_outputs
Expand Down
2 changes: 1 addition & 1 deletion playbooks/common/openshift-node/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
vars:
openshift_nodes: "{{ hostvars
| oo_select_keys(groups['oo_nodes_to_config'])
| oo_collect('openshift.common.hostname') }}"
| oo_collect('openshift.common.hostname') }}"
openshift_unscheduleable_nodes: "{{ hostvars | oo_select_keys(groups['oo_nodes_to_config'] | default([]))
| oo_collect('openshift.common.hostname', {'openshift_scheduleable': False}) }}"
pre_tasks:
Expand Down
8 changes: 8 additions & 0 deletions roles/openshift_manage_node/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@
command: >
{{ openshift.common.admin_binary }} manage-node {{ item }} --schedulable=true
with_items: openshift_scheduleable_nodes

- name: Label nodes
command: >
{{ openshift.common.client_binary }} label --overwrite node {{ item }} {{ hostvars[item]['openshift_node_labels'] | oo_combine_dict }}
with_items:
- "{{ openshift_nodes }}"
when:
"'openshift_node_labels' in hostvars[item]"
12 changes: 12 additions & 0 deletions roles/openshift_node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ openshift_common
Example Playbook
----------------

Notes
-----

Currently we support re-labeling nodes but we don't re-schedule running pods nor remove existing labels. That means you will have to trigger the re-schedulling manually. To re-schedule your pods, just follow the steps below:

```
oadm manage-node --schedulable=false ${NODE}
oadm manage-node --evacuate ${NODE}
oadm manage-node --schedulable=true ${NODE}
````


TODO

License
Expand Down

0 comments on commit cd989f6

Please sign in to comment.