panic: send on closed channel - IdentifySlow
renanaAkeyless opened this issue · 0 comments
goroutine 15 [running]:
github.com/banzaicloud/satellite/providers.IdentifyOracleViaMetadataServer(0xc0000ed440, 0x139ac40, 0xc0001fc0e0)
/home/runner/go/pkg/mod/github.com/banzaicloud/satellite@v0.0.0-20190806115352-cd462539f731/providers/oracle.go:72 +0x611
created by github.com/banzaicloud/satellite/providers.(*IdentifySlow).Identify
/home/runner/go/pkg/mod/github.com/banzaicloud/satellite@v0.0.0-20190806115352-cd462539f731/providers/slow.go:29 +0x14e
panic: send on closed channel
goroutine 16 [running]:
github.com/banzaicloud/satellite/providers.IdentifyDigitalOceanViaMetadataServer(0xc0000ed440, 0x139ac40, 0xc0001fc0e0)
/home/runner/go/pkg/mod/github.com/banzaicloud/satellite@v0.0.0-20190806115352-cd462539f731/providers/digitalocean.go:72 +0x5e1
created by github.com/banzaicloud/satellite/providers.(*IdentifySlow).Identify
/home/runner/go/pkg/mod/github.com/banzaicloud/satellite@v0.0.0-20190806115352-cd462539f731/providers/slow.go:29 +0x14e
in the function (s *IdentifySlow) Identify(): in case you found the cloud the function returns and closes the channel
but other goroutines will try to write to it... you need to add defer and recover OR safe write to channel
func (s *IdentifySlow) Identify() (string, error) {
detected := make(chan string)
defer close(detected)
.................
for range prov {
d := <-detected
if d != defaults.Unknown {
return d, nil
}
}
return defaults.Unknown, nil
}