Skip to content

Commit

Permalink
fix: environment is not found error during operation of apikey-cacher (
Browse files Browse the repository at this point in the history
  • Loading branch information
masaaania authored Jul 7, 2023
1 parent 119308f commit 9414dc8
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions pkg/account/apikeycacher/apikeycacher.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,17 @@ func (c *EnvAPIKeyCacher) handleAPIKeyEvent(msg *puller.Message, event *domainev
c.logger.Warn("Message contains an empty apiKeyID", zap.Any("event", event))
return
}
envResp, err := c.environmentClient.GetEnvironment(c.ctx, &environmentproto.GetEnvironmentRequest{
Id: event.EnvironmentNamespace,
})
envResp, err := c.environmentClient.GetEnvironmentByNamespace(
c.ctx,
&environmentproto.GetEnvironmentByNamespaceRequest{
Namespace: event.EnvironmentNamespace,
},
)
if err != nil {
if code := status.Code(err); code == grpccodes.NotFound {
msg.Ack()
handledCounter.WithLabelValues(codes.BadMessage.String()).Inc()
c.logger.Error("The specified environmentNamespace ID does not exist",
c.logger.Error("The specified environmentNamespace does not exist",
zap.Error(err),
zap.String("apiKeyID", apiKeyID),
zap.String("environmentNamespace", event.EnvironmentNamespace),
Expand Down Expand Up @@ -329,14 +332,17 @@ func (c *EnvAPIKeyCacher) handleEnvironmentEvent(msg *puller.Message, event *dom
return
}
environmentNamespace := ede.Namespace
envResp, err := c.environmentClient.GetEnvironment(c.ctx, &environmentproto.GetEnvironmentRequest{
Id: event.EnvironmentNamespace,
})
envResp, err := c.environmentClient.GetEnvironmentByNamespace(
c.ctx,
&environmentproto.GetEnvironmentByNamespaceRequest{
Namespace: event.EnvironmentNamespace,
},
)
if err != nil {
if code := status.Code(err); code == grpccodes.NotFound {
msg.Ack()
handledCounter.WithLabelValues(codes.BadMessage.String()).Inc()
c.logger.Error("The specified environmentNamespace ID does not exist",
c.logger.Error("The specified environmentNamespace does not exist",
zap.Error(err),
zap.String("environmentNamespace", event.EnvironmentNamespace),
zap.Any("event", event),
Expand Down

0 comments on commit 9414dc8

Please sign in to comment.