Browse Source

Remove apt-cacher-ng

The repo container's package cache causes quite a bit of confusion
given that it's a 'hidden' feature which catches deployers off-guard
when they already have their own cache configured. This is really
the kind of service which people should manage outside of OSA. It
also makes no sense if the deployer is using their own local mirror
which is a fairly common practise. Adding to that, it seems that it
is broken in bionic, causing massive delays in package installs.
Finally, it also adds to quite a bit of complexity due to the fact
that it's in a container - so in the playbooks prior to the container's
existence we have to detect whether it's there and add/remove the config
accordingly.

Let's just remove it and let deployers managing their own caching
infrastructure if they want it.

Change-Id: I829b9cfa16fbd1f9f4d33b5943f1e46623e1b157
Jesse Pretorius 6 months ago
parent
commit
6663637374

+ 0
- 18
defaults/main.yml View File

@@ -45,27 +45,10 @@ repo_server_port: 8181
45 45
 # Pypi Server port
46 46
 repo_pypiserver_port: 8280
47 47
 
48
-# Toggle the implementation of the Package Cache service
49
-repo_pkg_cache_enabled: true
50
-
51
-# Set the listening port for the Package Cache service
52
-repo_pkg_cache_port: 3142
53
-
54
-# Set the listening address for the Package Cache service
55
-repo_pkg_cache_bind: "0.0.0.0"
56
-
57 48
 # Set the git file paths
58 49
 repo_git_cache_dirname: openstackgit
59 50
 repo_git_cache_dir: "{{ repo_service_home_folder }}/repo/{{ repo_git_cache_dirname }}"
60 51
 
61
-# Set the Package Cache Service files path
62
-repo_pkg_cache_dirname: pkg-cache
63
-repo_pkg_cache_dir: "{{ repo_service_home_folder }}/repo/{{ repo_pkg_cache_dirname }}"
64
-
65
-# Set the Package Cache Service owner and group
66
-repo_pkg_cache_owner: apt-cacher-ng
67
-repo_pkg_cache_group: apt-cacher-ng
68
-
69 52
 # Set the log directory
70 53
 repo_service_log_dir: /var/log/apt-cacher-ng
71 54
 
@@ -94,4 +77,3 @@ repo_pypiserver_start_options: >-
94 77
 
95 78
 # config override var for systemd init file
96 79
 repo_pypiserver_init_overrides: {}
97
-

+ 33
- 11
handlers/main.yml View File

@@ -35,17 +35,6 @@
35 35
   retries: 5
36 36
   delay: 2
37 37
 
38
-- name: reload acng
39
-  service:
40
-    name: "apt-cacher-ng"
41
-    enabled: yes
42
-    state: restarted
43
-    daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}"
44
-  register: _restart
45
-  until: _restart is success
46
-  retries: 5
47
-  delay: 2
48
-
49 38
 - name: reload lsyncd
50 39
   service:
51 40
     name: "lsyncd"
@@ -90,3 +79,36 @@
90 79
   retries: 5
91 80
   delay: 2
92 81
 
82
+# TODO(odyssey4me):
83
+# Remove these tasks in T. They are only present for the
84
+# Q->R upgrade or for R->S upgrades for environments which
85
+# were installed prior to R's release.
86
+- name: Remove apt-cacher-ng package
87
+  package:
88
+    name: apt-cacher-ng
89
+    state: absent
90
+    purge: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}"
91
+  listen:
92
+    - cleanup apt-cacher-ng service
93
+
94
+- name: Remove apt-cacher-ng data folders
95
+  file:
96
+    path: "{{ repo_service_home_folder }}/repo/{{ repo_pkg_cache_dirname | default('pkg-cache') }}"
97
+    state: absent
98
+  listen:
99
+    - cleanup apt-cacher-ng service
100
+
101
+- name: Remove apt-cacher-ng user
102
+  user:
103
+    name: "{{ repo_pkg_cache_owner | default('apt-cacher-ng') }}"
104
+    state: absent
105
+  listen:
106
+    - cleanup apt-cacher-ng service
107
+
108
+- name: Remove apt-cacher-ng group
109
+  group:
110
+    name: "{{ repo_pkg_cache_group | default('apt-cacher-ng') }}"
111
+    state: absent
112
+  listen:
113
+    - cleanup apt-cacher-ng service
114
+

+ 22
- 0
releasenotes/notes/remove-pkg-cache-afba3577138dc0a0.yaml View File

