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

actually validate semver in node controller rather than prefix checking #18173

Merged
merged 1 commit into from Dec 3, 2015
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions pkg/controller/node/nodecontroller.go
Expand Up @@ -20,7 +20,6 @@ import (
"errors"
"fmt"
"net"
"strings"
"sync"
"time"

Expand All @@ -38,6 +37,7 @@ import (
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/version"
"k8s.io/kubernetes/pkg/watch"
)

Expand Down Expand Up @@ -287,6 +287,8 @@ func (nc *NodeController) getCondition(status *api.NodeStatus, conditionType api
return nil
}

var gracefulDeletionVersion = version.MustParse("v1.1.0")

// maybeDeleteTerminatingPod non-gracefully deletes pods that are terminating
// that should not be gracefully terminated.
func (nc *NodeController) maybeDeleteTerminatingPod(obj interface{}) {
Expand Down Expand Up @@ -328,7 +330,13 @@ func (nc *NodeController) maybeDeleteTerminatingPod(obj interface{}) {
// guarantee backwards compatibility of master API to kubelets with
// versions less than 1.1.0
node := nodeObj.(*api.Node)
if strings.HasPrefix(node.Status.NodeInfo.KubeletVersion, "v1.0") {
v, err := version.Parse(node.Status.NodeInfo.KubeletVersion)
if err != nil {
glog.Infof("couldn't parse verions %q of minion: %v", node.Status.NodeInfo.KubeletVersion, err)
nc.forcefullyDeletePod(pod)
return
}
if gracefulDeletionVersion.GT(v) {
nc.forcefullyDeletePod(pod)
return
}
Expand Down
34 changes: 34 additions & 0 deletions pkg/controller/node/nodecontroller_test.go
Expand Up @@ -725,6 +725,20 @@ func TestCheckPod(t *testing.T) {
},
prune: true,
},
{
pod: api.Pod{
ObjectMeta: api.ObjectMeta{DeletionTimestamp: &unversioned.Time{}},
Spec: api.PodSpec{NodeName: "older"},
},
prune: true,
},
{
pod: api.Pod{
ObjectMeta: api.ObjectMeta{DeletionTimestamp: &unversioned.Time{}},
Spec: api.PodSpec{NodeName: "oldest"},
},
prune: true,
},
{
pod: api.Pod{
ObjectMeta: api.ObjectMeta{DeletionTimestamp: &unversioned.Time{}},
Expand Down Expand Up @@ -763,6 +777,26 @@ func TestCheckPod(t *testing.T) {
},
},
})
nc.nodeStore.Store.Add(&api.Node{
ObjectMeta: api.ObjectMeta{
Name: "older",
},
Status: api.NodeStatus{
NodeInfo: api.NodeSystemInfo{
KubeletVersion: "v0.21.4",
},
},
})
nc.nodeStore.Store.Add(&api.Node{
ObjectMeta: api.ObjectMeta{
Name: "oldest",
},
Status: api.NodeStatus{
NodeInfo: api.NodeSystemInfo{
KubeletVersion: "v0.19.3",
},
},
})

for i, tc := range tcs {
var deleteCalls int
Expand Down