Skip to content

Commit bee8d8c

Browse files
Merge pull request openstack-k8s-operators#801 from openstack-k8s-operators/update/kpatch
Enable kpatch support for update
2 parents 54dd49f + 6f77a83 commit bee8d8c

File tree

13 files changed

+173
-43
lines changed

13 files changed

+173
-43
lines changed

.github/workflows/molecule.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ jobs:
4444
- edpm_timezone
4545
- edpm_telemetry
4646
- edpm_telemetry_logging
47-
- edpm_update
4847
- edpm_users
4948
- env_data
5049
- edpm_pre_adoption_validation

roles/edpm_update/defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
# All variables intended for modification should be placed in this file.
1919

20+
# Toggle to enable/disable kpatch usage
21+
edpm_update_enable_kpatch: false
22+
2023
# Toggle to enable/disable packages updates
2124
edpm_update_enable_packages_update: true
2225

roles/edpm_update/molecule/default/Containerfile.j2

Lines changed: 0 additions & 14 deletions
This file was deleted.

roles/edpm_update/molecule/default/molecule.yml

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,24 @@ dependency:
44
options:
55
role-file: collections.yml
66
driver:
7-
name: podman
7+
name: delegated
8+
options:
9+
managed: false
10+
ansible_connection_options:
11+
ansible_connection: local
812
platforms:
9-
- command: /sbin/init
10-
dockerfile: Containerfile.j2
11-
image: ${EDPM_ANSIBLE_MOLECULE_IMAGE:-"ubi9/ubi-init"}
12-
name: instance
13-
privileged: true
14-
registry:
15-
url: ${EDPM_ANSIBLE_MOLECULE_REGISTRY:-"registry.access.redhat.com"}
16-
ulimits:
17-
- host
13+
- name: edpm-0.localdomain
14+
groups:
15+
- compute
1816
provisioner:
1917
log: true
2018
name: ansible
21-
inventory:
22-
hosts:
23-
all:
24-
hosts:
25-
instance:
26-
canonical_hostname: edpm-0.localdomain
19+
2720
scenario:
2821
test_sequence:
29-
- dependency
30-
- destroy
31-
- create
32-
- prepare
33-
- converge
34-
- verify
35-
- cleanup
36-
- destroy
22+
- prepare
23+
- converge
24+
- cleanup
25+
- destroy
3726
verifier:
3827
name: ansible

roles/edpm_update/molecule/default/prepare.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
# License for the specific language governing permissions and limitations
1515
# under the License.
1616

17+
- name: Prepare test_deps
18+
hosts: all
19+
gather_facts: false
20+
roles:
21+
- role: ../../../../molecule/common/test_deps
22+
test_deps_setup_edpm: true
23+
test_deps_setup_stream: true
1724

1825
- name: Prepare
1926
hosts: all
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
# Copyright 2024 Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
18+
- name: Converge
19+
hosts: all
20+
gather_facts: false
21+
tasks:
22+
- name: "Call edpm_update role"
23+
ansible.builtin.include_role:
24+
name: osp.edpm.edpm_update
25+
vars:
26+
edpm_update_enable_containers_update: false
27+
edpm_service_types: []
28+
edpm_update_enable_kpatch: true
29+
30+
# We have to run the verifications in this play to
31+
# ensure we have access to the internally changed
32+
# facts.
33+
- name: Conduct some verifications
34+
block:
35+
- name: Ensure kernel related packages are excluded
36+
ansible.builtin.assert:
37+
that:
38+
- _exclude_packages is defined
39+
- "'kernel' in _exclude_packages"
40+
- "'kernel-core' in _exclude_packages"
41+
42+
- name: Gather all installed packages
43+
ansible.builtin.package_facts:
44+
45+
- name: Check service status if we have kpatch-patch installed
46+
when:
47+
- ansible_facts.packages["kpatch-patch"] is defined
48+
block:
49+
- name: Gather services
50+
ansible.builtin.service_facts:
51+
52+
- name: Ensure kpatch.service is running
53+
ansible.builtin.assert:
54+
that:
55+
- ansible_facts.services['kpatch.service'] is defined
56+
- ansible_facts.services['kpatch.service'].state == 'running'
57+
- ansible_facts.services['kpatch.service'].status == 'enabled'
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
dependency:
3+
name: galaxy
4+
options:
5+
role-file: collections.yml
6+
driver:
7+
name: delegated
8+
options:
9+
managed: false
10+
ansible_connection_options:
11+
ansible_connection: local
12+
platforms:
13+
- name: edpm-0.localdomain
14+
groups:
15+
- compute
16+
provisioner:
17+
log: true
18+
name: ansible
19+
20+
scenario:
21+
test_sequence:
22+
- prepare
23+
- converge
24+
- cleanup
25+
- destroy
26+
verifier:
27+
name: ansible
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
# Copyright 2024 Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
- name: Run prepare playbook
18+
ansible.builtin.import_playbook: ../default/prepare.yml

roles/edpm_update/tasks/kpatch.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
- name: Ensure we know about kernel version
3+
when:
4+
- ansible_facts['kernel'] is undefined
5+
ansible.builtin.setup:
6+
gather_subset:
7+
- '!all,!min'
8+
- 'kernel'
9+
10+
- name: Ensure kpatch package is installed
11+
become: true
12+
ansible.builtin.package:
13+
name: kpatch
14+
state: present
15+
16+
- name: Install kpatch-patch if available # noqa: package-latest
17+
failed_when: false
18+
become: true
19+
ansible.builtin.package:
20+
name: "kpatch-patch = {{ ansible_facts['kernel'] }}"
21+
state: latest
22+
23+
- name: Ensure further update stages will not update kernel
24+
vars:
25+
_kernel:
26+
- kernel
27+
- kernel-core
28+
ansible.builtin.set_fact:
29+
_exclude_packages: "{{ edpm_update_exclude_packages + _kernel }}"

roles/edpm_update/tasks/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
# "edpm_update" will search for and load any operating system variable file
1919

20+
- name: Apply kernel patch via kpatch
21+
ansible.builtin.include_tasks: kpatch.yml
22+
when: edpm_update_enable_kpatch
23+
2024
- name: Update packages
2125
ansible.builtin.include_tasks: packages.yml
2226
when: edpm_update_enable_packages_update

0 commit comments

Comments
 (0)