Conversation
|
|
||
| w := tabwriter.NewWriter(cmd.OutOrStdout(), 4, 8, 4, ' ', 0) | ||
| _, _ = fmt.Fprintln(w, "PROFILE\tSTATUS\tARCH\tCPUS\tMEMORY\tDISK\tRUNTIME\tADDRESS") | ||
| _, _ = fmt.Fprintln(w, "PROFILE\tSTATUS\tARCH\tCPUS\tMEMORY\tDISK\tRUNTIME\tADDRESSES") |
There was a problem hiding this comment.
I think I would prefer to leave the wording as singular.
| if status.IPAddress != "" { | ||
| log.Println("address:", status.IPAddress) | ||
| if len(status.IPAddress) > 0 { | ||
| log.Println("addresses:", strings.Join(status.IPAddress, ", ")) |
There was a problem hiding this comment.
I prefer the singular wording here.
| ips := limautil.IPAddress(config.CurrentProfile().ID) | ||
| masterAddress := c.guest.Get(masterAddressKey) | ||
|
|
||
| var ip string | ||
| for _, addr := range ips { | ||
| if addr != masterAddress { | ||
| ip = addr | ||
| break | ||
| } | ||
| } | ||
|
|
||
| if ip == "" { |
There was a problem hiding this comment.
Sorry for the lack of code comment.
What is being done here is to prevent provisioning the kubeconfig when it is already done. If the value was previously set, the provisioning is ignored. i.e. same IP address, no need for an update.
| ips := limautil.IPAddress(config.CurrentProfile().ID) | |
| masterAddress := c.guest.Get(masterAddressKey) | |
| var ip string | |
| for _, addr := range ips { | |
| if addr != masterAddress { | |
| ip = addr | |
| break | |
| } | |
| } | |
| if ip == "" { | |
| ips := limautil.IPAddress(config.CurrentProfile().ID) | |
| masterAddress := c.guest.Get(masterAddressKey) | |
| for _, addr := range ips { | |
| if addr == masterAddress { |
The logic should be that if any of the ips matches masterAddress, there should be a return.
There was a problem hiding this comment.
Gotcha. The question though is what to do if we have multiple IPs. Currently the config provisioning assumes that there will be just one IP.
There was a problem hiding this comment.
That's why I'm considering introducing an optional --k3s-advertise-address flag.
The other option would be to inspect the k3s args and deduce the address from there (if set).
| output := strings.TrimSpace(buf.String()) | ||
| if output == "" { | ||
| return []string{} | ||
| } | ||
| return strings.Split(output, "\n") |
There was a problem hiding this comment.
This should handle it.
| output := strings.TrimSpace(buf.String()) | |
| if output == "" { | |
| return []string{} | |
| } | |
| return strings.Split(output, "\n") | |
| return strings.Fields(buf.String()) |
|
Thanks for this. Kindly attend to the code suggestions and the conflict and we should be good to go. |
| if status.IPAddress != "" { | ||
| log.Println("address:", status.IPAddress) | ||
| if len(status.IPAddress) > 0 { | ||
| log.Println("addresses:", strings.Join(status.IPAddress, ", ")) |
There was a problem hiding this comment.
| log.Println("addresses:", strings.Join(status.IPAddress, ", ")) | |
| log.Println("address:", strings.Join(status.IPAddress, ", ")) |
|
|
||
| w := tabwriter.NewWriter(cmd.OutOrStdout(), 4, 8, 4, ' ', 0) | ||
| _, _ = fmt.Fprintln(w, "PROFILE\tSTATUS\tARCH\tCPUS\tMEMORY\tDISK\tRUNTIME\tADDRESS") | ||
| _, _ = fmt.Fprintln(w, "PROFILE\tSTATUS\tARCH\tCPUS\tMEMORY\tDISK\tRUNTIME\tADDRESSES") |
There was a problem hiding this comment.
| _, _ = fmt.Fprintln(w, "PROFILE\tSTATUS\tARCH\tCPUS\tMEMORY\tDISK\tRUNTIME\tADDRESSES") | |
| _, _ = fmt.Fprintln(w, "PROFILE\tSTATUS\tARCH\tCPUS\tMEMORY\tDISK\tRUNTIME\tADDRESS") |
|
With the merge of #1365 I think it's no longer appropriate to produce an error from the k3s cluster install when there are multiple IPs assigned to the interface, since you can now make it work with |
Yeah, that is accurate. |
|
I'm going to close this PR for now. I think the user interface for when there are multiple IPs probably needs to be thought through a bit first. I've solved my own problem by not using assigning a fixed IP when creating a Colima instance with kubernetes enabled, so I don't really have a strong need for this anymore. If someone else has that need and wants to finish it up they're welcome to use this code or not. |
I'm opening this mostly for the sake of discussion. I'm not sure if this is the right decision to make.
A network interface can have more than one address assigned. Currently, colima kind of assumes that the interface will only have one address. When getting the IP address from the col0 interface, if that interface has more than one address assigned, the returned string will be something like:
192.168.105.3\n192.168.105.2. You can see this in the output of for examplecolima listwhere the second IP breaks the line and appears visually in the first column of the table:In the JSON output, the
ip_addressfield will be a string with the value"192.168.105.3\n192.168.105.2".This PR changes two things:
192.168.105.3, 192.168.105.2. This changes the JSON output ofip_addressfromstringto[]string.--advertised-address.