Skip to content

Commit

Permalink
updating the toolchainapi and other changes related to it
Browse files Browse the repository at this point in the history
Signed-off-by: Feny Mehta <[email protected]>
  • Loading branch information
fbm3307 committed May 14, 2024
1 parent d88423e commit 9c5a21b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 53 deletions.
32 changes: 4 additions & 28 deletions controllers/toolchaincluster/healthchecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,8 @@ func clusterReadyCondition() toolchainv1alpha1.Condition {
Status: corev1.ConditionTrue,
Reason: toolchainv1alpha1.ToolchainClusterClusterReadyReason,
Message: healthzOk,
<<<<<<< HEAD
LastTransitionTime: currentTime,
LastUpdatedTime: &currentTime,
=======
LastProbeTime: currentTime,
LastUpdatedTime: &currentTime,
LastTransitionTime: &currentTime,
>>>>>>> master
LastTransitionTime: currentTime,
}
}

Expand All @@ -89,14 +83,8 @@ func clusterNotReadyCondition() toolchainv1alpha1.Condition {
Status: corev1.ConditionFalse,
Reason: toolchainv1alpha1.ToolchainClusterClusterNotReadyReason,
Message: healthzNotOk,
<<<<<<< HEAD
LastTransitionTime: currentTime,
LastUpdatedTime: &currentTime,
=======
LastProbeTime: currentTime,
LastUpdatedTime: &currentTime,
LastTransitionTime: &currentTime,
>>>>>>> master
LastTransitionTime: currentTime,
}
}

Expand All @@ -107,14 +95,8 @@ func clusterOfflineCondition() toolchainv1alpha1.Condition {
Status: corev1.ConditionTrue,
Reason: toolchainv1alpha1.ToolchainClusterClusterNotReachableReason,
Message: clusterNotReachableMsg,
<<<<<<< HEAD
LastTransitionTime: currentTime,
LastUpdatedTime: &currentTime,
=======
LastProbeTime: currentTime,
LastUpdatedTime: &currentTime,
LastTransitionTime: &currentTime,
>>>>>>> master
LastTransitionTime: currentTime,
}
}

Expand All @@ -125,13 +107,7 @@ func clusterNotOfflineCondition() toolchainv1alpha1.Condition {
Status: corev1.ConditionFalse,
Reason: toolchainv1alpha1.ToolchainClusterClusterReachableReason,
Message: clusterReachableMsg,
<<<<<<< HEAD
LastTransitionTime: currentTime,
LastUpdatedTime: &currentTime,
=======
LastProbeTime: currentTime,
LastUpdatedTime: &currentTime,
LastTransitionTime: &currentTime,
>>>>>>> master
LastTransitionTime: currentTime,
}
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/codeready-toolchain/toolchain-common
go 1.20

