Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #963 from phoenixking25/resource-quota-bug
Browse files Browse the repository at this point in the history
Resource quota Benchmark Bug
  • Loading branch information
k8s-ci-robot authored Jul 31, 2020
2 parents ae439cb + 27c043b commit a59bb77
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion benchmarks/kubectl-mtb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ clean:

# Install kubectl plugin
kubectl-mtb: generate readme build
cp bin/kubectl/kubectl-mtb ${GOPATH}/bin/kubectl-mtb
cp bin/kubectl/kubectl-mtb ${GOBIN}/kubectl-mtb

# Build the Mtb-builder
builder:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ import (
)

var b = &benchmark.Benchmark{
// Checks if user can list resourcequotas
PreRun: func(tenantNamespace string, kclient, tclient *kubernetes.Clientset) error {
resources := []utils.GroupResource{
{

verbs := []string{"list", "get"}

for _, verb := range verbs {
resource := utils.GroupResource{
APIGroup: "",
APIResource: metav1.APIResource{
Name: "resourcequotas",
},
},
}
verb := "list"
for _, resource := range resources {
}

access, msg, err := utils.RunAccessCheck(tclient, tenantNamespace, resource, verb)
if err != nil {
fmt.Println(err.Error())
return err
}
if !access {
return fmt.Errorf(msg)
}
}

return nil
},
Run: func(tenantNamespace string, kclient, tclient *kubernetes.Clientset) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ import (
)

var b = &benchmark.Benchmark{
// Check if user can list nodes
PreRun: func(tenantNamespace string, kclient, tclient *kubernetes.Clientset) error {
resources := []utils.GroupResource{
{

verbs := []string{"list", "get"}

for _, verb := range verbs {
resource := utils.GroupResource{
APIGroup: "",
APIResource: metav1.APIResource{
Name: "resourcequotas",
},
},
}
verb := "list"
for _, resource := range resources {
}

access, msg, err := utils.RunAccessCheck(tclient, tenantNamespace, resource, verb)
if err != nil {
fmt.Println(err.Error())
return err
}
if !access {
return fmt.Errorf(msg)
}
}

return nil
},
Run: func(tenantNamespace string, kclient, tclient *kubernetes.Clientset) error {
Expand Down
11 changes: 6 additions & 5 deletions benchmarks/kubectl-mtb/test/quotas/ns_quota.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: v1
kind: ResourceQuota
metadata:
name: object-quota
name: resource-quota
spec:
hard:
cpu: "1"
ephemeral-storage: "1"
memory: "1"
cpu: 1m
memory: 1Gi
ephemeral-storage: 1Gi
persistentvolumeclaims: "1"
services.loadbalancers: "1"
services.nodeports: "1"
Expand All @@ -15,4 +15,5 @@ spec:
resourcequotas: "1"
configmaps: "1"
secrets: "1"
services: "1"
services: "1"

15 changes: 13 additions & 2 deletions benchmarks/kubectl-mtb/test/utils/resources/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/creasty/defaults"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid"
imageutils "k8s.io/kubernetes/test/utils/image"
Expand Down Expand Up @@ -66,8 +67,18 @@ func (p PodSpec) MakeSecPod() *v1.Pod {
},
Containers: []v1.Container{
{
Name: "write-pod",
Image: imageutils.GetE2EImage(imageutils.BusyBox),
Name: "write-pod",
Image: imageutils.GetE2EImage(imageutils.BusyBox),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{
"cpu": resource.MustParse("0m"),
"memory": resource.MustParse("0Gi"),
},
Requests: v1.ResourceList{
"cpu": resource.MustParse("0m"),
"memory": resource.MustParse("0Gi"),
},
},
Command: []string{"/bin/sh"},
Args: []string{"-c", p.Command},
Ports: p.Ports,
Expand Down

0 comments on commit a59bb77

Please sign in to comment.