This commit is contained in:
Mike Danese 2018-04-04 13:43:50 -07:00
parent d02cf10123
commit f427531179
27 changed files with 23 additions and 174 deletions

View File

@ -133,9 +133,6 @@ func (idr *InitDryRunGetter) handleGetNode(action core.GetAction) (bool, runtime
"kubernetes.io/hostname": idr.masterName,
},
},
Spec: v1.NodeSpec{
ExternalID: idr.masterName,
},
}, nil
}

View File

@ -46,7 +46,7 @@ func TestHandleGetAction(t *testing.T) {
{
action: core.NewRootGetAction(schema.GroupVersionResource{Version: "v1", Resource: "nodes"}, masterName),
expectedHandled: true,
expectedObjectJSON: []byte(`{"metadata":{"name":"master-foo","creationTimestamp":null,"labels":{"kubernetes.io/hostname":"master-foo"}},"spec":{"externalID":"master-foo"},"status":{"daemonEndpoints":{"kubeletEndpoint":{"Port":0}},"nodeInfo":{"machineID":"","systemUUID":"","bootID":"","kernelVersion":"","osImage":"","containerRuntimeVersion":"","kubeletVersion":"","kubeProxyVersion":"","operatingSystem":"","architecture":""}}}`),
expectedObjectJSON: []byte(`{"metadata":{"name":"master-foo","creationTimestamp":null,"labels":{"kubernetes.io/hostname":"master-foo"}},"spec":{},"status":{"daemonEndpoints":{"kubeletEndpoint":{"Port":0}},"nodeInfo":{"machineID":"","systemUUID":"","bootID":"","kernelVersion":"","osImage":"","containerRuntimeVersion":"","kubeletVersion":"","kubeProxyVersion":"","operatingSystem":"","architecture":""}}}`),
expectedErr: false,
},
{

View File

@ -469,10 +469,6 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
ss.SessionAffinityConfig = nil
}
},
func(n *core.Node, c fuzz.Continue) {
c.FuzzNoCustom(n)
n.Spec.ExternalID = "external"
},
func(s *core.NodeStatus, c fuzz.Continue) {
c.FuzzNoCustom(s)
s.Allocatable = s.Capacity

View File

@ -296,11 +296,6 @@ func SetDefaults_NamespaceStatus(obj *v1.NamespaceStatus) {
obj.Phase = v1.NamespaceActive
}
}
func SetDefaults_Node(obj *v1.Node) {
if obj.Spec.ExternalID == "" {
obj.Spec.ExternalID = obj.Name
}
}
func SetDefaults_NodeStatus(obj *v1.NodeStatus) {
if obj.Allocatable == nil && obj.Capacity != nil {
obj.Allocatable = make(v1.ResourceList, len(obj.Capacity))

View File

@ -1033,20 +1033,6 @@ func TestSetDefaultPodSpecHostNetwork(t *testing.T) {
}
}
func TestSetDefaultNodeExternalID(t *testing.T) {
name := "node0"
n := &v1.Node{}
n.Name = name
obj2 := roundTrip(t, runtime.Object(n))
n2 := obj2.(*v1.Node)
if n2.Spec.ExternalID != name {
t.Errorf("Expected default External ID: %s, got: %s", name, n2.Spec.ExternalID)
}
if n2.Spec.ProviderID != "" {
t.Errorf("Expected empty default Cloud Provider ID, got: %s", n2.Spec.ProviderID)
}
}
func TestSetDefaultNodeStatusAllocatable(t *testing.T) {
capacity := v1.ResourceList{
v1.ResourceCPU: resource.MustParse("1000m"),

View File

@ -3973,11 +3973,6 @@ func ValidateNode(node *core.Node) field.ErrorList {
// That said, if specified, we need to ensure they are valid.
allErrs = append(allErrs, ValidateNodeResources(node)...)
// external ID is required.
if len(node.Spec.ExternalID) == 0 {
allErrs = append(allErrs, field.Required(field.NewPath("spec", "externalID"), ""))
}
// Only allow Node.Spec.ConfigSource to be set if the DynamicKubeletConfig feature gate is enabled
if node.Spec.ConfigSource != nil && !utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) {
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec", "configSource"), "configSource may only be set if the DynamicKubeletConfig feature gate is enabled)"))

View File

@ -9364,9 +9364,6 @@ func TestValidateNode(t *testing.T) {
core.ResourceName("hugepages-1Gi"): resource.MustParse("0"),
},
},
Spec: core.NodeSpec{
ExternalID: "external",
},
},
{
ObjectMeta: metav1.ObjectMeta{
@ -9381,9 +9378,6 @@ func TestValidateNode(t *testing.T) {
core.ResourceName(core.ResourceMemory): resource.MustParse("0"),
},
},
Spec: core.NodeSpec{
ExternalID: "external",
},
},
{
ObjectMeta: metav1.ObjectMeta{
@ -9399,7 +9393,6 @@ func TestValidateNode(t *testing.T) {
},
},
Spec: core.NodeSpec{
ExternalID: "external",
// Add a valid taint to a node
Taints: []core.Taint{{Key: "GPU", Value: "true", Effect: "NoSchedule"}},
},
@ -9437,9 +9430,6 @@ func TestValidateNode(t *testing.T) {
core.ResourceName(core.ResourceMemory): resource.MustParse("0"),
},
},
Spec: core.NodeSpec{
ExternalID: "external",
},
},
{
ObjectMeta: metav1.ObjectMeta{
@ -9455,8 +9445,7 @@ func TestValidateNode(t *testing.T) {
},
},
Spec: core.NodeSpec{
ExternalID: "external",
PodCIDR: "192.168.0.0/16",
PodCIDR: "192.168.0.0/16",
},
},
}
@ -9479,9 +9468,6 @@ func TestValidateNode(t *testing.T) {
core.ResourceName(core.ResourceMemory): resource.MustParse("10G"),
},
},
Spec: core.NodeSpec{
ExternalID: "external",
},
},
"invalid-labels": {
ObjectMeta: metav1.ObjectMeta{
@ -9494,28 +9480,12 @@ func TestValidateNode(t *testing.T) {
core.ResourceName(core.ResourceMemory): resource.MustParse("10G"),
},
},
Spec: core.NodeSpec{
ExternalID: "external",
},
},
"missing-external-id": {
ObjectMeta: metav1.ObjectMeta{
Name: "abc-123",
Labels: validSelector,
},
Status: core.NodeStatus{
Capacity: core.ResourceList{
core.ResourceName(core.ResourceCPU): resource.MustParse("10"),
core.ResourceName(core.ResourceMemory): resource.MustParse("10G"),
},
},
},
"missing-taint-key": {
ObjectMeta: metav1.ObjectMeta{
Name: "dedicated-node1",
},
Spec: core.NodeSpec{
ExternalID: "external",
// Add a taint with an empty key to a node
Taints: []core.Taint{{Key: "", Value: "special-user-1", Effect: "NoSchedule"}},
},
@ -9525,7 +9495,6 @@ func TestValidateNode(t *testing.T) {
Name: "dedicated-node1",
},
Spec: core.NodeSpec{
ExternalID: "external",
// Add a taint with an invalid key to a node
Taints: []core.Taint{{Key: "NoUppercaseOrSpecialCharsLike=Equals", Value: "special-user-1", Effect: "NoSchedule"}},
},
@ -9544,7 +9513,6 @@ func TestValidateNode(t *testing.T) {
},
},
Spec: core.NodeSpec{
ExternalID: "external",
// Add a taint with a bad value to a node
Taints: []core.Taint{{Key: "dedicated", Value: "some\\bad\\value", Effect: "NoSchedule"}},
},
@ -9563,7 +9531,6 @@ func TestValidateNode(t *testing.T) {
},
},
Spec: core.NodeSpec{
ExternalID: "external",
// Add a taint with an empty effect to a node
Taints: []core.Taint{{Key: "dedicated", Value: "special-user-3", Effect: ""}},
},
@ -9582,7 +9549,6 @@ func TestValidateNode(t *testing.T) {
},
},
Spec: core.NodeSpec{
ExternalID: "external",
// Add a taint with NoExecute effect to a node
Taints: []core.Taint{{Key: "dedicated", Value: "special-user-3", Effect: "NoScheduleNoAdmit"}},
},
@ -9592,7 +9558,6 @@ func TestValidateNode(t *testing.T) {
Name: "dedicated-node1",
},
Spec: core.NodeSpec{
ExternalID: "external",
// Add two taints to the node with the same key and effect; should be rejected.
Taints: []core.Taint{
{Key: "dedicated", Value: "special-user-1", Effect: "NoSchedule"},
@ -9622,9 +9587,6 @@ func TestValidateNode(t *testing.T) {
core.ResourceName(core.ResourceMemory): resource.MustParse("0"),
},
},
Spec: core.NodeSpec{
ExternalID: "external",
},
},
"invalid-podController": {
ObjectMeta: metav1.ObjectMeta{
@ -9657,9 +9619,6 @@ func TestValidateNode(t *testing.T) {
core.ResourceName(core.ResourceMemory): resource.MustParse("0"),
},
},
Spec: core.NodeSpec{
ExternalID: "external",
},
},
"multiple-pre-allocated-hugepages": {
ObjectMeta: metav1.ObjectMeta{
@ -9678,9 +9637,6 @@ func TestValidateNode(t *testing.T) {
core.ResourceName("hugepages-1Gi"): resource.MustParse("10Gi"),
},
},
Spec: core.NodeSpec{
ExternalID: "external",
},
},
"invalid-pod-cidr": {
ObjectMeta: metav1.ObjectMeta{
@ -9696,8 +9652,7 @@ func TestValidateNode(t *testing.T) {
},
},
Spec: core.NodeSpec{
ExternalID: "external",
PodCIDR: "192.168.0.0",
PodCIDR: "192.168.0.0",
},
},
}

