Skip to content

Commit

Permalink
add missing commits
Browse files Browse the repository at this point in the history
Signed-off-by: MUzairS15 <muzair.shaikh810@gmail.com>
  • Loading branch information
MUzairS15 committed Jul 22, 2024
1 parent 9221b81 commit 7eb9a90
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 7 deletions.
8 changes: 4 additions & 4 deletions pkg/broker/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ const (
)

func ErrGettingResource(err error) error {
return errors.New(ErrGettingResourceCode + ":" + "Unable to get resource")
return errors.New(ErrGettingResourceCode + ":" + "Unable to get resource" + err.Error())
}

func ErrGettingEndpoint(err error) error {
return errors.New(ErrGettingEndpointCode + ":" + "Unable to get endpoint")
return errors.New(ErrGettingEndpointCode + ":" + "Unable to get endpoint" + err.Error())
}

func ErrReplicasNotReady(reason string) error {
return errors.New(ErrReplicasNotReadyCode + ":" + "The replicas are not ready")
return errors.New(ErrReplicasNotReadyCode + ":" + "The replicas are not ready" + reason)
}

func ErrConditionFalse(reason string) error {
return errors.New(ErrConditionFalseCode + ":" + "The condition is false")
return errors.New(ErrConditionFalseCode + ":" + "The condition is false" + reason)
}
44 changes: 44 additions & 0 deletions pkg/meshsync/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright 2023 Layer5, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package meshsync

import (
"errors"
)

const (
ErrGettingResourceCode = "1013"
ErrReplicasNotReadyCode = "1014"
ErrConditionFalseCode = "1015"
ErrGettingEndpointCode = "1016"
)

func ErrGettingResource(err error) error {
return errors.New(ErrGettingResourceCode + ":" + "Unable to get resource" + err.Error())
}

func ErrGettingEndpoint(err error) error {
return errors.New(ErrGettingEndpointCode + ":" + "Unable to get endpoint" + err.Error())
}

func ErrReplicasNotReady(reason string) error {
return errors.New(ErrReplicasNotReadyCode + ":" + "The replicas are not ready" + reason)
}

func ErrConditionFalse(reason string) error {
return errors.New(ErrConditionFalseCode + ":" + "The condition is false" + reason)
}
9 changes: 6 additions & 3 deletions pkg/meshsync/meshsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,18 @@ func getServerObject(namespace, name string, replicas int32, url string) Object
func CheckHealth(ctx context.Context, m *mesheryv1alpha1.MeshSync, client *kubernetes.Clientset) error {
obj, err := client.AppsV1().Deployments(m.ObjectMeta.Namespace).Get(ctx, m.ObjectMeta.Name, metav1.GetOptions{})
if err != nil {
return err
return ErrGettingResource(err)
}

if obj.Status.Replicas != obj.Status.ReadyReplicas {
return err
if len(obj.Status.Conditions) > 0 {
return ErrReplicasNotReady(obj.Status.Conditions[0].Reason)
}
return ErrReplicasNotReady("Condition Unknown")
}

if len(obj.Status.Conditions) > 0 && (obj.Status.Conditions[0].Status == corev1.ConditionFalse || obj.Status.Conditions[0].Status == corev1.ConditionUnknown) {
return err
return ErrConditionFalse(obj.Status.Conditions[0].Reason)
}

return nil
Expand Down

0 comments on commit 7eb9a90

Please sign in to comment.