require (
github.com/codeready-toolchain/api v0.0.0-20240502171347-8db815b922bd
github.com/codeready-toolchain/api v0.0.0-20240507023248-73662d6db2c5
github.com/go-logr/logr v1.2.3
github.com/golang-jwt/jwt/v5 v5.2.0
github.com/lestrrat-go/jwx v1.2.29
Expand Down Expand Up @@ -113,4 +113,4 @@ require (
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/codeready-toolchain/api => github.com/fbm3307/toolchainapi v0.0.0-20240502095518-0d75583a5baf
replace github.com/codeready-toolchain/api => github.com/fbm3307/toolchainapi v0.0.0-20240513145519-e72bfb85209f
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZM
github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/set v0.2.1/go.mod h1:+RKtMCH+favT2+3YecHGxcc0b4KyVWA1QWWJUs4E0CI=
github.com/fbm3307/toolchainapi v0.0.0-20240502095518-0d75583a5baf h1:s2k7giZJOHA3EYRya8EqqbkUl4vHJYG2s5g2XL4Eezo=
github.com/fbm3307/toolchainapi v0.0.0-20240502095518-0d75583a5baf/go.mod h1:ie9p4LenCCS0LsnbWp6/xwpFDdCWYE0KWzUO6Sk1g0E=
github.com/fbm3307/toolchainapi v0.0.0-20240513145519-e72bfb85209f h1:SU/YIxkyXbvXfZMLsxdHb71X0Bs3WHe6vfev9N25VUI=
github.com/fbm3307/toolchainapi v0.0.0-20240513145519-e72bfb85209f/go.mod h1:ie9p4LenCCS0LsnbWp6/xwpFDdCWYE0KWzUO6Sk1g0E=
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
Expand Down
7 changes: 1 addition & 6 deletions pkg/status/toolchaincluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ func GetToolchainClusterConditions(logger logr.Logger, attrs ToolchainClusterAtt
foundLastProbeTime := false
for _, condition := range toolchainCluster.ClusterStatus.Conditions {
if condition.Type == toolchainv1alpha1.ToolchainClusterReady {
lastProbeTime = func() metav1.Time {
if condition.LastUpdatedTime != nil {
return *condition.LastUpdatedTime
}
return condition.LastProbeTime
}()
lastProbeTime = *condition.LastUpdatedTime
foundLastProbeTime = true
}

Expand Down
24 changes: 9 additions & 15 deletions pkg/status/toolchaincluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ import (

var fakeToolchainClusterReason = "AToolchainClusterReason"
var fakeToolchainClusterMsg = "AToolchainClusterMsg"
var probtime = metav1.Now()
var probtime1 = metav1.NewTime(metav1.Now().Add(time.Duration(-10) * time.Minute))
var updatetime = metav1.NewTime(metav1.Now().Add(time.Duration(-3) * time.Second))
var updatetime1 = metav1.NewTime(metav1.Now().Add(time.Duration(-10) * time.Minute))
var updatetime = metav1.Now()
var log = logf.Log.WithName("toolchaincluster_test")

func TestGetToolchainClusterConditions(t *testing.T) {
Expand Down Expand Up @@ -177,33 +176,29 @@ func TestGetToolchainClusterConditions(t *testing.T) {
}

func newGetHostClusterReady() cluster.GetHostClusterFunc {
return NewFakeGetHostCluster(true, toolchainv1alpha1.ToolchainClusterReady, corev1.ConditionTrue, probtime1, fakeToolchainClusterReason, "", &updatetime)
return NewFakeGetHostCluster(true, toolchainv1alpha1.ToolchainClusterReady, corev1.ConditionTrue, fakeToolchainClusterReason, "", &updatetime)
}

func newGetHostClusterNotOk() cluster.GetHostClusterFunc {
return NewFakeGetHostCluster(false, toolchainv1alpha1.ToolchainClusterReady, corev1.ConditionFalse, probtime, fakeToolchainClusterReason, fakeToolchainClusterMsg, nil)
return NewFakeGetHostCluster(false, toolchainv1alpha1.ToolchainClusterReady, corev1.ConditionFalse, fakeToolchainClusterReason, fakeToolchainClusterMsg, &updatetime)
}

func newGetHostClusterOkButNotReady(message string) cluster.GetHostClusterFunc {
return NewFakeGetHostCluster(true, toolchainv1alpha1.ToolchainClusterReady, corev1.ConditionFalse, probtime, fakeToolchainClusterReason, message, nil)
return NewFakeGetHostCluster(true, toolchainv1alpha1.ToolchainClusterReady, corev1.ConditionFalse, fakeToolchainClusterReason, message, &updatetime)
}

func newGetHostClusterOkWithClusterOfflineCondition() cluster.GetHostClusterFunc {
return NewFakeGetHostCluster(true, toolchainv1alpha1.ToolchainClusterOffline, corev1.ConditionFalse, probtime, fakeToolchainClusterReason, fakeToolchainClusterMsg, nil)
return NewFakeGetHostCluster(true, toolchainv1alpha1.ToolchainClusterOffline, corev1.ConditionFalse, fakeToolchainClusterReason, fakeToolchainClusterMsg, &updatetime)
}

func newGetHostClusterLastProbeTimeExceeded() cluster.GetHostClusterFunc {
return NewFakeGetHostCluster(true, toolchainv1alpha1.ToolchainClusterReady, corev1.ConditionTrue, probtime1, fakeToolchainClusterReason, fakeToolchainClusterMsg, nil)
return NewFakeGetHostCluster(true, toolchainv1alpha1.ToolchainClusterReady, corev1.ConditionTrue, fakeToolchainClusterReason, fakeToolchainClusterMsg, &updatetime1)
}

// NewGetHostCluster returns cluster.GetHostClusterFunc function. The cluster.CachedToolchainCluster
// that is returned by the function then contains the given client and the given status and lastProbeTime.
// If ok == false, then the function returns nil for the cluster.
<<<<<<< HEAD
func NewFakeGetHostCluster(ok bool, conditionType toolchainv1alpha1.ConditionType, status corev1.ConditionStatus, lastProbeTime metav1.Time, reason, message string) cluster.GetHostClusterFunc {
=======
func NewFakeGetHostCluster(ok bool, conditionType toolchainv1alpha1.ToolchainClusterConditionType, status corev1.ConditionStatus, lastProbeTime metav1.Time, reason, message string, lastUpdatedTime *metav1.Time) cluster.GetHostClusterFunc {
>>>>>>> master
func NewFakeGetHostCluster(ok bool, conditionType toolchainv1alpha1.ConditionType, status corev1.ConditionStatus, reason, message string, lastUpdatedTime *metav1.Time) cluster.GetHostClusterFunc {
if !ok {
return func() (*cluster.CachedToolchainCluster, bool) {
return nil, false
Expand All @@ -216,11 +211,10 @@ func NewFakeGetHostCluster(ok bool, conditionType toolchainv1alpha1.ToolchainClu
OwnerClusterName: test.MemberClusterName,
},
ClusterStatus: &toolchainv1alpha1.ToolchainClusterStatus{
Conditions: []toolchainv1alpha1.ToolchainClusterCondition{{
Conditions: []toolchainv1alpha1.Condition{{
Type: conditionType,
Reason: reason,
Status: status,
LastProbeTime: lastProbeTime,
LastUpdatedTime: lastUpdatedTime,
}},
},
Expand Down

0 comments on commit 9c5a21b

Please sign in to comment.