-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport][v0.7] Patch cgroup drivers (switch to systemd) (#2200)
* Backported patching cgroup drivers
- Loading branch information
Showing
12 changed files
with
232 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 11 additions & 4 deletions
15
core/src/epicli/data/common/ansible/playbooks/roles/docker/defaults/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
core/src/epicli/data/common/ansible/playbooks/roles/docker/handlers/main.yml
This file was deleted.
Oops, something went wrong.
21 changes: 4 additions & 17 deletions
21
core/src/epicli/data/common/ansible/playbooks/roles/docker/tasks/configure-docker.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
core/src/epicli/data/common/ansible/playbooks/roles/docker/tasks/update-daemon-config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
- name: Stat /etc/docker/daemon.json | ||
stat: | ||
path: /etc/docker/daemon.json | ||
get_attributes: false | ||
get_checksum: false | ||
get_mime: false | ||
register: stat_etc_docker_daemon_json | ||
|
||
- name: Read /etc/docker/daemon.json | ||
slurp: | ||
path: /etc/docker/daemon.json | ||
register: slurp_etc_docker_daemon_json | ||
when: | ||
- stat_etc_docker_daemon_json.stat.exists | ||
|
||
- name: Process /etc/docker/daemon.json | ||
set_fact: | ||
etc_docker_daemon_json: | ||
output: "{{ _output }}" | ||
changed: "{{ _changed }}" | ||
reload: "{{ _reload }}" | ||
restart: "{{ _restart }}" | ||
vars: | ||
# To detect changes we cannot use defaults as inputs here. | ||
_input: >- | ||
{{ (slurp_etc_docker_daemon_json.content | b64decode | from_json) | ||
if slurp_etc_docker_daemon_json.content is defined else | ||
{} }} | ||
# This role is used directly during both "apply" and "upgrade" runs. | ||
# In the case of "upgrade" we have to accept what we find on the target machine and | ||
# make corrections to "exec-opts" later in a separate procedure (inside the "upgrade" role). | ||
# In the case of "apply" it is just fine to overwrite the whole document with defaults. | ||
_output: >- | ||
{{ (docker_daemon_defaults | dict2items | ||
| rejectattr('key', '==', 'exec-opts') | ||
| list | ||
| items2dict | ||
| combine(_input, recursive=true)) | ||
if is_upgrade_run else | ||
docker_daemon_defaults }} | ||
_changed: >- | ||
{{ _output != _input }} | ||
# Restart is too much to handle changes to "insecure-registries". | ||
_reload: >- | ||
{{ _changed and (not _restart) }} | ||
# Reload is not enough to handle changes to "exec-opts". | ||
_restart: >- | ||
{{ _changed and (_input['exec-opts'] | default([]) != _output['exec-opts'] | default([])) }} | ||
- name: Write config and reload/restart Docker | ||
when: | ||
- etc_docker_daemon_json.changed | ||
block: | ||
- name: Ensure directory /etc/docker/ exists | ||
file: | ||
path: /etc/docker/ | ||
state: directory | ||
owner: root | ||
group: root | ||
mode: u=rwx,go=rx | ||
|
||
# NOTE: Previously a "template" task was used here instead, but | ||
# it has proven to provide insufficient idempotency (unnecessary docker restarts). | ||
- name: Write /etc/docker/daemon.json | ||
copy: | ||
dest: /etc/docker/daemon.json | ||
content: | | ||
{{ etc_docker_daemon_json.output | to_nice_json(indent=2) }} | ||
owner: root | ||
group: root | ||
mode: u=rw,go=r | ||
|
||
- name: Reload Docker | ||
systemd: | ||
name: docker | ||
state: reloaded | ||
when: | ||
- etc_docker_daemon_json.reload | ||
|
||
- name: Restart Docker | ||
systemd: | ||
name: docker | ||
state: restarted | ||
when: | ||
- etc_docker_daemon_json.restart |
12 changes: 0 additions & 12 deletions
12
core/src/epicli/data/common/ansible/playbooks/roles/docker/templates/daemon.json.j2
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...icli/data/common/ansible/playbooks/roles/upgrade/tasks/kubernetes/patch-cgroup-driver.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
# A standalone version of this procedure can be found in tools/development/k8s/memory/patch_cgroup_driver/. | ||
# It has been reported that Epiphany behaves unstable with high resource utilization, this patch seems to be fixing these problems. | ||
|
||
# K8s documentation (https://kubernetes.io/docs/setup/production-environment/container-runtimes/#cgroup-drivers) states: | ||
# > A single cgroup manager simplifies the view of what resources are being allocated and will by default have a more consistent view of the available and in-use resources. | ||
# > When there are two cgroup managers on a system, you end up with two views of those resources. | ||
# > In the field, people have reported cases where nodes that are configured to use cgroupfs for the kubelet and Docker, | ||
# > but systemd for the rest of the processes, become unstable under resource pressure. | ||
|
||
- name: k8s/cgroups | Read /var/lib/kubelet/kubeadm-flags.env | ||
slurp: | ||
path: /var/lib/kubelet/kubeadm-flags.env | ||
register: slurp_var_lib_kubelet_kubeadm_flags_env | ||
|
||
- name: k8s/cgroups | Process /var/lib/kubelet/kubeadm-flags.env | ||
set_fact: | ||
var_lib_kubelet_kubeadm_flags_env: | ||
output: "{{ _output }}" | ||
changed: "{{ _output != _input }}" | ||
vars: | ||
_input: >- | ||
{{ slurp_var_lib_kubelet_kubeadm_flags_env.content | b64decode }} | ||
_output: >- | ||
{{ _input.replace('--cgroup-driver=cgroupfs', '--cgroup-driver=systemd') }} | ||
- name: k8s/cgroups | Read /etc/docker/daemon.json | ||
slurp: | ||
path: /etc/docker/daemon.json | ||
register: slurp_etc_docker_daemon_json | ||
|
||
- name: k8s/cgroups | Process /etc/docker/daemon.json | ||
set_fact: | ||
etc_docker_daemon_json: | ||
output: "{{ _output }}" | ||
changed: "{{ _output['exec-opts'] != _exec_opts }}" | ||
vars: | ||
_input: >- | ||
{{ slurp_etc_docker_daemon_json.content | b64decode | from_json }} | ||
_exec_opts: >- | ||
{{ _input['exec-opts'] | default([]) }} | ||
_update: | ||
exec-opts: >- | ||
{{ _exec_opts | difference(['native.cgroupdriver=cgroupfs']) | union(['native.cgroupdriver=systemd']) }} | ||
_output: >- | ||
{{ _input | combine(_update, recursive=true) }} | ||
- name: k8s/cgroups | Perform cgroup driver patching (switch to systemd) | ||
when: var_lib_kubelet_kubeadm_flags_env.changed or etc_docker_daemon_json.changed | ||
block: | ||
# At this point we assume that currently processed node has been drained already. | ||
|
||
- name: k8s/cgroups | Write /var/lib/kubelet/kubeadm-flags.env | ||
copy: | ||
dest: /var/lib/kubelet/kubeadm-flags.env | ||
content: | | ||
{{ var_lib_kubelet_kubeadm_flags_env.output }} | ||
owner: root | ||
group: root | ||
mode: preserve | ||
|
||
- name: k8s/cgroups | Write /etc/docker/daemon.json | ||
copy: | ||
dest: /etc/docker/daemon.json | ||
content: | | ||
{{ etc_docker_daemon_json.output | to_nice_json(indent=2) }} | ||
owner: root | ||
group: root | ||
mode: preserve | ||
|
||
- name: k8s/cgroups | Restart kubelet and docker | ||
include_tasks: utils/restart-kubelet-and-docker.yml | ||
when: | ||
- (_requires_restart is undefined) or _requires_restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.