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

This adds LastTransitionTime to all knative/serving resources. #1142

Merged
merged 1 commit into from
Jun 11, 2018
Merged
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
5 changes: 5 additions & 0 deletions pkg/apis/serving/v1alpha1/configuration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1alpha1
import (
"encoding/json"
"fmt"
"time"

build "github.com/knative/build/pkg/apis/build/v1alpha1"

Expand Down Expand Up @@ -91,6 +92,9 @@ type ConfigurationCondition struct {

Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"`

// +optional
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"`

// +optional
Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"`

Expand Down Expand Up @@ -183,6 +187,7 @@ func (cs *ConfigurationStatus) setCondition(new *ConfigurationCondition) {
conditions = append(conditions, cond)
}
}
new.LastTransitionTime = metav1.NewTime(time.Now())
conditions = append(conditions, *new)
cs.Conditions = conditions
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/serving/v1alpha1/route_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1alpha1
import (
"encoding/json"
"fmt"
"time"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -94,6 +95,9 @@ type RouteCondition struct {

Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"`

// +optional
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "transited"? "transitioned"?


// +optional
Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"`
// +optional
Expand Down Expand Up @@ -194,6 +198,7 @@ func (rs *RouteStatus) setCondition(new *RouteCondition) {
conditions = append(conditions, cond)
}
}
new.LastTransitionTime = metav1.NewTime(time.Now())
conditions = append(conditions, *new)
rs.Conditions = conditions
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/serving/v1alpha1/service_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha1

import (
"encoding/json"
"time"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -81,6 +82,9 @@ type ServiceCondition struct {

Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"`

// +optional
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same transit nit


// +optional
Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"`
// +optional
Expand Down Expand Up @@ -156,6 +160,7 @@ func (ss *ServiceStatus) setCondition(new *ServiceCondition) {
conditions = append(conditions, cond)
}
}
new.LastTransitionTime = metav1.NewTime(time.Now())
conditions = append(conditions, *new)
ss.Conditions = conditions
}
Expand Down
22 changes: 11 additions & 11 deletions pkg/controller/configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ func TestMarkConfigurationReadyWhenLatestRevisionReady(t *testing.T) {
for _, ct := range []v1alpha1.ConfigurationConditionType{"Ready"} {
got := readyConfig.Status.GetCondition(ct)
want := &v1alpha1.ConfigurationCondition{
Type: ct,
Status: corev1.ConditionTrue,
// TODO(mattmoor): LastTransitionTime: got.LastTransitionTime,
Type: ct,
Status: corev1.ConditionTrue,
LastTransitionTime: got.LastTransitionTime,
}
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("Unexpected config conditions diff (-want +got): %v", diff)
Expand Down Expand Up @@ -522,11 +522,11 @@ func TestMarkConfigurationStatusWhenLatestRevisionIsNotReady(t *testing.T) {
for _, ct := range []v1alpha1.ConfigurationConditionType{"LatestRevisionReady"} {
got := readyConfig.Status.GetCondition(ct)
want := &v1alpha1.ConfigurationCondition{
Type: ct,
Status: corev1.ConditionFalse,
Reason: "RevisionFailed",
Message: `revision "test-config-00001" failed with message: Build step failed with error`,
// TODO(mattmoor): LastTransitionTime: got.LastTransitionTime,
Type: ct,
Status: corev1.ConditionFalse,
Reason: "RevisionFailed",
Message: `revision "test-config-00001" failed with message: Build step failed with error`,
LastTransitionTime: got.LastTransitionTime,
}
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("Unexpected config conditions diff (-want +got): %v", diff)
Expand Down Expand Up @@ -590,9 +590,9 @@ func TestMarkConfigurationReadyWhenLatestRevisionRecovers(t *testing.T) {
for _, ct := range []v1alpha1.ConfigurationConditionType{"Ready"} {
got := readyConfig.Status.GetCondition(ct)
want := &v1alpha1.ConfigurationCondition{
Type: ct,
Status: corev1.ConditionTrue,
// TODO(mattmoor): LastTransitionTime: got.LastTransitionTime,
Type: ct,
Status: corev1.ConditionTrue,
LastTransitionTime: got.LastTransitionTime,
}
if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("Unexpected config conditions diff (-want +got): %v", diff)
Expand Down
Loading