Skip to content

Commit f486a95

Browse files
authored
Merge pull request #16755 from justinsb/dpkg_was_interrupted
nodeup: if apt-get tells us to run dpkg configure, run it
2 parents 9d08e4e + 9adfb36 commit f486a95

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

tests/e2e/pkg/tester/skip_regex.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (t *Tester) setSkipRegexFlag() error {
105105

106106
if cluster.Spec.LegacyCloudProvider == "digitalocean" {
107107
skipRegex += "|Services.should.respect.internalTrafficPolicy=Local.Pod.and.Node,.to.Pod"
108-
if k8sVersion.Minor < 31 {
108+
if k8sVersion.Minor < 32 {
109109
// https://github.com/kubernetes/kubernetes/issues/121018
110110
skipRegex += "|Services.should.function.for.service.endpoints.using.hostNetwork"
111111
}
@@ -147,7 +147,7 @@ func (t *Tester) setSkipRegexFlag() error {
147147
// Dedicated job testing this: https://testgrid.k8s.io/kops-misc#kops-aws-k28-hostname-bug123255
148148
// ref: https://github.com/kubernetes/kops/issues/16349
149149
// ref: https://github.com/kubernetes/kubernetes/issues/123255
150-
if k8sVersion.Minor < 31 {
150+
if k8sVersion.Minor < 32 {
151151
skipRegex += "|Services.should.function.for.service.endpoints.using.hostNetwork"
152152
}
153153

upup/pkg/fi/nodeup/nodetasks/package.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,22 @@ func (_ *Package) RenderLocal(t *local.LocalTarget, a, e, changes *Package) erro
346346
cmd.Env = env
347347
output, err := cmd.CombinedOutput()
348348
if err != nil {
349+
// This is a bit of a hack, but if we get an error that says we need to run dpkg configure, we run it.
350+
// The typical cause is that we install a package that kills nodeup,
351+
// also killing apt-get, and then apt-get is in a bad state.
352+
// Typical error looks like this:
353+
// exit status 100: E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem.
354+
if strings.Contains(string(output), "dpkg --configure -a") {
355+
klog.Warningf("found error requiring dpkg repair: %q", string(output))
356+
args := []string{"dpkg", "--configure", "-a"}
357+
klog.Infof("running command %s", args)
358+
cmd := exec.Command(args[0], args[1:]...)
359+
dpkgOutput, err := cmd.CombinedOutput()
360+
if err != nil {
361+
return fmt.Errorf("error running `dpkg --configure -a`: %v: %s", err, string(dpkgOutput))
362+
}
363+
// Note that we still return an error, because our package installation failed; we will retry.
364+
}
349365
return fmt.Errorf("error installing package %q: %v: %s", e.Name, err, string(output))
350366
}
351367
} else {

0 commit comments

Comments
 (0)