diff --git a/pkg/firmament/resource_desc.pb.go b/pkg/firmament/resource_desc.pb.go index f6e7a53f..5a9e4fd8 100644 --- a/pkg/firmament/resource_desc.pb.go +++ b/pkg/firmament/resource_desc.pb.go @@ -141,6 +141,8 @@ type ResourceDescriptor struct { TraceMachineId uint64 `protobuf:"varint,21,opt,name=trace_machine_id,json=traceMachineId" json:"trace_machine_id,omitempty"` // Resource labels Labels []*Label `protobuf:"bytes,32,rep,name=labels" json:"labels,omitempty"` + // Max pods allowed per node + MaxPods uint64 `protobuf:"varint,33,opt,name=max_pods,json=maxPods" json:"max_pods,omitempty"` } func (m *ResourceDescriptor) Reset() { *m = ResourceDescriptor{} } @@ -302,6 +304,13 @@ func (m *ResourceDescriptor) GetLabels() []*Label { return nil } +func (m *ResourceDescriptor) GetMaxPods() uint64 { + if m != nil { + return m.MaxPods + } + return 0 +} + func init() { proto.RegisterType((*ResourceDescriptor)(nil), "firmament.ResourceDescriptor") proto.RegisterEnum("firmament.ResourceDescriptor_ResourceState", ResourceDescriptor_ResourceState_name, ResourceDescriptor_ResourceState_value) @@ -311,55 +320,56 @@ func init() { func init() { proto.RegisterFile("resource_desc.proto", fileDescriptor10) } var fileDescriptor10 = []byte{ - // 787 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x95, 0xdf, 0x6e, 0xe3, 0x44, - 0x14, 0xc6, 0x49, 0x93, 0x76, 0xdb, 0x93, 0x7f, 0xd3, 0x49, 0xbb, 0x0c, 0x45, 0xac, 0x4c, 0x11, - 0xc8, 0x80, 0xd4, 0x8b, 0x22, 0x6e, 0x11, 0x59, 0x27, 0xd0, 0xd0, 0x34, 0x46, 0xe3, 0x84, 0x15, - 0x02, 0xad, 0x35, 0x71, 0xa6, 0xd4, 0x22, 0x1e, 0x47, 0x33, 0xe3, 0xfe, 0x79, 0x17, 0x1e, 0x92, - 0x47, 0x40, 0x33, 0x71, 0x1c,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, 0xbc, 0x7e, 0xfe, 0x16, 0x9a, 0x1b, 0x5b, 0x0a, 0x9f, 0x00, 0xa2, 0xfd, - 0xc0, 0x9f, 0x50, 0xaf, 0x1f, 0x4e, 0x46, 0xd7, 0x23, 0xff, 0xcd, 0x08, 0x7d, 0x84, 0x8f, 0xa1, - 0x59, 0xa8, 0x83, 0xde, 0xb0, 0x8f, 0x2a, 0x1b, 0xd2, 0xeb, 0x49, 0xf0, 0x3b, 0xda, 0xdb, 0x90, - 0x86, 0x7e, 0x30, 0x46, 0xd5, 0xf3, 0x7f, 0x2b, 0xd0, 0x28, 0x2f, 0x1e, 0xdc, 0x86, 0x7a, 0xe1, - 0xf9, 0x75, 0xf2, 0x0e, 0xda, 0xf3, 0xa9, 0x41, 0x63, 0x68, 0xad, 0xa5, 0xae, 0x77, 0xd5, 0x47, - 0x7b, 0x18, 0x41, 0xa3, 0xd0, 0x46, 0x03, 0x0f, 0x55, 0x37, 0x1a, 0x7b, 0x83, 0xe0, 0x1a, 0xd5, - 0x36, 0x4c, 0x41, 0xd0, 0x43, 0xfb, 0x1b, 0xe3, 0xdc, 0x74, 0xbd, 0xab, 0xc1, 0xa8, 0x8f, 0x0e, - 0x36, 0xd4, 0xa1, 0xff, 0xf3, 0xc0, 0xeb, 0x0e, 0xd1, 0x0b, 0xfc, 0x12, 0xf0, 0xfa, 0x15, 0x93, - 0x9b, 0x6e, 0x38, 0xf2, 0x7b, 0x7d, 0x74, 0x88, 0x3b, 0xd0, 0x5e, 0x53, 0x7d, 0xef, 0xba, 0x3f, - 0x46, 0x47, 0x98, 0xc0, 0x49, 0x29, 0xb6, 0x4f, 0x7b, 0x83, 0x51, 0x77, 0xec, 0x53, 0x04, 0xd3, - 0x03, 0xfb, 0x2f, 0xf5, 0xdd, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x8b, 0x7b, 0xa9, 0x34, 0x22, - 0x07, 0x00, 0x00, + // 807 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b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, 0xdf, 0x18, 0xe7, 0xb6, 0xeb, 0x5c, + 0x0f, 0x46, 0x7d, 0x74, 0xb0, 0xa1, 0x0e, 0xdd, 0x9f, 0x07, 0x4e, 0x77, 0x88, 0x0e, 0xf1, 0x0b, + 0xc0, 0xeb, 0x57, 0x4c, 0x6e, 0xbb, 0xfe, 0xc8, 0xed, 0xf5, 0xd1, 0x11, 0xee, 0x40, 0x7b, 0x4d, + 0x75, 0x9d, 0x9b, 0xfe, 0x18, 0x1d, 0x63, 0x02, 0xa7, 0xa5, 0xd8, 0x2e, 0xed, 0x0d, 0x46, 0xdd, + 0xb1, 0x4b, 0x11, 0x4c, 0x0f, 0xcc, 0x0f, 0xd8, 0x77, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x20, + 0x1b, 0xe4, 0xef, 0x3d, 0x07, 0x00, 0x00, } diff --git a/pkg/firmament/resource_desc.proto b/pkg/firmament/resource_desc.proto index 61961ec8..f456fbd6 100644 --- a/pkg/firmament/resource_desc.proto +++ b/pkg/firmament/resource_desc.proto @@ -80,4 +80,6 @@ message ResourceDescriptor { uint64 trace_machine_id = 21; // Resource labels repeated Label labels = 32; + // Max pods allowed per node + uint64 max_pods = 33; } diff --git a/pkg/k8sclient/nodewatcher.go b/pkg/k8sclient/nodewatcher.go index 74b3245e..346bf1b3 100644 --- a/pkg/k8sclient/nodewatcher.go +++ b/pkg/k8sclient/nodewatcher.go @@ -106,6 +106,7 @@ func (nw *NodeWatcher) parseNode(node *v1.Node, phase NodePhase) *Node { memCap, _ := memCapQuantity.AsInt64() memAllocQuantity := node.Status.Allocatable[v1.ResourceMemory] memAlloc, _ := memAllocQuantity.AsInt64() + podAllocQuantity := node.Status.Allocatable[v1.ResourcePods] return &Node{ Hostname: node.Name, Phase: phase, @@ -115,6 +116,7 @@ func (nw *NodeWatcher) parseNode(node *v1.Node, phase NodePhase) *Node { CPUAllocatable: cpuAllocQuantity.MilliValue(), MemCapacityKb: memCap / bytesToKb, MemAllocatableKb: memAlloc / bytesToKb, + PodAllocatable: podAllocQuantity.Value(), Labels: node.Labels, Annotations: node.Annotations, } @@ -302,6 +304,7 @@ func (nw *NodeWatcher) createResourceTopologyForNode(node *Node) *firmament.Reso RamCap: uint64(node.MemCapacityKb), CpuCores: float32(node.CPUCapacity), }, + MaxPods: uint64(node.PodAllocatable), }, } ResIDToNode[resUUID] = node.Hostname diff --git a/pkg/k8sclient/types.go b/pkg/k8sclient/types.go index 17f0393c..9a6735cc 100644 --- a/pkg/k8sclient/types.go +++ b/pkg/k8sclient/types.go @@ -71,6 +71,7 @@ type Node struct { CPUAllocatable int64 MemCapacityKb int64 MemAllocatableKb int64 + PodAllocatable int64 Labels map[string]string Annotations map[string]string } diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index 902c96e2..b4531436 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -164,7 +164,7 @@ func (f *Framework) AfterEach() { f.FetchLogsFromFirmament(f.TestingNS) f.FetchLogsFromPoseidon(f.TestingNS) Logf("Delete namespace called") - err = f.deleteNamespace(f.TestingNS) + err = f.DeleteNamespace(f.TestingNS) Expect(err).NotTo(HaveOccurred()) err = f.DeleteDeploymentIfExist(f.TestingNS, poseidonDeploymentName) diff --git a/test/e2e/framework/namespace.go b/test/e2e/framework/namespace.go index f8020036..0c9ce5bb 100644 --- a/test/e2e/framework/namespace.go +++ b/test/e2e/framework/namespace.go @@ -62,14 +62,14 @@ func (f *Framework) deleteNamespaceIfExist(nsName string) error { } else { //delete the namespace as it exist Logf("Deleting %v namespace as it exists", nsName) - if err = f.deleteNamespace(nsName); err != nil { + if err = f.DeleteNamespace(nsName); err != nil { return fmt.Errorf("unable to delete %v namespace, error: %v occurred", nsName, err) } } return nil } -func (f *Framework) deleteNamespace(nsName string) error { +func (f *Framework) DeleteNamespace(nsName string) error { if err := f.ClientSet.CoreV1().Namespaces().Delete(nsName, nil); err != nil { return err diff --git a/test/e2e/poseidon_integration.go b/test/e2e/poseidon_integration.go index 7ed9342c..0762f32f 100644 --- a/test/e2e/poseidon_integration.go +++ b/test/e2e/poseidon_integration.go @@ -20,6 +20,8 @@ import ( "fmt" "math/rand" "os" + "strconv" + "time" "github.com/golang/glog" "github.com/kubernetes-sigs/poseidon/test/e2e/framework" @@ -32,7 +34,6 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - "time" ) var _ = Describe("Poseidon", func() { @@ -483,6 +484,91 @@ var _ = Describe("Poseidon", func() { Expect(err).To(HaveOccurred()) }) + // Test whether the kubelet flag max_pods works + // Currently the test uses the node's default max_pods value, i.e., we don't manually set the kubelet flag max_pods; + // And only test on one of the nodes. + It("validates MaxPods limit number of pods that are allowed to run [Slow]", func() { + + nodeList, err := clientset.CoreV1().Nodes().List(metav1.ListOptions{}) + Expect(err).NotTo(HaveOccurred()) + maxPodNamespace := "max-pods-test" + _, err = clientset.CoreV1().Namespaces().Create(&v1.Namespace{ + ObjectMeta: metav1.ObjectMeta{Name: maxPodNamespace}, + }) + if err != nil { + glog.Errorf("unable to create namespace %s, error: %v occurred", maxPodNamespace, err) + } + for idx, node := range nodeList.Items { + framework.Logf("Node: %v", node.Name) + podAlloc, found := node.Status.Allocatable[v1.ResourcePods] + Expect(found).To(Equal(true)) + podList, err := clientset.CoreV1().Pods(metav1.NamespaceAll).List(metav1.ListOptions{}) + Expect(err).NotTo(HaveOccurred()) + podCount := podList.Size() + + name := "max-pods-" + strconv.Itoa(idx) + var replicas int32 + replicas = int32(podAlloc.Value()) + if podCount < 1 { + replicas += 5 + } + _, err = clientset.ExtensionsV1beta1().Deployments(maxPodNamespace).Create(&v1beta1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"app": "nginx"}, + Name: name, + }, + Spec: v1beta1.DeploymentSpec{ + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{"app": "nginx", "name": "test-max-pods"}, + }, + Replicas: &replicas, + Template: v1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"name": "test-max-pods", "app": "nginx", "schedulerName": "poseidon"}, + Name: name, + }, + Spec: v1.PodSpec{ + SchedulerName: "poseidon", + Containers: []v1.Container{ + { + Name: fmt.Sprintf("container-%s", name), + Image: "nginx:latest", + ImagePullPolicy: "IfNotPresent", + }, + }, + }, + }, + }, + }) + Expect(err).NotTo(HaveOccurred()) + // time for pods to be Running + time.Sleep(3 * time.Minute) + podList, err = clientset.CoreV1().Pods(metav1.NamespaceAll).List(metav1.ListOptions{}) + Expect(err).NotTo(HaveOccurred()) + var podRunningCount, podPendingCount, podFailedCount int64 = 0, 0, 0 + for _, pod := range podList.Items { + if pod.Status.Phase == v1.PodRunning { + podRunningCount++ + } else if pod.Status.Phase == v1.PodPending { + podPendingCount++ + } else if pod.Status.Phase == v1.PodFailed { + podFailedCount++ + } + } + Expect(podRunningCount == podAlloc.Value()).To(Equal(true)) + glog.Errorf("Pods: %d Running, %d Pening, %d Failed", podRunningCount, podPendingCount, podFailedCount) + + framework.Logf("Time to clean up the ns [%s] now...", maxPodNamespace) + if err = f.DeleteNamespace(maxPodNamespace); err != nil { + glog.Errorf("unable to delete %v namespace, error: %v occurred", maxPodNamespace, err) + } + // time for Terminating pods to disappear + // TODO: deal with the deletion better. Tried deleting the deployment but didn't work well. + time.Sleep(1 * time.Minute) + // Test one node for now since the test takes much time. + break + } + }) // Test Nodes does not have any label, hence it should be impossible to schedule Pod with // nonempty Selector set. /*