View File

@ -152,7 +152,7 @@ func (cnc *CloudNodeController) updateNodeAddress(node *v1.Node, instances cloud
return
}
// Node that isn't present according to the cloud provider shouldn't have its address updated
exists, err := ensureNodeExistsByProviderIDOrExternalID(instances, node)
exists, err := ensureNodeExistsByProviderIDOrInstanceID(instances, node)
if err != nil {
// Continue to update node address when not sure the node is not exists
glog.Errorf("%v", err)
@ -245,7 +245,7 @@ func (cnc *CloudNodeController) MonitorNode() {
if currentReadyCondition.Status != v1.ConditionTrue {
// Check with the cloud provider to see if the node still exists. If it
// doesn't, delete the node immediately.
exists, err := ensureNodeExistsByProviderIDOrExternalID(instances, node)
exists, err := ensureNodeExistsByProviderIDOrInstanceID(instances, node)
if err != nil {
glog.Errorf("Error getting data for node %s from cloud: %v", node.Name, err)
continue
@ -412,13 +412,13 @@ func excludeTaintFromList(taints []v1.Taint, toExclude v1.Taint) []v1.Taint {
return newTaints
}
// ensureNodeExistsByProviderIDOrExternalID first checks if the instance exists by the provider id and then by calling external id with node name
func ensureNodeExistsByProviderIDOrExternalID(instances cloudprovider.Instances, node *v1.Node) (bool, error) {
// ensureNodeExistsByProviderIDOrInstanceID first checks if the instance exists by the provider id and then by calling instance id with node name
func ensureNodeExistsByProviderIDOrInstanceID(instances cloudprovider.Instances, node *v1.Node) (bool, error) {
exists, err := instances.InstanceExistsByProviderID(context.TODO(), node.Spec.ProviderID)
if err != nil {
providerIDErr := err
_, err = instances.InstanceID(context.TODO(), types.NodeName(node.Name))
//<anupn> Changing the check as InstanceID does not return error
//TODO(anupn): Changing the check as InstanceID does not return error
if err == nil {
return false, nil
}

View File

@ -128,7 +128,7 @@ func TestEnsureNodeExistsByProviderIDOrNodeName(t *testing.T) {
}
instances, _ := fc.Instances()
exists, err := ensureNodeExistsByProviderIDOrExternalID(instances, tc.node)
exists, err := ensureNodeExistsByProviderIDOrInstanceID(instances, tc.node)
assert.NoError(t, err)
assert.EqualValues(t, tc.expectedCalls, fc.Calls,
"expected cloud provider methods `%v` to be called but `%v` was called ",

View File

@ -1543,9 +1543,6 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
v1.ResourceName(v1.ResourceMemory): resource.MustParse("10G"),
},
},
Spec: v1.NodeSpec{
ExternalID: "node0",
},
},
},
Clientset: fake.NewSimpleClientset(&v1.PodList{Items: []v1.Pod{*testutil.NewPod("pod0", "node0")}}),
@ -1620,9 +1617,6 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
v1.ResourceName(v1.ResourceMemory): resource.MustParse("10G"),
},
},
Spec: v1.NodeSpec{
ExternalID: "node0",
},
},
},
},
@ -1651,9 +1645,6 @@ func TestMonitorNodeStatusUpdateStatus(t *testing.T) {
v1.ResourceName(v1.ResourceMemory): resource.MustParse("10G"),
},
},
Spec: v1.NodeSpec{
ExternalID: "node0",
},
},
},
Clientset: fake.NewSimpleClientset(&v1.PodList{Items: []v1.Pod{*testutil.NewPod("pod0", "node0")}}),
@ -1755,9 +1746,6 @@ func TestMonitorNodeStatusMarkPodsNotReady(t *testing.T) {
v1.ResourceName(v1.ResourceMemory): resource.MustParse("10G"),
},
},
Spec: v1.NodeSpec{
ExternalID: "node0",
},
},
},
Clientset: fake.NewSimpleClientset(&v1.PodList{Items: []v1.Pod{*testutil.NewPod("pod0", "node0")}}),
@ -1789,9 +1777,6 @@ func TestMonitorNodeStatusMarkPodsNotReady(t *testing.T) {
v1.ResourceName(v1.ResourceMemory): resource.MustParse("10G"),
},
},
Spec: v1.NodeSpec{
ExternalID: "node0",
},
},
},
Clientset: fake.NewSimpleClientset(&v1.PodList{Items: []v1.Pod{*testutil.NewPod("pod0", "node0")}}),
@ -2208,9 +2193,6 @@ func TestNodeEventGeneration(t *testing.T) {
UID: "1234567890",
CreationTimestamp: metav1.Date(2015, 8, 10, 0, 0, 0, 0, time.UTC),
},
Spec: v1.NodeSpec{
ExternalID: "node0",
},
Status: v1.NodeStatus{
Conditions: []v1.NodeCondition{
{

View File

@ -421,9 +421,6 @@ func NewFakeRecorder() *FakeRecorder {
func NewNode(name string) *v1.Node {
return &v1.Node{
ObjectMeta: metav1.ObjectMeta{Name: name},
Spec: v1.NodeSpec{
ExternalID: name,
},
Status: v1.NodeStatus{
Capacity: v1.ResourceList{
v1.ResourceName(v1.ResourceCPU): resource.MustParse("10"),

View File

@ -153,7 +153,6 @@ func CreateTestClient() *fake.Clientset {
},
},
},
Spec: v1.NodeSpec{ExternalID: string(nodeName)},
}
obj.Items = append(obj.Items, node)
}

View File

@ -70,9 +70,6 @@ func TestMain(m *testing.M) {
Name: "node",
CreationTimestamp: metav1.Time{Time: time.Now()},
},
Spec: corev1.NodeSpec{
ExternalID: "node",
},
Status: corev1.NodeStatus{},
}

View File

@ -867,9 +867,6 @@ func TestGetMultipleTypeObjectsWithDirectReference(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
},
Spec: api.NodeSpec{
ExternalID: "ext",
},
}
tf := cmdtesting.NewTestFactory()

View File

@ -45,8 +45,7 @@ func generateNodeAndTaintedNode(oldTaints []v1.Taint, newTaints []v1.Taint) (*v1
CreationTimestamp: metav1.Time{Time: time.Now()},
},
Spec: v1.NodeSpec{
ExternalID: "node-name",
Taints: oldTaints,
Taints: oldTaints,
},
Status: v1.NodeStatus{},
}

View File

@ -1067,7 +1067,7 @@ func TestSingleItemImpliedObjectNoExtension(t *testing.T) {
}
func TestSingleItemImpliedRootScopedObject(t *testing.T) {
node := &v1.Node{ObjectMeta: metav1.ObjectMeta{Name: "test"}, Spec: v1.NodeSpec{ExternalID: "test"}}
node := &v1.Node{ObjectMeta: metav1.ObjectMeta{Name: "test"}}
r := streamTestObject(node)
infos, err := newDefaultBuilder().
NamespaceParam("test").DefaultNamespace().

View File

@ -912,7 +912,6 @@ func TestRegisterWithApiServer(t *testing.T) {
kubeletapis.LabelArch: goruntime.GOARCH,
},
},
Spec: v1.NodeSpec{ExternalID: testKubeletHostname},
}, nil
})
kubeClient.AddReactor("*", "*", func(action core.Action) (bool, runtime.Object, error) {
@ -966,7 +965,7 @@ func TestTryRegisterWithApiServer(t *testing.T) {
ErrStatus: metav1.Status{Reason: metav1.StatusReasonConflict},
}
newNode := func(cmad bool, externalID string) *v1.Node {
newNode := func(cmad bool) *v1.Node {
node := &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
@ -975,9 +974,6 @@ func TestTryRegisterWithApiServer(t *testing.T) {
kubeletapis.LabelArch: goruntime.GOARCH,
},
},
Spec: v1.NodeSpec{
ExternalID: externalID,
},
}
if cmad {
@ -1010,17 +1006,17 @@ func TestTryRegisterWithApiServer(t *testing.T) {
},
{
name: "success case - existing node - no change in CMAD",
newNode: newNode(true, "a"),
newNode: newNode(true),
createError: alreadyExists,
existingNode: newNode(true, "a"),
existingNode: newNode(true),
expectedResult: true,
expectedActions: 2,
},
{
name: "success case - existing node - CMAD disabled",
newNode: newNode(false, "a"),
newNode: newNode(false),
createError: alreadyExists,
existingNode: newNode(true, "a"),
existingNode: newNode(true),
expectedResult: true,
expectedActions: 3,
testSavedNode: true,
@ -1029,33 +1025,25 @@ func TestTryRegisterWithApiServer(t *testing.T) {
},
{
name: "success case - existing node - CMAD enabled",
newNode: newNode(true, "a"),
newNode: newNode(true),
createError: alreadyExists,
existingNode: newNode(false, "a"),
existingNode: newNode(false),
expectedResult: true,
expectedActions: 3,
testSavedNode: true,
savedNodeIndex: 2,
savedNodeCMAD: true,
},
{
name: "success case - external ID changed",
newNode: newNode(false, "b"),
createError: alreadyExists,
existingNode: newNode(false, "a"),
expectedResult: false,
expectedActions: 3,
},
{
name: "create failed",
newNode: newNode(false, "b"),
newNode: newNode(false),
createError: conflict,
expectedResult: false,
expectedActions: 1,
},
{
name: "get existing node failed",
newNode: newNode(false, "a"),
newNode: newNode(false),
createError: alreadyExists,
getError: conflict,
expectedResult: false,
@ -1063,22 +1051,13 @@ func TestTryRegisterWithApiServer(t *testing.T) {
},
{
name: "update existing node failed",
newNode: newNode(false, "a"),
newNode: newNode(false),
createError: alreadyExists,
existingNode: newNode(true, "a"),
existingNode: newNode(true),
patchError: conflict,
expectedResult: false,
expectedActions: 3,
},
{
name: "delete existing node failed",
newNode: newNode(false, "b"),
createError: alreadyExists,
existingNode: newNode(false, "a"),
deleteError: conflict,
expectedResult: false,
expectedActions: 3,
},
}
notImplemented := func(action core.Action) (bool, runtime.Object, error) {

View File

@ -283,7 +283,6 @@ func TestVolumeAttachAndMountControllerEnabled(t *testing.T) {
DevicePath: "fake/path",
},
}},
Spec: v1.NodeSpec{ExternalID: testKubeletHostname},
}, nil
})
kubeClient.AddReactor("*", "*", func(action core.Action) (bool, runtime.Object, error) {
@ -350,7 +349,6 @@ func TestVolumeUnmountAndDetachControllerEnabled(t *testing.T) {
DevicePath: "fake/path",
},
}},
Spec: v1.NodeSpec{ExternalID: testKubeletHostname},
}, nil
})
kubeClient.AddReactor("*", "*", func(action core.Action) (bool, runtime.Object, error) {

View File

@ -1033,7 +1033,6 @@ func createTestClient() *fake.Clientset {
DevicePath: "fake/path",
},
}},
Spec: v1.NodeSpec{ExternalID: string(nodeName)},
}, nil
})
fakeClient.AddReactor("*", "*", func(action core.Action) (bool, runtime.Object, error) {

View File

@ -250,7 +250,6 @@ func createObjects() (*v1.Node, *v1.Pod, *v1.PersistentVolume, *v1.PersistentVol
DevicePath: "fake/path",
},
}},
Spec: v1.NodeSpec{ExternalID: testHostname},
}
pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{

View File

@ -2710,9 +2710,6 @@ func describeNode(node *api.Node, nodeNonTerminatedPodsList *api.PodList, events
if len(node.Spec.PodCIDR) > 0 {
w.Write(LEVEL_0, "PodCIDR:\t%s\n", node.Spec.PodCIDR)
}
if len(node.Spec.ExternalID) > 0 {
w.Write(LEVEL_0, "ExternalID:\t%s\n", node.Spec.ExternalID)
}
if len(node.Spec.ProviderID) > 0 {
w.Write(LEVEL_0, "ProviderID:\t%s\n", node.Spec.ProviderID)
}

View File

@ -55,9 +55,6 @@ func validNewNode() *api.Node {
"name": "foo",
},
},
Spec: api.NodeSpec{
ExternalID: "external",
},
Status: api.NodeStatus{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceCPU): resource.MustParse("10"),

View File

@ -712,10 +712,6 @@ func (instances *instances) NodeAddressesByProviderID(ctx context.Context, provi
return []v1.NodeAddress{}, errors.New("Not implemented")
}
func (instances *instances) ExternalID(ctx context.Context, name types.NodeName) (string, error) {
return "", errors.New("Not implemented")
}
func (instances *instances) InstanceID(ctx context.Context, name types.NodeName) (string, error) {
return instances.instanceID, nil
}

View File

@ -26,7 +26,7 @@ func GetNodeIds(cs clientset.Interface) []string {
nodes := framework.GetReadySchedulableNodesOrDie(cs)
nodeIds := []string{}
for _, n := range nodes.Items {
nodeIds = append(nodeIds, n.Spec.ExternalID)
nodeIds = append(nodeIds, n.Name)
}
return nodeIds
}

View File

@ -56,10 +56,6 @@ func (p *IntegrationTestNodePreparer) PrepareNodes() error {
ObjectMeta: metav1.ObjectMeta{
GenerateName: p.nodeNamePrefix,
},
Spec: v1.NodeSpec{
// TODO: investigate why this is needed.
ExternalID: "foo",
},
Status: v1.NodeStatus{
Capacity: v1.ResourceList{
v1.ResourcePods: *resource.NewQuantity(110, resource.DecimalSI),

View File

@ -39,9 +39,6 @@ var (
ObjectMeta: metav1.ObjectMeta{
GenerateName: "sample-node-",
},
Spec: v1.NodeSpec{
ExternalID: "foo",
},
Status: v1.NodeStatus{
Capacity: v1.ResourceList{
v1.ResourcePods: *resource.NewQuantity(110, resource.DecimalSI),

View File

@ -50,10 +50,6 @@ var (
ObjectMeta: metav1.ObjectMeta{
GenerateName: "sample-node-",
},
Spec: v1.NodeSpec{
// TODO: investigate why this is needed.
ExternalID: "foo",
},
Status: v1.NodeStatus{
Capacity: v1.ResourceList{
v1.ResourcePods: *resource.NewQuantity(110, resource.DecimalSI),