Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5xx 3.0 #42

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions utils/k8s/K8sUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,10 @@ func (impl K8sServiceImpl) GetCoreV1ClientByRestConfig(restConfig *rest.Config)

func (impl K8sServiceImpl) GetNodesList(ctx context.Context, k8sClientSet *kubernetes.Clientset) (*v1.NodeList, error) {
nodeList, err := k8sClientSet.CoreV1().Nodes().List(ctx, metav1.ListOptions{})
if err != nil {
if err != nil && strings.Contains(err.Error(), DnsLookupNoSuchHostError) {
impl.logger.Errorw("k8s cluster unreachable", "err", err)
return nil, &utils.ApiError{HttpStatusCode: http.StatusBadRequest, Code: "200", UserMessage: "k8s cluster unreachable"}
} else if err != nil {
impl.logger.Errorw("error in getting node list", "err", err)
return nil, err
}
Expand Down Expand Up @@ -1341,7 +1344,10 @@ func (impl K8sServiceImpl) GetApiResources(restConfig *rest.Config, includeOnlyV
}

apiResourcesListFromK8s, err := discoveryClient.ServerPreferredResources()
if err != nil {
if err != nil && strings.Contains(err.Error(), DnsLookupNoSuchHostError) {
impl.logger.Errorw("k8s cluster unreachable", "err", err)
return nil, &utils.ApiError{HttpStatusCode: http.StatusBadRequest, Code: "200", UserMessage: "k8s cluster unreachable"}
} else if err != nil {
//takes care when K8s is unable to handle the request for some resources
Isk8sApiError := strings.Contains(err.Error(), "unable to retrieve the complete list of server APIs")
switch Isk8sApiError {
Expand Down
1 change: 1 addition & 0 deletions utils/k8s/bean.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
DEVTRON_APP_LABEL_KEY = "app"
DEVTRON_APP_LABEL_VALUE1 = "devtron"
DEVTRON_APP_LABEL_VALUE2 = "orchestrator"
DnsLookupNoSuchHostError = "no such host"
)

type ClusterConfig struct {
Expand Down