@@ -0,0 +1,22 @@
1
+---
2
+deprecations:
3
+  - |
4
+    The package cache on the repo server has been removed. If caching of
5
+    packages is desired, it should be setup outside of OpenStack-Ansible
6
+    and the variable ``lxc_container_cache_files`` (for LXC containers)
7
+    or ``nspawn_container_cache_files_from_host`` (for nspawn containers)
8
+    can be used to copy the appropriate host configuration from the host
9
+    into the containers on creation. Alternatively, environment variables
10
+    can be set to use the cache in the host /etc/environment file prior
11
+    to container creation, or the ``deployment_environment_variables``
12
+    can have the right variables set to use it. The following variables
13
+    have been removed.
14
+
15
+    * ``repo_pkg_cache_enabled``
16
+    * ``repo_pkg_cache_port``
17
+    * ``repo_pkg_cache_bind``
18
+    * ``repo_pkg_cache_dirname``
19
+    * ``repo_pkg_cache_dir``
20
+    * ``repo_pkg_cache_owner``
21
+    * ``repo_pkg_cache_group``
22
+

+ 0
- 4
tasks/main.yml View File

@@ -36,10 +36,6 @@
36 36
   tags:
37 37
     - repo_server-config
38 38
 
39
-- include: repo_cacher.yml
40
-  static: no
41
-  when: repo_pkg_cache_enabled | bool
42
-
43 39
 - include: repo_key_populate.yml
44 40
   tags:
45 41
     - repo_server-config

+ 0
- 92
tasks/repo_cacher.yml View File

@@ -1,92 +0,0 @@
1
----
2
-# Copyright 2016, Rackspace US, Inc.
3
-#
4
-# Licensed under the Apache License, Version 2.0 (the "License");
5
-# you may not use this file except in compliance with the License.
6
-# You may obtain a copy of the License at
7
-#
8
-#     http://www.apache.org/licenses/LICENSE-2.0
9
-#
10
-# Unless required by applicable law or agreed to in writing, software
11
-# distributed under the License is distributed on an "AS IS" BASIS,
12
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
-# See the License for the specific language governing permissions and
14
-# limitations under the License.
15
-
16
-- name: Install repo caching server packages
17
-  package:
18
-    name: "{{ repo_pkg_cache_server_distro_packages }}"
19
-    state: "{{ repo_server_package_state }}"
20
-  register: install_packages
21
-  until: install_packages is success
22
-  retries: 5
23
-  delay: 5
24
-  when:
25
-    - repo_pkg_cache_enabled | bool
26
-  tags:
27
-    - repo_server-install
28
-
29
-- name: Create cache directory
30
-  file:
31
-    path: "{{ repo_pkg_cache_dir }}"
32
-    state: "directory"
33
-    owner: "{{ repo_pkg_cache_owner }}"
34
-    group: "{{ repo_service_group_name }}"
35
-    mode: "02775"
36
-  tags:
37
-    - repo_server-install
38
-
39
-- name: Create log directory
40
-  file:
41
-    path: "{{ repo_service_log_dir }}"
42
-    state: "directory"
43
-    owner: "{{ repo_pkg_cache_owner }}"
44
-    group: "{{ repo_pkg_cache_group }}"
45
-    mode: "02775"
46
-  tags:
47
-    - repo_server-install
48
-
49
-- name: Stat the cache path
50
-  stat:
51
-    path: /var/cache/apt-cacher-ng
52
-  register: acs
53
-  tags:
54
-    - repo_server-install
55
-
56
-- name: Remove cacher directory if its a directory
57
-  file:
58
-    path: "/var/cache/apt-cacher-ng"
59
-    state: "absent"
60
-  when:
61
-    - acs.stat.isdir is defined and acs.stat.isdir
62
-  tags:
63
-    - repo_server-install
64
-
65
-- name: Link cacher to the repo path
66
-  file:
67
-    src: "{{ repo_service_home_folder }}/repo/pkg-cache"
68
-    dest: "/var/cache/apt-cacher-ng"
69
-    state: "link"
70
-  tags:
71
-    - repo_server-install
72
-
73
-- name: Create yum merged mirror list
74
-  shell: |
75
-    curl https://www.centos.org/download/full-mirrorlist.csv | sed 's/^.*"http:/http:/' | sed 's/".*$//' | grep ^http >/etc/apt-cacher-ng/centos_mirrors
76
-    echo "http://mirror.centos.org/centos/" >>/etc/apt-cacher-ng/centos_mirrors
77
-  args:
78
-    warn: no
79
-  when:
80
-    - ansible_pkg_mgr == 'yum'
81
-  tags:
82
-    - repo_server-config
83
-    - skip_ansible_lint
84
-
85
-- name: Drop acng.conf
86
-  template:
87
-    src: "acng.conf.j2"
88
-    dest: "/etc/apt-cacher-ng/acng.conf"
89
-  notify:
90
-    - reload acng
91
-  tags:
92
-    - repo_server-config

