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

[release/v1.7] Clean yum caches when configuring repos #3147

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions pkg/scripts/os_amzn.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ echo -n "${yum_proxy}" >> /tmp/yum.conf
sudo mv /tmp/yum.conf /etc/yum.conf

{{ if .CONFIGURE_REPOSITORIES }}
# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned
# repositories, otherwise, yum will fail to upgrade the packages because it's trying to
# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1).
repo_migration_needed=false

if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then
repo_migration_needed=true
fi

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
Expand All @@ -62,10 +53,11 @@ gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/{{ .KUBERNETES_MAJOR_MINOR }}/rpm/repodata/repomd.xml.key
EOF

if [[ $repo_migration_needed == "true" ]]; then
sudo yum clean all
sudo yum makecache
fi
# We must clean 'yum' cache upon changing the package repository
# because older 'yum' versions (e.g. CentOS and Amazon Linux 2)
# don't detect the change otherwise.
sudo yum clean all
sudo yum makecache
{{ end }}

sudo yum install -y \
Expand Down
18 changes: 5 additions & 13 deletions pkg/scripts/os_centos.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ echo -n "${yum_proxy}" >> /tmp/yum.conf
sudo mv /tmp/yum.conf /etc/yum.conf

{{ if .CONFIGURE_REPOSITORIES }}
# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned
# repositories, otherwise, yum will fail to upgrade the packages because it's trying to
# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1).
repo_migration_needed=false

if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then
repo_migration_needed=true
fi

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
Expand All @@ -68,10 +59,11 @@ if [ "$ID" == "centos" ] && [ "$VERSION_ID" == "8" ]; then
sudo sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
fi

if [[ $repo_migration_needed == "true" ]]; then
sudo yum clean all
sudo yum makecache
fi
# We must clean 'yum' cache upon changing the package repository
# because older 'yum' versions (e.g. CentOS and Amazon Linux 2)
# don't detect the change otherwise.
sudo yum clean all
sudo yum makecache
{{ end }}

sudo yum install -y \
Expand Down
18 changes: 5 additions & 13 deletions pkg/scripts/testdata/TestKubeadmAmazonLinux-force.golden
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ echo -n "${yum_proxy}" >> /tmp/yum.conf
sudo mv /tmp/yum.conf /etc/yum.conf


# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned
# repositories, otherwise, yum will fail to upgrade the packages because it's trying to
# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1).
repo_migration_needed=false

if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then
repo_migration_needed=true
fi

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
Expand All @@ -71,10 +62,11 @@ gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.26/rpm/repodata/repomd.xml.key
EOF

if [[ $repo_migration_needed == "true" ]]; then
sudo yum clean all
sudo yum makecache
fi
# We must clean 'yum' cache upon changing the package repository
# because older 'yum' versions (e.g. CentOS and Amazon Linux 2)
# don't detect the change otherwise.
sudo yum clean all
sudo yum makecache


sudo yum install -y \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ echo -n "${yum_proxy}" >> /tmp/yum.conf
sudo mv /tmp/yum.conf /etc/yum.conf


# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned
# repositories, otherwise, yum will fail to upgrade the packages because it's trying to
# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1).
repo_migration_needed=false

if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then
repo_migration_needed=true
fi

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
Expand All @@ -71,10 +62,11 @@ gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.26/rpm/repodata/repomd.xml.key
EOF

if [[ $repo_migration_needed == "true" ]]; then
sudo yum clean all
sudo yum makecache
fi
# We must clean 'yum' cache upon changing the package repository
# because older 'yum' versions (e.g. CentOS and Amazon Linux 2)
# don't detect the change otherwise.
sudo yum clean all
sudo yum makecache


sudo yum install -y \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ echo -n "${yum_proxy}" >> /tmp/yum.conf
sudo mv /tmp/yum.conf /etc/yum.conf


# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned
# repositories, otherwise, yum will fail to upgrade the packages because it's trying to
# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1).
repo_migration_needed=false

if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then
repo_migration_needed=true
fi

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
Expand All @@ -71,10 +62,11 @@ gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.26/rpm/repodata/repomd.xml.key
EOF

if [[ $repo_migration_needed == "true" ]]; then
sudo yum clean all
sudo yum makecache
fi
# We must clean 'yum' cache upon changing the package repository
# because older 'yum' versions (e.g. CentOS and Amazon Linux 2)
# don't detect the change otherwise.
sudo yum clean all
sudo yum makecache


sudo yum install -y \
Expand Down
18 changes: 5 additions & 13 deletions pkg/scripts/testdata/TestKubeadmAmazonLinux-proxy.golden
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ echo -n "${yum_proxy}" >> /tmp/yum.conf
sudo mv /tmp/yum.conf /etc/yum.conf


# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned
# repositories, otherwise, yum will fail to upgrade the packages because it's trying to
# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1).
repo_migration_needed=false

if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then
repo_migration_needed=true
fi

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
Expand All @@ -71,10 +62,11 @@ gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.26/rpm/repodata/repomd.xml.key
EOF

if [[ $repo_migration_needed == "true" ]]; then
sudo yum clean all
sudo yum makecache
fi
# We must clean 'yum' cache upon changing the package repository
# because older 'yum' versions (e.g. CentOS and Amazon Linux 2)
# don't detect the change otherwise.
sudo yum clean all
sudo yum makecache


sudo yum install -y \
Expand Down
18 changes: 5 additions & 13 deletions pkg/scripts/testdata/TestKubeadmAmazonLinux-simple.golden
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ echo -n "${yum_proxy}" >> /tmp/yum.conf
sudo mv /tmp/yum.conf /etc/yum.conf


# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned
# repositories, otherwise, yum will fail to upgrade the packages because it's trying to
# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1).
repo_migration_needed=false

if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then
repo_migration_needed=true
fi

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
Expand All @@ -71,10 +62,11 @@ gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.26/rpm/repodata/repomd.xml.key
EOF

if [[ $repo_migration_needed == "true" ]]; then
sudo yum clean all
sudo yum makecache
fi
# We must clean 'yum' cache upon changing the package repository
# because older 'yum' versions (e.g. CentOS and Amazon Linux 2)
# don't detect the change otherwise.
sudo yum clean all
sudo yum makecache


sudo yum install -y \
Expand Down
18 changes: 5 additions & 13 deletions pkg/scripts/testdata/TestKubeadmAmazonLinux-v1.26.0.golden
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ echo -n "${yum_proxy}" >> /tmp/yum.conf
sudo mv /tmp/yum.conf /etc/yum.conf


# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned
# repositories, otherwise, yum will fail to upgrade the packages because it's trying to
# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1).
repo_migration_needed=false

if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then
repo_migration_needed=true
fi

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
Expand All @@ -71,10 +62,11 @@ gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.26/rpm/repodata/repomd.xml.key
EOF

if [[ $repo_migration_needed == "true" ]]; then
sudo yum clean all
sudo yum makecache
fi
# We must clean 'yum' cache upon changing the package repository
# because older 'yum' versions (e.g. CentOS and Amazon Linux 2)
# don't detect the change otherwise.
sudo yum clean all
sudo yum makecache


sudo yum install -y \
Expand Down
18 changes: 5 additions & 13 deletions pkg/scripts/testdata/TestKubeadmAmazonLinux-with_cilium.golden
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ echo -n "${yum_proxy}" >> /tmp/yum.conf
sudo mv /tmp/yum.conf /etc/yum.conf


# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned
# repositories, otherwise, yum will fail to upgrade the packages because it's trying to
# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1).
repo_migration_needed=false

if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then
repo_migration_needed=true
fi

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
Expand All @@ -71,10 +62,11 @@ gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.26/rpm/repodata/repomd.xml.key
EOF

if [[ $repo_migration_needed == "true" ]]; then
sudo yum clean all
sudo yum makecache
fi
# We must clean 'yum' cache upon changing the package repository
# because older 'yum' versions (e.g. CentOS and Amazon Linux 2)
# don't detect the change otherwise.
sudo yum clean all
sudo yum makecache


sudo yum install -y \
Expand Down
18 changes: 5 additions & 13 deletions pkg/scripts/testdata/TestKubeadmAmazonLinux-with_containerd.golden
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ echo -n "${yum_proxy}" >> /tmp/yum.conf
sudo mv /tmp/yum.conf /etc/yum.conf


# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned
# repositories, otherwise, yum will fail to upgrade the packages because it's trying to
# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1).
repo_migration_needed=false

if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then
repo_migration_needed=true
fi

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
Expand All @@ -71,10 +62,11 @@ gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.26/rpm/repodata/repomd.xml.key
EOF

if [[ $repo_migration_needed == "true" ]]; then
sudo yum clean all
sudo yum makecache
fi
# We must clean 'yum' cache upon changing the package repository
# because older 'yum' versions (e.g. CentOS and Amazon Linux 2)
# don't detect the change otherwise.
sudo yum clean all
sudo yum makecache


sudo yum install -y \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ echo -n "${yum_proxy}" >> /tmp/yum.conf
sudo mv /tmp/yum.conf /etc/yum.conf


# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned
# repositories, otherwise, yum will fail to upgrade the packages because it's trying to
# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1).
repo_migration_needed=false

if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then
repo_migration_needed=true
fi

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
Expand All @@ -71,10 +62,11 @@ gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.26/rpm/repodata/repomd.xml.key
EOF

if [[ $repo_migration_needed == "true" ]]; then
sudo yum clean all
sudo yum makecache
fi
# We must clean 'yum' cache upon changing the package repository
# because older 'yum' versions (e.g. CentOS and Amazon Linux 2)
# don't detect the change otherwise.
sudo yum clean all
sudo yum makecache


sudo yum install -y \
Expand Down
18 changes: 5 additions & 13 deletions pkg/scripts/testdata/TestKubeadmCentOS-cilium_cluster.golden
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ echo -n "${yum_proxy}" >> /tmp/yum.conf
sudo mv /tmp/yum.conf /etc/yum.conf


# Rebuilding the yum cache is required upon migrating from the legacy to the community-owned
# repositories, otherwise, yum will fail to upgrade the packages because it's trying to
# use old revisions (e.g. 1.27.0-0 instead of 1.27.5-150500.1.1).
repo_migration_needed=false

if sudo grep -q "packages.cloud.google.com" /etc/yum.repos.d/kubernetes.repo; then
repo_migration_needed=true
fi

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
Expand All @@ -77,10 +68,11 @@ if [ "$ID" == "centos" ] && [ "$VERSION_ID" == "8" ]; then
sudo sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
fi

if [[ $repo_migration_needed == "true" ]]; then
sudo yum clean all
sudo yum makecache
fi
# We must clean 'yum' cache upon changing the package repository
# because older 'yum' versions (e.g. CentOS and Amazon Linux 2)
# don't detect the change otherwise.
sudo yum clean all
sudo yum makecache


sudo yum install -y \
Expand Down
Loading