Skip to content

Commit

Permalink
fix: make image pre pull failure block the kubernetes update
Browse files Browse the repository at this point in the history
If the wrong version of the kubernetes components is used it won't bring
down any pods as the upgrade will stop on the pre-pull phase.

Signed-off-by: Artem Chernyshev <[email protected]>
  • Loading branch information
Unix4ever committed Jul 19, 2024
1 parent b8db949 commit 23fb0c1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 deletions.
15 changes: 2 additions & 13 deletions cmd/integration-test/pkg/tests/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,8 @@ func AssertKubernetesUpgradeIsRevertible(testCtx context.Context, st state.State
assert.Equal(currentKubernetesVersion, r.TypedSpec().Value.LastUpgradeVersion, resourceDetails(r))
})

// verify that the upgrade took one API server down
rtestutils.AssertResources(ctx, t, st, []resource.ID{clusterName}, func(r *omni.KubernetesStatus, assert *assert.Assertions) {
var notReadyAPIServers int

for _, nodePods := range r.TypedSpec().Value.StaticPods {
for _, pod := range nodePods.StaticPods {
if pod.App == "kube-apiserver" && !pod.Ready {
notReadyAPIServers++
}
}
}

assert.Equal(1, notReadyAPIServers)
rtestutils.AssertResources(ctx, t, st, []resource.ID{clusterName}, func(r *omni.ImagePullStatus, assert *assert.Assertions) {
assert.Contains(r.TypedSpec().Value.LastProcessedError, "-bad")
})

t.Log("revert an upgrade")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,31 @@ func (p PullTaskSpec) RunTask(ctx context.Context, _ *zap.Logger, pullStatusCh P
currentNode = imageList.Node

for _, img := range imageList.Images {
currentError = nil
currentImage = img
currentNum++

if nodeImageInfoMap.shouldPull(imageList.Node, img) {
currentError = p.pullImage(ctx, clusterID, imageList.Node, img)
if currentError != nil {
errs = multierror.Append(errs, currentError)
}

if !channel.SendWithContext(ctx, pullStatusCh, PullStatus{
Request: p.request,
Node: currentNode,
Image: currentImage,
CurrentNum: currentNum,
TotalNum: totalNum,
Error: currentError,
}) {
return errs
}

if !nodeImageInfoMap.shouldPull(imageList.Node, img) {
currentNum++

continue
}

currentError = p.pullImage(ctx, clusterID, imageList.Node, img)
if currentError == nil {
currentNum++
} else {
errs = multierror.Append(errs, currentError)
}

if !channel.SendWithContext(ctx, pullStatusCh, PullStatus{
Request: p.request,
Node: currentNode,
Image: currentImage,
CurrentNum: currentNum,
TotalNum: totalNum,
Error: currentError,
}) {
return errs
}
}
}
Expand Down

0 comments on commit 23fb0c1

Please sign in to comment.