+ 1
- 1
tasks/repo_install.yml View File

@@ -32,7 +32,7 @@
32 32
     gpgcheck: yes
33 33
     enabled: yes
34 34
     state: present
35
-    includepkgs: 'apt-cacher-ng lsyncd'
35
+    includepkgs: 'lsyncd'
36 36
   when:
37 37
     - ansible_pkg_mgr in ['yum', 'dnf']
38 38
   register: install_epel_repo

+ 20
- 1
tasks/repo_sync_manager.yml View File

@@ -22,8 +22,27 @@
22 22
     - { src: "lsyncd.defaults.j2", dest: "{{ repo_lsyncd_defaults_file }}" }
23 23
   notify:
24 24
     - reload lsyncd
25
+    - cleanup apt-cacher-ng service
25 26
   when:
26
-    - groups['repo_all']|length > 1
27
+    - groups['repo_all'] | length > 1
27 28
   tags:
28 29
     - repo-lsyncd
29 30
     - repo-config
31
+
32
+# TODO(odyssey4me):
33
+# Remove this task in T. It is only present for the
34
+# Q->R upgrade or for R->S upgrades for environments which
35
+# were installed prior to R's release.
36
+# It is implemented as a handler to prevent the service
37
+# being removed before lsync has restarted with the new
38
+# config. This task in particular cater for when lsync
39
+# is not used because there is only one repo container.
40
+- name: Remove apt-cacher-ng service
41
+  command: "true"
42
+  when:
43
+    - groups['repo_all'] | length == 1
44
+  notify:
45
+    - cleanup apt-cacher-ng service
46
+  tags:
47
+    - skip_ansible_lint
48
+

+ 0
- 31
templates/acng.conf.j2 View File

@@ -1,31 +0,0 @@
1
-# {{ ansible_managed }}
2
-
3
-CacheDir: {{ repo_pkg_cache_dir }}
4
-LogDir: /var/log/apt-cacher-ng
5
-Port: {{ repo_pkg_cache_port }}
6
-BindAddress: {{ repo_pkg_cache_bind }}
7
-Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian # Debian Archives
8
-Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu # Ubuntu Archives
9
-Remap-debvol: file:debvol_mirror*.gz /debian-volatile ; file:backends_debvol # Debian Volatile Archives
10
-Remap-cygwin: file:cygwin_mirrors /cygwin # ; file:backends_cygwin # incomplete, please create this file or specify preferred mirrors here
11
-Remap-sfnet:  file:sfnet_mirrors # ; file:backends_sfnet # incomplete, please create this file or specify preferred mirrors here
12
-Remap-alxrep: file:archlx_mirrors /archlinux # ; file:backend_archlx # Arch Linux
13
-Remap-fedora: file:fedora_mirrors # Fedora Linux
14
-Remap-slrep:  file:sl_mirrors # Scientific Linux
15
-Remap-centos: file:centos_mirrors /centos #centos
16
-ReportPage: acng-report.html
17
-PidFile: /var/run/apt-cacher-ng
18
-ExTreshold: 4
19
-LocalDirs: acng-doc /usr/share/doc/apt-cacher-ng
20
-PassThroughPattern: .*
21
-{% if proxy_env_url is defined %}
22
-Proxy: {{ proxy_env_url }}
23
-{% endif %}
24
-VfilePatternEx: ^/\?release=[0-9]+&arch=
25
-# NOTE(mhayden): Caching the CentOS mirror list causes yum to throw
26
-# 503 errors intermittently since the remote file is dynamic. Also,
27
-# yum has issues with retrieving the mariadb.org repodata bz2 and
28
-# that causes more intermittent 503 errors. This DontCache line
29
-# tells apt-cacher-ng to allow requests for these to pass through
30
-# without being cached.
31
-DontCache: (mirrorlist\.centos\.org)|(mariadb\.org.*\.bz2$)

+ 1
- 16
templates/lsyncd.lua.j2 View File

