Skip to content

Commit

Permalink
Remove cluster's subnode from ListProfiles result.
Browse files Browse the repository at this point in the history
Fix prolbem which ListProfiles return subnodes in Mult-Node clusters as
a part of inValidPs.
  • Loading branch information
daehyeok committed Jan 9, 2021
1 parent f17951c commit 12315d6
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions pkg/minikube/config/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,9 @@ func ListProfiles(miniHome ...string) (validPs []*Profile, inValidPs []*Profile,
if err == nil {
pDirs = append(pDirs, cs...)
}
pDirs = removeDupes(pDirs)
for _, n := range pDirs {

nodeNames := map[string]bool{}
for _, n := range removeDupes(pDirs) {
p, err := LoadProfile(n, miniHome...)
if err != nil {
inValidPs = append(inValidPs, p)
Expand All @@ -219,7 +220,13 @@ func ListProfiles(miniHome ...string) (validPs []*Profile, inValidPs []*Profile,
continue
}
validPs = append(validPs, p)

for _, child := range p.Config.Nodes {
nodeNames[MachineName(p.Config, &child)] = true
}
}

inValidPs = removeChildNodes(inValidPs, nodeNames)
return validPs, inValidPs, nil
}

Expand All @@ -243,6 +250,17 @@ func removeDupes(profiles []string) []string {
return result
}

func removeChildNodes(inValidPs []*Profile, nodeNames map[string]bool) []*Profile {
ps := []*Profile{}
for _, p := range inValidPs {
if _, ok := nodeNames[p.Name]; !ok {
ps = append(ps, p)
}
}

return ps
}

// LoadProfile loads type Profile based on its name
func LoadProfile(name string, miniHome ...string) (*Profile, error) {
cfg, err := DefaultLoader.LoadConfigFromFile(name, miniHome...)
Expand Down

0 comments on commit 12315d6

Please sign in to comment.