From c778ad3b173be34fe9ba1459845cf1a3ef7179a4 Mon Sep 17 00:00:00 2001 From: Tim Heurich Date: Mon, 7 Nov 2022 10:12:32 +0100 Subject: [PATCH] fix: handle http status 501 when fetch topics from a powered off cluster (#26) --- internal/pkg/client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/pkg/client.go b/internal/pkg/client.go index 0456acc..a9d1f04 100644 --- a/internal/pkg/client.go +++ b/internal/pkg/client.go @@ -25,7 +25,13 @@ func (c AivenClient) GetAccountTeamMembersList(accountId string, teamId string) func (c AivenClient) GetKafkaTopicsList(projectName string, serviceName string) []*aiven.KafkaListTopic { topics, err := c.client.KafkaTopics.List(projectName, serviceName) - handle(err) + if aivenError, ok := err.(aiven.Error); ok { + if aivenError.Status == 501 { + // Aiven returns 501 if a Kafka Cluster is powered off + return nil + } + handle(err) + } return topics }