@@ -593,7 +593,7 @@ sync {
593 593
     rsync,
594 594
     source = "{{ repo_service_home_folder }}/repo",
595 595
     target = "{{ hostvars[node]['ansible_host'] }}:{{ repo_service_home_folder }}/repo",
596
-    exclude = {"{{ repo_pkg_cache_dirname }}", "{{ repo_git_cache_dir }}"},
596
+    exclude = {"{{ repo_git_cache_dir }}"},
597 597
     rsync = {
598 598
         compress = true,
599 599
         acls = true,
@@ -614,20 +614,5 @@ sync {
614 614
         postcmd = "sudo {{ repo_service_home_folder }}/repo/repo_prepost_cmd.sh post-git"
615 615
     }
616 616
 }
617
-{% if repo_pkg_cache_enabled | bool %}
618
-sync {
619
-    rsync,
620
-    source = "{{ repo_pkg_cache_dir }}",
621
-    target = "{{ hostvars[node]['ansible_host'] }}:{{ repo_pkg_cache_dir }}",
622
-    delete = false,
623
-    rsync = {
624
-        compress = true,
625
-        acls = true,
626
-        rsh = "/usr/bin/ssh -l {{ repo_service_user_name }} -i {{ repo_service_home_folder }}/.ssh/id_rsa -o StrictHostKeyChecking=no -o ServerAliveInterval=30 -o ServerAliveCountMax=5",
627
-        precmd = "sudo {{ repo_service_home_folder }}/repo/repo_prepost_cmd.sh pre-pkg",
628
-        postcmd = "sudo {{ repo_service_home_folder }}/repo/repo_prepost_cmd.sh post-pkg"
629
-    }
630
-}
631
-{% endif %}
632 617
 {% endif %}
633 618
 {% endfor %}

+ 0
- 15
templates/repo_prepost_cmd.sh.j2 View File

@@ -1,15 +1,6 @@
1 1
 #!/bin/bash
2 2
 #  This script is called by lsyncd to perform 'pre' and 'post' rsync tasks.
3 3
 #
4
-PKG_CACHE={{ repo_pkg_cache_dir }}
5
-
6
-function chg_owner {
7
-  NEW_OWNER=$1
8
-  if [ -d $PKG_CACHE ]; then
9
-    chown -R $NEW_OWNER $PKG_CACHE
10
-  fi
11
-}
12
-
13 4
 CMD=$1
14 5
 case $CMD in
15 6
 pre-www)
@@ -26,12 +17,6 @@ pre-git)
26 17
 post-git)
27 18
   systemctl start git.socket
28 19
   ;;
29
-pre-pkg)
30
-  chg_owner {{ repo_service_user_name }}
31
-  ;;
32
-post-pkg)
33
-  chg_owner {{ repo_pkg_cache_owner }}
34
-  ;;
35 20
 *)
36 21
   echo "Unknown command."
37 22
 esac

+ 0
- 9
tests/test-repo-server-functional.yml View File

@@ -58,12 +58,3 @@
58 58
         dest: /tmp/repo_server
59 59
         version: master
60 60
         accept_hostkey: yes
61
-
62
-    - name: Check apt-cacher-ng is running
63
-      command: "pgrep apt-cacher-ng"
64
-      register: pgrep_apt_cacher_ng
65
-      until: pgrep_apt_cacher_ng is success
66
-      retries: 5
67
-      delay: 2
68
-      tags:
69
-        - skip_ansible_lint

+ 0
- 3
vars/debian.yml View File

@@ -27,9 +27,6 @@ repo_server_distro_packages:
27 27
   - openssh-server
28 28
   - rsync
29 29
 
30
-repo_pkg_cache_server_distro_packages:
31
-  - apt-cacher-ng
32
-
33 30
 repo_lsyncd_config_file: /etc/lsyncd/lsyncd.conf.lua
34 31
 repo_lsyncd_defaults_file: /etc/default/lsyncd
35 32
 

+ 0
- 3
vars/redhat.yml View File

@@ -29,9 +29,6 @@ repo_server_distro_packages:
29 29
   - openssh-server
30 30
   - rsync
31 31
 
32
-repo_pkg_cache_server_distro_packages:
33
-  - apt-cacher-ng
34
-
35 32
 repo_lsyncd_config_file: /etc/lsyncd.conf
36 33
 repo_lsyncd_defaults_file: /etc/sysconfig/lsyncd
37 34
 

+ 0
- 3
vars/suse.yml View File

@@ -28,9 +28,6 @@ repo_server_distro_packages:
28 28
   - openssh
29 29
   - rsync
30 30
 
31
-repo_pkg_cache_server_distro_packages:
32
-  - apt-cacher-ng
33
-
34 31
 repo_lsyncd_config_file: /etc/lsyncd/lsyncd.conf
35 32
 repo_lsyncd_defaults_file: /etc/sysconfig/lsyncd
36 33
 

Loading…
Cancel
Save