Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix node labeling. Issue #305 #416

Merged
merged 5 commits into from
Aug 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions filter_plugins/oo_filters.py
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
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
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
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