From 75085b8fa94a78fe4f2901dcbb5d544a93aca5c0 Mon Sep 17 00:00:00 2001 From: Elio Bischof Date: Mon, 27 Jun 2022 14:43:13 +0200 Subject: [PATCH] fix: disable gpg checks for https yum repos --- internal/operator/nodeagent/dep/k8s/common.go | 2 +- .../nodeagent/dep/package-manager-init.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/internal/operator/nodeagent/dep/k8s/common.go b/internal/operator/nodeagent/dep/k8s/common.go index 7262d35a2..e0f95e5ab 100644 --- a/internal/operator/nodeagent/dep/k8s/common.go +++ b/internal/operator/nodeagent/dep/k8s/common.go @@ -55,7 +55,7 @@ name=Kubernetes baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=1 -repo_gpgcheck=1 +repo_gpgcheck=0 gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg`), 0644); err != nil { return err } diff --git a/internal/operator/nodeagent/dep/package-manager-init.go b/internal/operator/nodeagent/dep/package-manager-init.go index 73bf3b7be..abeaa4944 100644 --- a/internal/operator/nodeagent/dep/package-manager-init.go +++ b/internal/operator/nodeagent/dep/package-manager-init.go @@ -2,6 +2,7 @@ package dep import ( "bytes" + "errors" "fmt" "os" "os/exec" @@ -38,8 +39,23 @@ func (p *PackageManager) remSpecificInit() error { ) } +func (p *PackageManager) remSpecificDisableGPGRepoCheckForGcloudRepo() error { + + repoSpecPath := "/etc/yum.repos.d/google-cloud.repo" + if _, err := os.Stat(repoSpecPath); errors.Is(err, os.ErrNotExist) { + // Do nothing if repo file doesn't exist + return nil + } + + return exec.Command("sed", "-i", "s/repo_gpgcheck=1/repo_gpgcheck=0/g", repoSpecPath).Run() +} + func (p *PackageManager) remSpecificUpdatePackages() error { + if err := p.remSpecificDisableGPGRepoCheckForGcloudRepo(); err != nil { + return err + } + conflictingCronFile := "/etc/cron.daily/yumupdate.sh" removeConflictingCronFile := true _, err := os.Stat(conflictingCronFile)