maybe fix duplicates? this isn't really safe probably

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-27 08:10:19 -05:00
parent 7288595efc
commit d38865a6cf
2 changed files with 19 additions and 4 deletions

View File

@ -102,7 +102,9 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
result, err := Start(hostname)
if err == nil {
fmt.Fprintln(w, result)
fmt.Fprintln(w, hostname, "started ok")
fmt.Fprintln(w, hostname, "started output ok")
fmt.Fprintln(w, hostname, "need to parse the output here")
fmt.Fprintln(w, hostname, "todo: switch to protobuf here")
} else {
fmt.Fprintln(w, result)
fmt.Fprintln(w, err)

View File

@ -230,8 +230,21 @@ func setUniqueSpicePort(check *pb.Droplet) error {
if d.SpicePort == 0 {
continue
}
if _, ok := ports[d.SpicePort]; ok {
log.Info("duplicate ports", d.SpicePort)
if dup, ok := ports[d.SpicePort]; ok {
// dup := ports[d.SpicePort]
log.Warn("duplicate ports", d.SpicePort, d.Hostname, d.CurrentState)
if d.CurrentState != pb.DropletState_ON {
// hack for now. should be safe to erase this
d.SpicePort = 0
log.Warn("erasing port for non-ON droplet", d.SpicePort, d.Hostname, d.CurrentState)
}
log.Warn("duplicate ports", dup.SpicePort, dup.Hostname, dup.CurrentState)
if dup.CurrentState != pb.DropletState_ON {
// hack for now. should be safe to erase this
dup.SpicePort = 0
log.Warn("erasing port for non-ON droplet", dup.SpicePort, dup.Hostname, dup.CurrentState)
}
// todo: fix this somewhow
return errors.New("duplicate ports")
}
ports[d.SpicePort] = d
@ -242,7 +255,7 @@ func setUniqueSpicePort(check *pb.Droplet) error {
}
var start int64
start = 5900
start = 5910
for {
if start == 6000 {
// x11 might use this on dom0's running a desktop