Skip to content

Commit

Permalink
Merge pull request kubernetes#106414 from jonyhy96/kubelet-fix-flake
Browse files Browse the repository at this point in the history
kubelet: fix npe in test
  • Loading branch information
k8s-ci-robot committed Nov 19, 2021
2 parents 9b180d8 + 65ac99e commit ddfc539
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/kubelet/kubelet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2410,9 +2410,12 @@ func TestSyncLabels(t *testing.T) {
}
for _, action := range actions {
if action.GetVerb() == "patch" {
patchAction := action.(core.PatchActionImpl)
var err error
savedNode, err = applyNodeStatusPatch(test.existingNode, patchAction.GetPatch())
var (
err error
patchAction = action.(core.PatchActionImpl)
patchContent = patchAction.GetPatch()
)
savedNode, err = applyNodeStatusPatch(test.existingNode, patchContent)
if err != nil {
t.Logf("node patching failed, %v", err)
return false, nil
Expand All @@ -2422,6 +2425,10 @@ func TestSyncLabels(t *testing.T) {
} else {
savedNode = test.existingNode
}
if savedNode == nil || savedNode.Labels == nil {
t.Logf("savedNode.Labels should not be nil")
return false, nil
}
val, ok := savedNode.Labels[v1.LabelOSStable]
if !ok {
t.Logf("expected kubernetes.io/os label to be present")
Expand Down

0 comments on commit ddfc539

Please sign in to comment.