Skip to content

Commit

Permalink
*: add list limit
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
  • Loading branch information
gyuho committed May 25, 2020
1 parent f2a02cd commit 4661d46
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG/CHANGELOG-1.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ See [code changes](https://github.com/aws/aws-k8s-tester/compare/v1.2.5...v1.2.6

### `eksconfig`

- Add [`AddOnStresserLocal.ListLimit` and `AddOnStresserRemote.ListLimit`](https://github.com/aws/aws-k8s-tester/commit/).
- Add [`eksconfig.Config.TotalNodes` read-only field](https://github.com/aws/aws-k8s-tester/commit/c2f658b54107493960e14e9ec3aa11f8bb818b12).
- Increase [`NGMaxLimit` from 300 to 5000](https://github.com/aws/aws-k8s-tester/commit/34bbeb50a034d86a854017591bb6c69e35e5a699).
- Add [`timeutil.TimeFrame` read-only fields for create/delete](https://github.com/aws/aws-k8s-tester/commit/ffff58e526627de630ec4d9697863568d43c8181).
- `ec2config.Config.TimeUTCCreateCompleteRFC3339Micro` is now `pkg/timeutil.TimeFrame`.

### `eks`

- Add [`ListLimit` to `eks/stresser`](https://github.com/aws/aws-k8s-tester/commit/).
- Use [`client-go` to list nodes and CSRs](https://github.com/aws/aws-k8s-tester/commit/bd8a46b728fa41ab7bc049ce85524dc2b6d587ad).
- Disable [`eks/hollow-nodes` CSI driver](https://github.com/aws/aws-k8s-tester/commit/876d0a6650f333076ee8137d416adbe5477a2fc7).
- `"E | csi_plugin.go:271] Failed to initialize CSINodeInfo: error updating CSINode annotation: timed out waiting for the condition; caused by: the server could not find the requested resource"`
Expand Down
3 changes: 3 additions & 0 deletions cmd/aws-k8s-tester/eks/create-stresser.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (
stresserClientBurst int
stresserClientTimeout time.Duration
stresserObjectSize int
stresserListLimit int64
stresserDuration time.Duration

stresserNamespaceWrite string
Expand All @@ -49,6 +50,7 @@ func newCreateStresser() *cobra.Command {
cmd.PersistentFlags().IntVar(&stresserClientBurst, "client-burst", eksconfig.DefaultClientBurst, "kubelet client setup for burst")
cmd.PersistentFlags().DurationVar(&stresserClientTimeout, "client-timeout", eksconfig.DefaultClientTimeout, "kubelet client timeout")
cmd.PersistentFlags().IntVar(&stresserObjectSize, "object-size", 0, "Size of object per write (0 to disable writes)")
cmd.PersistentFlags().Int64Var(&stresserListLimit, "list-limit", 0, "Maximum number of items to return for list call (0 to list all)")
cmd.PersistentFlags().DurationVar(&stresserDuration, "duration", 5*time.Minute, "duration to run cluster loader")
cmd.PersistentFlags().StringVar(&stresserNamespaceWrite, "namespace-write", "default", "namespaces to send writes")
cmd.PersistentFlags().StringSliceVar(&stresserNamespacesRead, "namespaces-read", []string{"default"}, "namespaces to send reads")
Expand Down Expand Up @@ -102,6 +104,7 @@ func createStresserFunc(cmd *cobra.Command, args []string) {
NamespaceWrite: stresserNamespaceWrite,
NamespacesRead: stresserNamespacesRead,
ObjectSize: stresserObjectSize,
ListLimit: stresserListLimit,
})
loader.Start()

Expand Down
1 change: 1 addition & 0 deletions eks/stresser/local/stresser.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (ts *tester) Create() (err error) {
NamespaceWrite: ts.cfg.EKSConfig.AddOnStresserLocal.Namespace,
NamespacesRead: ns,
ObjectSize: ts.cfg.EKSConfig.AddOnStresserLocal.ObjectSize,
ListLimit: ts.cfg.EKSConfig.AddOnStresserLocal.ListLimit,
})
loader.Start()

Expand Down
3 changes: 2 additions & 1 deletion eks/stresser/remote/stresser.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,12 +520,13 @@ func (ts *tester) createDeployment() error {
// do not specify "kubeconfig", and use in-cluster config via "pkg/k8s-client"
// otherwise, error "namespaces is forbidden: User "system:node:ip-192-168-84..."
// ref. https://github.com/kubernetes/client-go/blob/master/examples/in-cluster-client-configuration/main.go
testerCmd := fmt.Sprintf("/aws-k8s-tester eks create stresser --clients=%d --client-qps=%f --client-burst=%d --client-timeout=%s --object-size=%d --duration=%s --namespace-write=%s --namespaces-read=%s --writes-output-name-prefix=%s --reads-output-name-prefix=%s --block=true",
testerCmd := fmt.Sprintf("/aws-k8s-tester eks create stresser --clients=%d --client-qps=%f --client-burst=%d --client-timeout=%s --object-size=%d --list-limit=%d --duration=%s --namespace-write=%s --namespaces-read=%s --writes-output-name-prefix=%s --reads-output-name-prefix=%s --block=true",
ts.cfg.EKSConfig.Clients,
ts.cfg.EKSConfig.ClientQPS,
ts.cfg.EKSConfig.ClientBurst,
ts.cfg.EKSConfig.ClientTimeout,
ts.cfg.EKSConfig.AddOnStresserRemote.ObjectSize,
ts.cfg.EKSConfig.AddOnStresserRemote.ListLimit,
ts.cfg.EKSConfig.AddOnStresserRemote.Duration,
ts.cfg.EKSConfig.AddOnStresserRemote.Namespace,
strings.Join(ns, ","),
Expand Down
21 changes: 11 additions & 10 deletions eks/stresser/stresser.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type Config struct {
NamespacesRead []string

ObjectSize int
ListLimit int64
}

// Loader defines cluster loader operations.
Expand Down Expand Up @@ -127,7 +128,7 @@ func (ld *loader) Start() {
ld.wg.Add(1) // for writes
go startWrites(ld.cfg.Logger, ld.cfg.Client.KubernetesClientSet(), ld.cfg.ClientTimeout, ld.cfg.Deadline, ld.cfg.NamespaceWrite, ld.cfg.ObjectSize, ld.wg, ld.cfg.Stopc, ld.donec)
}
go startReads(ld.cfg.Logger, ld.cfg.Client.KubernetesClientSet(), ld.cfg.ClientTimeout, ld.cfg.Deadline, ld.cfg.NamespacesRead, ld.wg, ld.cfg.Stopc, ld.donec)
go startReads(ld.cfg.Logger, ld.cfg.Client.KubernetesClientSet(), ld.cfg.ClientTimeout, ld.cfg.Deadline, ld.cfg.NamespacesRead, ld.cfg.ListLimit, ld.wg, ld.cfg.Stopc, ld.donec)
ld.cfg.Logger.Info("started load functions", zap.String("namespace-write", ld.cfg.NamespaceWrite), zap.Strings("namespaces-read", ld.cfg.NamespacesRead))
}

Expand Down Expand Up @@ -286,7 +287,7 @@ func startWrites(lg *zap.Logger, cli *kubernetes.Clientset, timeout time.Duratio
}
}

func startReads(lg *zap.Logger, cli *kubernetes.Clientset, timeout time.Duration, deadline time.Time, ns []string, wg *sync.WaitGroup, stopc chan struct{}, donec chan struct{}) {
func startReads(lg *zap.Logger, cli *kubernetes.Clientset, timeout time.Duration, deadline time.Time, ns []string, listLimit int64, wg *sync.WaitGroup, stopc chan struct{}, donec chan struct{}) {
lg.Info("starting startReads", zap.Strings("namespaces", ns))
defer wg.Done()
cnt := 0
Expand All @@ -304,7 +305,7 @@ func startReads(lg *zap.Logger, cli *kubernetes.Clientset, timeout time.Duration

start := time.Now()
ctx, cancel := context.WithTimeout(context.Background(), timeout)
rs, err := cli.CoreV1().Nodes().List(ctx, metav1.ListOptions{})
rs, err := cli.CoreV1().Nodes().List(ctx, metav1.ListOptions{Limit: listLimit})
cancel()
readRequestLatencyMs.Observe(float64(time.Since(start) / time.Millisecond))
if err != nil {
Expand All @@ -320,7 +321,7 @@ func startReads(lg *zap.Logger, cli *kubernetes.Clientset, timeout time.Duration
for _, nv := range ns {
start := time.Now()
ctx, cancel := context.WithTimeout(context.Background(), timeout)
pods, err := cli.CoreV1().Pods(nv).List(ctx, metav1.ListOptions{})
pods, err := cli.CoreV1().Pods(nv).List(ctx, metav1.ListOptions{Limit: listLimit})
cancel()
readRequestLatencyMs.Observe(float64(time.Since(start) / time.Millisecond))
if err != nil {
Expand All @@ -344,7 +345,7 @@ func startReads(lg *zap.Logger, cli *kubernetes.Clientset, timeout time.Duration

start = time.Now()
ctx, cancel = context.WithTimeout(context.Background(), timeout)
svcs, err := cli.CoreV1().Services(nv).List(ctx, metav1.ListOptions{})
svcs, err := cli.CoreV1().Services(nv).List(ctx, metav1.ListOptions{Limit: listLimit})
cancel()
readRequestLatencyMs.Observe(float64(time.Since(start) / time.Millisecond))
if err != nil {
Expand All @@ -368,7 +369,7 @@ func startReads(lg *zap.Logger, cli *kubernetes.Clientset, timeout time.Duration

start = time.Now()
ctx, cancel = context.WithTimeout(context.Background(), timeout)
eps, err := cli.CoreV1().Endpoints(nv).List(ctx, metav1.ListOptions{})
eps, err := cli.CoreV1().Endpoints(nv).List(ctx, metav1.ListOptions{Limit: listLimit})
cancel()
readRequestLatencyMs.Observe(float64(time.Since(start) / time.Millisecond))
if err != nil {
Expand All @@ -392,7 +393,7 @@ func startReads(lg *zap.Logger, cli *kubernetes.Clientset, timeout time.Duration

start = time.Now()
ctx, cancel = context.WithTimeout(context.Background(), timeout)
cms, err := cli.CoreV1().ConfigMaps(nv).List(ctx, metav1.ListOptions{})
cms, err := cli.CoreV1().ConfigMaps(nv).List(ctx, metav1.ListOptions{Limit: listLimit})
cancel()
readRequestLatencyMs.Observe(float64(time.Since(start) / time.Millisecond))
if err != nil {
Expand All @@ -416,7 +417,7 @@ func startReads(lg *zap.Logger, cli *kubernetes.Clientset, timeout time.Duration

start = time.Now()
ctx, cancel = context.WithTimeout(context.Background(), timeout)
ss, err := cli.CoreV1().Secrets(nv).List(ctx, metav1.ListOptions{})
ss, err := cli.CoreV1().Secrets(nv).List(ctx, metav1.ListOptions{Limit: listLimit})
cancel()
readRequestLatencyMs.Observe(float64(time.Since(start) / time.Millisecond))
if err != nil {
Expand All @@ -440,7 +441,7 @@ func startReads(lg *zap.Logger, cli *kubernetes.Clientset, timeout time.Duration

start = time.Now()
ctx, cancel = context.WithTimeout(context.Background(), timeout)
jobs, err := cli.BatchV1().Jobs(nv).List(ctx, metav1.ListOptions{})
jobs, err := cli.BatchV1().Jobs(nv).List(ctx, metav1.ListOptions{Limit: listLimit})
cancel()
readRequestLatencyMs.Observe(float64(time.Since(start) / time.Millisecond))
if err != nil {
Expand All @@ -464,7 +465,7 @@ func startReads(lg *zap.Logger, cli *kubernetes.Clientset, timeout time.Duration

start = time.Now()
ctx, cancel = context.WithTimeout(context.Background(), timeout)
cjbs, err := cli.BatchV1beta1().CronJobs(nv).List(ctx, metav1.ListOptions{})
cjbs, err := cli.BatchV1beta1().CronJobs(nv).List(ctx, metav1.ListOptions{Limit: listLimit})
cancel()
readRequestLatencyMs.Observe(float64(time.Since(start) / time.Millisecond))
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions eksconfig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_ENABLE=true \
| AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_LOCAL_TIME_FRAME_DELETE | read-only "true" | *eksconfig.AddOnStresserLocal.TimeFrameDelete | timeutil.TimeFrame |
| AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_LOCAL_NAMESPACE | read-only "false" | *eksconfig.AddOnStresserLocal.Namespace | string |
| AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_LOCAL_OBJECT_SIZE | read-only "false" | *eksconfig.AddOnStresserLocal.ObjectSize | int |
| AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_LOCAL_LIST_LIMIT | read-only "false" | *eksconfig.AddOnStresserLocal.ListLimit | int64 |
| AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_LOCAL_DURATION | read-only "false" | *eksconfig.AddOnStresserLocal.Duration | time.Duration |
| AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_LOCAL_DURATION_STRING | read-only "true" | *eksconfig.AddOnStresserLocal.DurationString | string |
| AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_LOCAL_REQUESTS_SUMMARY_WRITES | read-only "true" | *eksconfig.AddOnStresserLocal.RequestsSummaryWrites | metrics.RequestsSummary |
Expand All @@ -610,6 +611,7 @@ AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_ENABLE=true \
| AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_REPOSITORY_IMAGE_TAG | read-only "false" | *eksconfig.AddOnStresserRemote.RepositoryImageTag | string |
| AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_DEPLOYMENT_REPLICAS | read-only "false" | *eksconfig.AddOnStresserRemote.DeploymentReplicas | int32 |
| AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_OBJECT_SIZE | read-only "false" | *eksconfig.AddOnStresserRemote.ObjectSize | int |
| AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_LIST_LIMIT | read-only "false" | *eksconfig.AddOnStresserRemote.ListLimit | int64 |
| AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_DURATION | read-only "false" | *eksconfig.AddOnStresserRemote.Duration | time.Duration |
| AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_DURATION_STRING | read-only "true" | *eksconfig.AddOnStresserRemote.DurationString | string |
| AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_REQUESTS_SUMMARY_WRITES | read-only "true" | *eksconfig.AddOnStresserRemote.RequestsSummaryWrites | metrics.RequestsSummary |
Expand Down
5 changes: 5 additions & 0 deletions eksconfig/add-on-stresser-local.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ type AddOnStresserLocal struct {

// ObjectSize is the value size in bytes for write objects.
ObjectSize int `json:"object-size"`
// ListLimit is the maximum number of items in the list call.
// Sets "metav1.ListOptions".Limit field.
// 0 to list all.
ListLimit int64 `json:"list-limit"`
// Duration is the duration to run load testing.
// The cluster loader waits "one" "Duration" for hollow ones.
// And other one for cluster loader.
Expand Down Expand Up @@ -67,6 +71,7 @@ func getDefaultAddOnStresserLocal() *AddOnStresserLocal {
return &AddOnStresserLocal{
Enable: false,
ObjectSize: 0,
ListLimit: 0,
Duration: time.Minute,
}
}
Expand Down
5 changes: 5 additions & 0 deletions eksconfig/add-on-stresser-remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ type AddOnStresserRemote struct {
// ObjectSize is the value size in bytes for write objects.
// If 0, do not write anything.
ObjectSize int `json:"object-size"`
// ListLimit is the maximum number of items in the list call.
// Sets "metav1.ListOptions".Limit field.
// 0 to list all.
ListLimit int64 `json:"list-limit"`
// Duration is the duration to run load testing.
// The cluster loader waits "one" "Duration" for hollow ones.
// And other one for cluster loader.
Expand Down Expand Up @@ -91,6 +95,7 @@ func getDefaultAddOnStresserRemote() *AddOnStresserRemote {
Enable: false,
DeploymentReplicas: 5,
ObjectSize: 0,
ListLimit: 0,
Duration: time.Minute,
RequestsSummaryWritesOutputNamePrefix: "stresser-writes" + randutil.String(10),
RequestsSummaryReadsOutputNamePrefix: "stresser-reads" + randutil.String(10),
Expand Down
6 changes: 3 additions & 3 deletions eksconfig/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ log-level: info
log-outputs:
- stderr
- /home/ANT.AMAZON.COM/leegyuho/go/src/github.com/aws/aws-k8s-tester/eksconfig/default.log
name: eks-2020052502-impressiveob
name: eks-2020052502-amberkmpih6g
on-failure-delete: true
on-failure-delete-wait-seconds: 120
parameters:
Expand All @@ -38,7 +38,7 @@ parameters:
role-cfn-stack-id: ""
role-create: true
role-managed-policy-arns: null
role-name: eks-2020052502-impressiveob-role
role-name: eks-2020052502-amberkmpih6g-role
role-service-principals: null
signing-name: eks
tags: null
Expand All @@ -51,7 +51,7 @@ partition: aws
region: us-west-2
remote-access-commands-output-path: /home/ANT.AMAZON.COM/leegyuho/go/src/github.com/aws/aws-k8s-tester/eksconfig/default.ssh.sh
remote-access-key-create: true
remote-access-key-name: eks-2020052502-impressiveob-remote-access-key
remote-access-key-name: eks-2020052502-amberkmpih6g-remote-access-key
remote-access-private-key-path: /home/ANT.AMAZON.COM/leegyuho/.ssh/kube_aws_rsa
s3-bucket-create: false
s3-bucket-create-keep: false
Expand Down
12 changes: 11 additions & 1 deletion eksconfig/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ func TestEnv(t *testing.T) {
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_LOCAL_ENABLE")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_LOCAL_DURATION", "7m30s")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_LOCAL_DURATION")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_LOCAL_LIST_LIMIT", "133")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_LOCAL_LIST_LIMIT")

os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_ENABLE", "true")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_ENABLE")
Expand All @@ -400,7 +402,9 @@ func TestEnv(t *testing.T) {
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_DEPLOYMENT_REPLICAS", "500")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_DEPLOYMENT_REPLICAS")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_OBJECT_SIZE", "512")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_ENABLE")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_OBJECT_SIZE")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_LIST_LIMIT", "177")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_LIST_LIMIT")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_REQUESTS_SUMMARY_WRITES_OUTPUT_NAME_PREFIX", "stresser-out-pfx")
defer os.Unsetenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_REQUESTS_SUMMARY_WRITES_OUTPUT_NAME_PREFIX")
os.Setenv("AWS_K8S_TESTER_EKS_ADD_ON_STRESSER_REMOTE_REQUESTS_SUMMARY_READS_OUTPUT_NAME_PREFIX", "stresser-out-pfx")
Expand Down Expand Up @@ -1034,6 +1038,9 @@ func TestEnv(t *testing.T) {
if cfg.AddOnStresserLocal.Duration != 7*time.Minute+30*time.Second {
t.Fatalf("unexpected cfg.AddOnStresserLocal.Duration %v", cfg.AddOnStresserLocal.Duration)
}
if cfg.AddOnStresserLocal.ListLimit != 133 {
t.Fatalf("unexpected cfg.AddOnStresserLocal.ListLimit %v", cfg.AddOnStresserLocal.ListLimit)
}

if !cfg.AddOnStresserRemote.Enable {
t.Fatalf("unexpected cfg.AddOnStresserRemote.Enable %v", cfg.AddOnStresserRemote.Enable)
Expand All @@ -1056,6 +1063,9 @@ func TestEnv(t *testing.T) {
if cfg.AddOnStresserRemote.ObjectSize != 512 {
t.Fatalf("unexpected cfg.AddOnStresserRemote.ObjectSize %v", cfg.AddOnStresserRemote.ObjectSize)
}
if cfg.AddOnStresserRemote.ListLimit != 177 {
t.Fatalf("unexpected cfg.AddOnStresserRemote.ListLimit %v", cfg.AddOnStresserRemote.ListLimit)
}
if cfg.AddOnStresserRemote.RequestsSummaryWritesOutputNamePrefix != "stresser-out-pfx" {
t.Fatalf("unexpected cfg.AddOnStresserRemote.RequestsSummaryWritesOutputNamePrefix %v", cfg.AddOnStresserRemote.RequestsSummaryWritesOutputNamePrefix)
}
Expand Down

0 comments on commit 4661d46

Please sign in to comment.