Skip to content

Commit

Permalink
Merge pull request eksctl-io#298 from anusha-ragunathan/master
Browse files Browse the repository at this point in the history
Device allocator should not use reserved dev names.
  • Loading branch information
k8s-ci-robot authored May 17, 2019
2 parents e067f70 + 3775460 commit 493aa67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pkg/cloud/devicemanager/allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ var _ NameAllocator = &nameAllocator{}

// GetNext gets next available device given existing names that are being used
// This function iterate through the device names in deterministic order of:
// a, b, ... , z, aa, ab, ... , az
// ba, ... ,bz, ca, ... , cz
// and return the first one that is not used yet.
func (d *nameAllocator) GetNext(existingNames ExistingNames) (string, error) {
for _, c1 := range []string{"", "a"} {
for _, c1 := range []string{"b", "c"} {
for c2 := 'a'; c2 <= 'z'; c2++ {
name := fmt.Sprintf("%s%s", c1, string(c2))
if _, found := existingNames[name]; !found {
Expand Down
12 changes: 6 additions & 6 deletions pkg/cloud/devicemanager/allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ func TestNameAllocator(t *testing.T) {
tests := []struct {
expectedName string
}{
{"a"}, {"b"}, {"c"}, {"d"}, {"e"}, {"f"}, {"g"}, {"h"}, {"i"}, {"j"},
{"k"}, {"l"}, {"m"}, {"n"}, {"o"}, {"p"}, {"q"}, {"r"}, {"s"}, {"t"},
{"u"}, {"v"}, {"w"}, {"x"}, {"y"}, {"z"},
{"aa"}, {"ab"}, {"ac"}, {"ad"}, {"ae"}, {"af"}, {"ag"}, {"ah"}, {"ai"}, {"aj"},
{"ak"}, {"al"}, {"am"}, {"an"}, {"ao"}, {"ap"}, {"aq"}, {"ar"}, {"as"}, {"at"},
{"au"}, {"av"}, {"aw"}, {"ax"}, {"ay"}, {"az"},
{"ba"}, {"bb"}, {"bc"}, {"bd"}, {"be"}, {"bf"}, {"bg"}, {"bh"}, {"bi"}, {"bj"},
{"bk"}, {"bl"}, {"bm"}, {"bn"}, {"bo"}, {"bp"}, {"bq"}, {"br"}, {"bs"}, {"bt"},
{"bu"}, {"bv"}, {"bw"}, {"bx"}, {"by"}, {"bz"},
{"ca"}, {"cb"}, {"cc"}, {"cd"}, {"ce"}, {"cf"}, {"cg"}, {"ch"}, {"ci"}, {"cj"},
{"ck"}, {"cl"}, {"cm"}, {"cn"}, {"co"}, {"cp"}, {"cq"}, {"cr"}, {"cs"}, {"ct"},
{"cu"}, {"cv"}, {"cw"}, {"cx"}, {"cy"}, {"cz"},
}

for _, test := range tests {
Expand Down

0 comments on commit 493aa67

Please sign in to comment.