Reputation: 75810
I would like to pull a Google PubSub subscription with Go. It works well locally but when I deploy it on Cloud Run, impossible to pull any message.
Here my code snippet
func (pubSubService *pubSubService) Received() (msgArray []*pubsub.Message, err error) {
ctx := context.Background()
cctx, cancel := context.WithCancel(ctx)
msgArray = []*pubsub.Message{}
var receivedMessage = make(chan *pubsub.Message)
go func() {
for {
select {
case msg := <-receivedMessage:
msgArray = append(msgArray, msg)
case <-time.After(pubSubService.waitTimeOutInMillis * time.Millisecond):
cancel()
}
}
}()
err = pubSubService.client.Subscription(pubSubService.subscriptionName).Receive(cctx, func(ctx context.Context, msg *pubsub.Message) {
receivedMessage <- msg
msg.Ack()
})
if err != nil {
return
}
return
}
Here the log error
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x7,0x6,0x12,0xc00006f204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x5,0x6,0x12,0xc0003c1204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0xa,0x6,0x12,0xc0003bd204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0xc,0x6,0x12,0xc00037d204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x6,0x6,0x12,0xc0002d3204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x8,0x6,0x12,0xc00052b204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x9,0x6,0x12,0xc000391204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0xb,0x6,0x12,0xc00043b204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x6,0x6,0x12,0xc0003b3204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0xc,0x6,0x12,0xc0003d3204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x7,0x6,0x12,0xc000391204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0x5,0x6,0x12,0xc000309204,0x4,0x0)
D Container Sandbox Limitation: Unsupported syscall setsockopt(0xb,0x6,0x12,0xc0004d3204,0x4,0x0)
The Received call is filter by the GVisor sandbox of Cloud Run
Do you know workarround or ReceiveSetting to set for this issue ? Thanks in advance.
Upvotes: 2
Views: 308
Reputation: 75810
No it's wrong. I found my issue: I over estimated the GCP global network: My timeout which cancel the polling was set to 200ms. With this requirement, my app don't have the time to recover the first message before the cancel. With 2000ms of timeout, it work perfectly !
Go routine are allowed with Cloud run, but they can't survive after the reply of the http request.
Upvotes: 1
Reputation: 2584
Pull subscription doesn't work in Cloud Run because the container gets throttled or even terminated out of request scope.
The goroutine is not able to proceed.
Upvotes: 0