@@ -883,23 +883,30 @@ type Workspace struct {
883
883
}
884
884
885
885
// updateDNSNames updates the DNS names for all agents in the workspace.
886
+ // DNS hosts must be all lowercase, or the resolver won't be able to find them.
887
+ // Usernames are globally unique & case-insensitive.
888
+ // Workspace names are unique per-user & case-insensitive.
889
+ // Agent names are unique per-workspace & case-insensitive.
886
890
func (w * Workspace ) updateDNSNames () error {
891
+ wsName := strings .ToLower (w .Name )
892
+ username := strings .ToLower (w .ownerUsername )
887
893
for id , a := range w .agents {
894
+ agentName := strings .ToLower (a .Name )
888
895
names := make (map [dnsname.FQDN ][]netip.Addr )
889
896
// TODO: technically, DNS labels cannot start with numbers, but the rules are often not
890
897
// strictly enforced.
891
- fqdn , err := dnsname .ToFQDN (fmt .Sprintf ("%s.%s.me.coder." , a . Name , w . Name ))
898
+ fqdn , err := dnsname .ToFQDN (fmt .Sprintf ("%s.%s.me.coder." , agentName , wsName ))
892
899
if err != nil {
893
900
return err
894
901
}
895
902
names [fqdn ] = []netip.Addr {CoderServicePrefix .AddrFromUUID (a .ID )}
896
- fqdn , err = dnsname .ToFQDN (fmt .Sprintf ("%s.%s.%s.coder." , a . Name , w . Name , w . ownerUsername ))
903
+ fqdn , err = dnsname .ToFQDN (fmt .Sprintf ("%s.%s.%s.coder." , agentName , wsName , username ))
897
904
if err != nil {
898
905
return err
899
906
}
900
907
names [fqdn ] = []netip.Addr {CoderServicePrefix .AddrFromUUID (a .ID )}
901
908
if len (w .agents ) == 1 {
902
- fqdn , err := dnsname .ToFQDN (fmt .Sprintf ("%s.coder." , w . Name ))
909
+ fqdn , err := dnsname .ToFQDN (fmt .Sprintf ("%s.coder." , wsName ))
903
910
if err != nil {
904
911
return err
905
912
}
0 commit comments