Open jiankunking opened 5 years ago
Concurrent call harborClient.Repositories.ListRepositoryTags(repoRecordName) occur panic
for _, repoRecordName := range repositoryNames { wg.Add(1) go func(repoRecordName, harborAddress string, harborClient *harbor.Client) { defer wg.Done() repositoryTags, err := listRepositoryTags(repoRecordName, harborAddress, harborClient) if err != nil { errChan <- &err } repositoryTagsChan <- &repositoryTags }(repoRecordName, harborAddress, harborClient) }
error info: fatal error: concurrent map writes
goroutine 438 [running]: runtime.throw(0xa4f9e1, 0x15) C:/Go/src/runtime/panic.go:616 +0x88 fp=0xc042761b18 sp=0xc042761af8 pc=0x42d198 runtime.mapassign_faststr(0x97bbc0, 0xc04241ea80, 0xa45de4, 0x6, 0x4) C:/Go/src/runtime/hashmap_fast.go:703 +0x3f0 fp=0xc042761b88 sp=0xc042761b18 pc=0x40bd10 github.com/TimeBye/go-harbor/vendor/github.com/parnurzeal/gorequest.(SuperAgent).Set(...) F:/Code/Go/src/github.com/TimeBye/go-harbor/vendor/github.com/parnurzeal/gorequest/gorequest.go:240 github.com/TimeBye/go-harbor.(Client).NewRequest(0xc042118f30, 0xa444b1, 0x3, 0xc042418090, 0x21, 0xc042418090) F:/Code/Go/src/github.com/TimeBye/go-harbor/harbor.go:77 +0xd9 fp=0xc042761c50 sp=0xc042761b88 pc=0x8e14d9 github.com/TimeBye/go-harbor.(*RepositoriesService).ListRepositoryTags(0xc042130058, 0xc04247ac00, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0) F:/Code/Go/src/github.com/TimeBye/go-harbor/repositories.go:200 +0x13b fp=0xc042761cf8 sp=0xc042761c50 pc=0x8e671b git.haier.net/monitor/harbor-admin/pkg/service.listRepositoryTags(0xc04247ac00, 0xf, 0xa4ddad, 0x12, 0xc042118f30, 0x0, 0x0, 0x0, 0x0, 0x0) F:/Code/Go/src/git.haier.net/monitor/harbor-admin/pkg/service/harbor_images.go:126 +0x68 fp=0xc042761f20 sp=0xc042761cf8 pc=0x8eaa88 git.haier.net/monitor/harbor-admin/pkg/service.ListProjectsImages.func2(0xc042134d10, 0xc042130108, 0xc042202000, 0xc04247ac00, 0xf, 0xa4ddad, 0x12, 0xc042118f30) F:/Code/Go/src/git.haier.net/monitor/harbor-admin/pkg/service/harbor_images.go:87 +0xce fp=0xc042761fa0 sp=0xc042761f20 pc=0x8eb05e runtime.goexit() C:/Go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc042761fa8 sp=0xc042761fa0 pc=0x45a601 created by git.haier.net/monitor/harbor-admin/pkg/service.ListProjectsImages F:/Code/Go/src/git.haier.net/monitor/harbor-admin/pkg/service/harbor_images.go:85 +0xa80
goroutine 1 [IO wait]: internal/poll.runtime_pollWait(0x30a0ea0, 0x72, 0xaaf580) C:/Go/src/runtime/netpoll.go:173 +0x5e internal/poll.(pollDesc).wait(0xc04224a1c8, 0x72, 0xcf2500, 0x0, 0x0) C:/Go/src/internal/poll/fd_poll_runtime.go:85 +0xa2 internal/poll.(ioSrv).ExecIO(0xd37838, 0xc04224a018, 0xc0421f2760, 0x1, 0x0, 0x128) C:/Go/src/internal/poll/fd_windows.go:223 +0x13a internal/poll.(FD).acceptOne(0xc04224a000, 0x128, 0xc04224e0e0, 0x2, 0x2, 0xc04224a018, 0x46eb19, 0xc042077b88, 0x410f8f, 0x10) C:/Go/src/internal/poll/fd_windows.go:793 +0xae internal/poll.(FD).Accept(0xc04224a000, 0xc04211c760, 0x0, 0x0, 0x0, 0x0, 0xc000000000, 0x0, 0x0, 0x0, ...) C:/Go/src/internal/poll/fd_windows.go:827 +0x142 net.(netFD).accept(0xc04224a000, 0xc0422064e0, 0xc042077cf8, 0x4022f8) C:/Go/src/net/fd_windows.go:192 +0x86 net.(TCPListener).accept(0xc0421300e8, 0xc042077d28, 0x40119e, 0xc0422064e0) C:/Go/src/net/tcpsock_posix.go:136 +0x35 net.(TCPListener).AcceptTCP(0xc0421300e8, 0xc042077d70, 0xc042077d78, 0x18) C:/Go/src/net/tcpsock.go:246 +0x50 net/http.tcpKeepAliveListener.Accept(0xc0421300e8, 0xa70650, 0xc042206460, 0xab2900, 0xc0421190b0) C:/Go/src/net/http/server.go:3219 +0x36 net/http.(Server).Serve(0xc0421fe340, 0xab2440, 0xc0421300e8, 0x0, 0x0) C:/Go/src/net/http/server.go:2773 +0x1ac net/http.(Server).ListenAndServe(0xc0421fe340, 0xc0421fe340, 0xc04211c6f0) C:/Go/src/net/http/server.go:2714 +0xb0 net/http.ListenAndServe(0xc042134534, 0x5, 0xaae4a0, 0xc042236120, 0x1, 0x444fbe) C:/Go/src/net/http/server.go:2972 +0x81 github.com/gin-gonic/gin.(Engine).Run(0xc042236120, 0xc042077f58, 0x1, 0x1, 0x0, 0x0) F:/Code/Go/src/github.com/gin-gonic/gin/gin.go:287 +0x13f main.main() F:/Code/Go/src/git.haier.net/monitor/harbor-admin/cmd/main.go:20 +0x12f
I have fixed this bug https://github.com/jiankunking/harbor-go-client
大哥,这个支持的harbor版本似乎太低了,2.0+的,有轮子吗,素质点亮小星星
@barrettzjh 2.0的轮子由 @ClareChu 造出来了,在此十分感谢 @ClareChu
Concurrent call harborClient.Repositories.ListRepositoryTags(repoRecordName) occur panic
for _, repoRecordName := range repositoryNames { wg.Add(1) go func(repoRecordName, harborAddress string, harborClient *harbor.Client) { defer wg.Done() repositoryTags, err := listRepositoryTags(repoRecordName, harborAddress, harborClient) if err != nil { errChan <- &err } repositoryTagsChan <- &repositoryTags }(repoRecordName, harborAddress, harborClient) }
error info: fatal error: concurrent map writes
goroutine 438 [running]: runtime.throw(0xa4f9e1, 0x15) C:/Go/src/runtime/panic.go:616 +0x88 fp=0xc042761b18 sp=0xc042761af8 pc=0x42d198 runtime.mapassign_faststr(0x97bbc0, 0xc04241ea80, 0xa45de4, 0x6, 0x4) C:/Go/src/runtime/hashmap_fast.go:703 +0x3f0 fp=0xc042761b88 sp=0xc042761b18 pc=0x40bd10 github.com/TimeBye/go-harbor/vendor/github.com/parnurzeal/gorequest.(SuperAgent).Set(...) F:/Code/Go/src/github.com/TimeBye/go-harbor/vendor/github.com/parnurzeal/gorequest/gorequest.go:240 github.com/TimeBye/go-harbor.(Client).NewRequest(0xc042118f30, 0xa444b1, 0x3, 0xc042418090, 0x21, 0xc042418090) F:/Code/Go/src/github.com/TimeBye/go-harbor/harbor.go:77 +0xd9 fp=0xc042761c50 sp=0xc042761b88 pc=0x8e14d9 github.com/TimeBye/go-harbor.(*RepositoriesService).ListRepositoryTags(0xc042130058, 0xc04247ac00, 0xf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0) F:/Code/Go/src/github.com/TimeBye/go-harbor/repositories.go:200 +0x13b fp=0xc042761cf8 sp=0xc042761c50 pc=0x8e671b git.haier.net/monitor/harbor-admin/pkg/service.listRepositoryTags(0xc04247ac00, 0xf, 0xa4ddad, 0x12, 0xc042118f30, 0x0, 0x0, 0x0, 0x0, 0x0) F:/Code/Go/src/git.haier.net/monitor/harbor-admin/pkg/service/harbor_images.go:126 +0x68 fp=0xc042761f20 sp=0xc042761cf8 pc=0x8eaa88 git.haier.net/monitor/harbor-admin/pkg/service.ListProjectsImages.func2(0xc042134d10, 0xc042130108, 0xc042202000, 0xc04247ac00, 0xf, 0xa4ddad, 0x12, 0xc042118f30) F:/Code/Go/src/git.haier.net/monitor/harbor-admin/pkg/service/harbor_images.go:87 +0xce fp=0xc042761fa0 sp=0xc042761f20 pc=0x8eb05e runtime.goexit() C:/Go/src/runtime/asm_amd64.s:2361 +0x1 fp=0xc042761fa8 sp=0xc042761fa0 pc=0x45a601 created by git.haier.net/monitor/harbor-admin/pkg/service.ListProjectsImages F:/Code/Go/src/git.haier.net/monitor/harbor-admin/pkg/service/harbor_images.go:85 +0xa80
goroutine 1 [IO wait]: internal/poll.runtime_pollWait(0x30a0ea0, 0x72, 0xaaf580) C:/Go/src/runtime/netpoll.go:173 +0x5e internal/poll.(pollDesc).wait(0xc04224a1c8, 0x72, 0xcf2500, 0x0, 0x0) C:/Go/src/internal/poll/fd_poll_runtime.go:85 +0xa2 internal/poll.(ioSrv).ExecIO(0xd37838, 0xc04224a018, 0xc0421f2760, 0x1, 0x0, 0x128) C:/Go/src/internal/poll/fd_windows.go:223 +0x13a internal/poll.(FD).acceptOne(0xc04224a000, 0x128, 0xc04224e0e0, 0x2, 0x2, 0xc04224a018, 0x46eb19, 0xc042077b88, 0x410f8f, 0x10) C:/Go/src/internal/poll/fd_windows.go:793 +0xae internal/poll.(FD).Accept(0xc04224a000, 0xc04211c760, 0x0, 0x0, 0x0, 0x0, 0xc000000000, 0x0, 0x0, 0x0, ...) C:/Go/src/internal/poll/fd_windows.go:827 +0x142 net.(netFD).accept(0xc04224a000, 0xc0422064e0, 0xc042077cf8, 0x4022f8) C:/Go/src/net/fd_windows.go:192 +0x86 net.(TCPListener).accept(0xc0421300e8, 0xc042077d28, 0x40119e, 0xc0422064e0) C:/Go/src/net/tcpsock_posix.go:136 +0x35 net.(TCPListener).AcceptTCP(0xc0421300e8, 0xc042077d70, 0xc042077d78, 0x18) C:/Go/src/net/tcpsock.go:246 +0x50 net/http.tcpKeepAliveListener.Accept(0xc0421300e8, 0xa70650, 0xc042206460, 0xab2900, 0xc0421190b0) C:/Go/src/net/http/server.go:3219 +0x36 net/http.(Server).Serve(0xc0421fe340, 0xab2440, 0xc0421300e8, 0x0, 0x0) C:/Go/src/net/http/server.go:2773 +0x1ac net/http.(Server).ListenAndServe(0xc0421fe340, 0xc0421fe340, 0xc04211c6f0) C:/Go/src/net/http/server.go:2714 +0xb0 net/http.ListenAndServe(0xc042134534, 0x5, 0xaae4a0, 0xc042236120, 0x1, 0x444fbe) C:/Go/src/net/http/server.go:2972 +0x81 github.com/gin-gonic/gin.(Engine).Run(0xc042236120, 0xc042077f58, 0x1, 0x1, 0x0, 0x0) F:/Code/Go/src/github.com/gin-gonic/gin/gin.go:287 +0x13f main.main() F:/Code/Go/src/git.haier.net/monitor/harbor-admin/cmd/main.go:20 +0x12f