From 17b51240c9b37fa67bc47803195d3802168b4994 Mon Sep 17 00:00:00 2001
From: David Leadbeater <dgl@dgl.cx>
Date: Tue, 12 Dec 2023 01:41:13 +1100
Subject: [PATCH] Remove legacy crio packaging cleanup (#10702)

This has now been removed and results in a 404 when trying to remove the
old key, even if it's not present.
---
 .../container-engine/cri-o/defaults/main.yml  |   4 -
 .../container-engine/cri-o/tasks/cleanup.yaml | 125 ------------------
 roles/container-engine/cri-o/tasks/main.yaml  |   3 -
 3 files changed, 132 deletions(-)
 delete mode 100644 roles/container-engine/cri-o/tasks/cleanup.yaml

diff --git a/roles/container-engine/cri-o/defaults/main.yml b/roles/container-engine/cri-o/defaults/main.yml
index 21de17aeb..f20108f86 100644
--- a/roles/container-engine/cri-o/defaults/main.yml
+++ b/roles/container-engine/cri-o/defaults/main.yml
@@ -69,10 +69,6 @@ youki_runtime:
   type: oci
   root: /run/youki
 
-# TODO(cristicalin): remove this after 2.21
-crio_download_base: "download.opensuse.org/repositories/devel:kubic:libcontainers:stable"
-crio_download_crio: "http://{{ crio_download_base }}:/cri-o:/"
-
 # Reserve 16M uids and gids for user namespaces (256 pods * 65536 uids/gids)
 # at the end of the uid/gid space
 crio_remap_enable: false
diff --git a/roles/container-engine/cri-o/tasks/cleanup.yaml b/roles/container-engine/cri-o/tasks/cleanup.yaml
deleted file mode 100644
index 1675a5b2f..000000000
--- a/roles/container-engine/cri-o/tasks/cleanup.yaml
+++ /dev/null
@@ -1,125 +0,0 @@
----
-# TODO(cristicalin): drop this file after 2.21
-- name: CRI-O kubic repo name for debian os family
-  set_fact:
-    crio_kubic_debian_repo_name: "{{ ((ansible_distribution == 'Ubuntu') | ternary('x', '')) ~ ansible_distribution ~ '_' ~ ansible_distribution_version }}"
-  when: ansible_os_family == "Debian"
-
-- name: Remove legacy CRI-O kubic apt repo key
-  apt_key:
-    url: "https://{{ crio_download_base }}/{{ crio_kubic_debian_repo_name }}/Release.key"
-    state: absent
-  environment: "{{ proxy_env }}"
-  when: crio_kubic_debian_repo_name is defined
-
-- name: Remove legacy CRI-O kubic apt repo
-  apt_repository:
-    repo: "deb http://{{ crio_download_base }}/{{ crio_kubic_debian_repo_name }}/ /"
-    state: absent
-    filename: devel-kubic-libcontainers-stable
-  when: crio_kubic_debian_repo_name is defined
-
-- name: Remove legacy CRI-O kubic cri-o apt repo
-  apt_repository:
-    repo: "deb {{ crio_download_crio }}{{ crio_version }}/{{ crio_kubic_debian_repo_name }}/ /"
-    state: absent
-    filename: devel-kubic-libcontainers-stable-cri-o
-  when: crio_kubic_debian_repo_name is defined
-
-- name: Remove legacy CRI-O kubic yum repo
-  yum_repository:
-    name: devel_kubic_libcontainers_stable
-    description: Stable Releases of Upstream github.com/containers packages (CentOS_$releasever)
-    baseurl: http://{{ crio_download_base }}/CentOS_{{ ansible_distribution_major_version }}/
-    state: absent
-  when:
-    - ansible_os_family == "RedHat"
-    - ansible_distribution not in ["Amazon", "Fedora"]
-
-- name: Remove legacy CRI-O kubic yum repo
-  yum_repository:
-    name: "devel_kubic_libcontainers_stable_cri-o_{{ crio_version }}"
-    description: "CRI-O {{ crio_version }} (CentOS_$releasever)"
-    baseurl: "{{ crio_download_crio }}{{ crio_version }}/CentOS_{{ ansible_distribution_major_version }}/"
-    state: absent
-  when:
-    - ansible_os_family == "RedHat"
-    - ansible_distribution not in ["Amazon", "Fedora"]
-
-- name: Remove legacy CRI-O kubic yum repo
-  yum_repository:
-    name: devel_kubic_libcontainers_stable
-    description: Stable Releases of Upstream github.com/containers packages
-    baseurl: http://{{ crio_download_base }}/Fedora_{{ ansible_distribution_major_version }}/
-    state: absent
-  when:
-    - ansible_distribution in ["Fedora"]
-    - not is_ostree
-
-- name: Remove legacy CRI-O kubic yum repo
-  yum_repository:
-    name: "devel_kubic_libcontainers_stable_cri-o_{{ crio_version }}"
-    description: "CRI-O {{ crio_version }}"
-    baseurl: "{{ crio_download_crio }}{{ crio_version }}/Fedora_{{ ansible_distribution_major_version }}/"
-    state: absent
-  when:
-    - ansible_distribution in ["Fedora"]
-    - not is_ostree
-
-- name: Remove legacy CRI-O kubic yum repo
-  yum_repository:
-    name: devel_kubic_libcontainers_stable
-    description: Stable Releases of Upstream github.com/containers packages
-    baseurl: http://{{ crio_download_base }}/CentOS_7/
-    state: absent
-  when: ansible_distribution in ["Amazon"]
-
-- name: Remove legacy CRI-O kubic yum repo
-  yum_repository:
-    name: "devel_kubic_libcontainers_stable_cri-o_{{ crio_version }}"
-    description: "CRI-O {{ crio_version }}"
-    baseurl: "{{ crio_download_crio }}{{ crio_version }}/CentOS_7/"
-    state: absent
-  when: ansible_distribution in ["Amazon"]
-
-- name: Disable modular repos for CRI-O
-  community.general.ini_file:
-    path: "/etc/yum.repos.d/{{ item.repo }}.repo"
-    section: "{{ item.section }}"
-    option: enabled
-    value: 0
-    mode: 0644
-  become: true
-  when: is_ostree
-  loop:
-    - repo: "fedora-updates-modular"
-      section: "updates-modular"
-    - repo: "fedora-modular"
-      section: "fedora-modular"
-
-# Disable any older module version if we enabled them before
-- name: Disable CRI-O ex module
-  command: "rpm-ostree ex module disable cri-o:{{ item }}"
-  become: true
-  when:
-    - is_ostree
-    - ostree_version is defined and ostree_version.stdout is version('2021.9', '>=')
-  with_items:
-    - 1.22
-    - 1.23
-    - 1.24
-
-- name: Cri-o | remove installed packages
-  package:
-    name: "{{ item }}"
-    state: absent
-  when: not is_ostree
-  with_items:
-    - cri-o
-    - cri-o-runc
-    - oci-systemd-hook
-
-- name: CRI-O | Remove CRI-O package configuration files
-  file:
-    name: /etc/crio/crio.conf.d/01-crio-runc.conf
-    state: absent
diff --git a/roles/container-engine/cri-o/tasks/main.yaml b/roles/container-engine/cri-o/tasks/main.yaml
index f5df97467..60c818a55 100644
--- a/roles/container-engine/cri-o/tasks/main.yaml
+++ b/roles/container-engine/cri-o/tasks/main.yaml
@@ -27,9 +27,6 @@
   import_tasks: "setup-amazon.yaml"
   when: ansible_distribution in ["Amazon"]
 
-- name: Cri-o | clean up reglacy repos
-  import_tasks: "cleanup.yaml"
-
 - name: Cri-o | build a list of crio runtimes with Katacontainers runtimes
   set_fact:
     crio_runtimes: "{{ crio_runtimes + kata_runtimes }}"
-- 
GitLab