forked from cilium/cilium
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The `cilium-operator` start/resync time and memory consumption are excessive in our largest AWS accounts, due to the `GetInstances` regularly fetching each VPC's interfaces. We run our clusters in dedicated subnets, so the set of relevant interfaces can be easily reduced. In one of our AWS accounts, fetching all subnets and interfaces requires about 2GB of memory, and takes about 60s. Filtering on cluster's subnets, we're down to 20MB and 2s for a 130 nodes cluster (or 200MB / 8s for 2300 nodes). Signed-off-by: Benjamin Pineau <benjamin.pineau@datadoghq.com>
- Loading branch information
1 parent
dcbdb1e
commit f5425fe
Showing
6 changed files
with
199 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| // Copyright 2020 Authors of Cilium | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| // +build !privileged_tests | ||
|
|
||
| package ec2 | ||
|
|
||
| import ( | ||
| "reflect" | ||
| "sort" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/aws/aws-sdk-go-v2/aws" | ||
| "github.com/aws/aws-sdk-go-v2/service/ec2" | ||
| ) | ||
|
|
||
| type Filters []ec2.Filter | ||
|
|
||
| func (s Filters) Len() int { return len(s) } | ||
| func (s Filters) Swap(i, j int) { s[i], s[j] = s[j], s[i] } | ||
| func (s Filters) Less(i, j int) bool { return strings.Compare(*s[i].Name, *s[j].Name) > 0 } | ||
|
|
||
| func TestNewSubnetsFilters(t *testing.T) { | ||
| type args struct { | ||
| tags map[string]string | ||
| ids []string | ||
| } | ||
| tests := []struct { | ||
| name string | ||
| args args | ||
| want []ec2.Filter | ||
| }{ | ||
|
|
||
| { | ||
| name: "empty arguments", | ||
| args: args{ | ||
| tags: map[string]string{}, | ||
| ids: []string{}, | ||
| }, | ||
| want: []ec2.Filter{}, | ||
| }, | ||
|
|
||
| { | ||
| name: "ids only", | ||
| args: args{ | ||
| tags: map[string]string{}, | ||
| ids: []string{"a", "b"}, | ||
| }, | ||
| want: []ec2.Filter{ | ||
| { | ||
| Name: aws.String("subnet-id"), | ||
| Values: []string{"a", "b"}, | ||
| }, | ||
| }, | ||
| }, | ||
|
|
||
| { | ||
| name: "tags only", | ||
| args: args{ | ||
| tags: map[string]string{"a": "b", "c": "d"}, | ||
| ids: []string{}, | ||
| }, | ||
| want: []ec2.Filter{ | ||
| { | ||
| Name: aws.String("tag:a"), | ||
| Values: []string{"b"}, | ||
| }, | ||
| { | ||
| Name: aws.String("tag:c"), | ||
| Values: []string{"d"}, | ||
| }, | ||
| }, | ||
| }, | ||
|
|
||
| { | ||
| name: "tags and ids", | ||
| args: args{ | ||
| tags: map[string]string{"a": "b"}, | ||
| ids: []string{"c", "d"}, | ||
| }, | ||
| want: []ec2.Filter{ | ||
| { | ||
| Name: aws.String("tag:a"), | ||
| Values: []string{"b"}, | ||
| }, | ||
| { | ||
| Name: aws.String("subnet-id"), | ||
| Values: []string{"c", "d"}, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| got := NewSubnetsFilters(tt.args.tags, tt.args.ids) | ||
| sort.Sort(Filters(got)) | ||
| sort.Sort(Filters(tt.want)) | ||
| if !reflect.DeepEqual(got, tt.want) { | ||
| t.Errorf("NewSubnetsFilters() = %v, want %v", got, tt.want) | ||
| } | ||
| }) | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters