Skip to content

Commit

Permalink
Revert "Add startTime to the Traceflow Status (antrea-io#2952)"
Browse files Browse the repository at this point in the history
This reverts commit f679f04.
  • Loading branch information
qiyueyao committed Nov 9, 2021
1 parent d0419f9 commit 7fb2c3c
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 56 deletions.
4 changes: 0 additions & 4 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2954,8 +2954,6 @@ spec:
type: integer
type: object
type: array
startTime:
type: string
type: object
required:
- spec
Expand Down Expand Up @@ -3134,8 +3132,6 @@ spec:
type: integer
type: object
type: array
startTime:
type: string
type: object
required:
- spec
Expand Down
4 changes: 0 additions & 4 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2954,8 +2954,6 @@ spec:
type: integer
type: object
type: array
startTime:
type: string
type: object
required:
- spec
Expand Down Expand Up @@ -3134,8 +3132,6 @@ spec:
type: integer
type: object
type: array
startTime:
type: string
type: object
required:
- spec
Expand Down
4 changes: 0 additions & 4 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2954,8 +2954,6 @@ spec:
type: integer
type: object
type: array
startTime:
type: string
type: object
required:
- spec
Expand Down Expand Up @@ -3134,8 +3132,6 @@ spec:
type: integer
type: object
type: array
startTime:
type: string
type: object
required:
- spec
Expand Down
4 changes: 0 additions & 4 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2954,8 +2954,6 @@ spec:
type: integer
type: object
type: array
startTime:
type: string
type: object
required:
- spec
Expand Down Expand Up @@ -3134,8 +3132,6 @@ spec:
type: integer
type: object
type: array
startTime:
type: string
type: object
required:
- spec
Expand Down
4 changes: 0 additions & 4 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2954,8 +2954,6 @@ spec:
type: integer
type: object
type: array
startTime:
type: string
type: object
required:
- spec
Expand Down Expand Up @@ -3134,8 +3132,6 @@ spec:
type: integer
type: object
type: array
startTime:
type: string
type: object
required:
- spec
Expand Down
4 changes: 0 additions & 4 deletions build/yamls/base/crds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,6 @@ spec:
type: integer
phase:
type: string
startTime:
type: string
results:
type: array
items:
Expand Down Expand Up @@ -2026,8 +2024,6 @@ spec:
type: integer
phase:
type: string
startTime:
type: string
results:
type: array
items:
Expand Down
8 changes: 0 additions & 8 deletions pkg/apis/crd/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
type TraceflowPhase string

const (
// Pending is not used anymore
Pending TraceflowPhase = "Pending"
Running TraceflowPhase = "Running"
Succeeded TraceflowPhase = "Succeeded"
Expand Down Expand Up @@ -222,13 +221,6 @@ type TraceflowStatus struct {
Phase TraceflowPhase `json:"phase,omitempty"`
// Reason is a message indicating the reason of the traceflow's current phase.
Reason string `json:"reason,omitempty"`
// StartTime is the time at which the Traceflow as started by the Antrea Controller.
// Before K8s v1.20, null values (field not set) are not pruned, and a CR where a
// metav1.Time field is not set would fail OpenAPI validation (type string). The
// recommendation seems to be to use a pointer instead, and the field will be omitted when
// serializing.
// See https://github.com/kubernetes/kubernetes/issues/86811
StartTime *metav1.Time `json:"startTime,omitempty"`
// DataplaneTag is a tag to identify a traceflow session across Nodes.
DataplaneTag uint8 `json:"dataplaneTag,omitempty"`
// Results is the collection of all observations on different nodes.
Expand Down
4 changes: 0 additions & 4 deletions pkg/apis/crd/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 5 additions & 20 deletions pkg/controller/traceflow/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ func (c *Controller) startTraceflow(tf *crdv1alpha1.Traceflow) error {
return err
}

// checkTraceflowStatus is only called for Traceflows in the Running phase
func (c *Controller) checkTraceflowStatus(tf *crdv1alpha1.Traceflow) error {
succeeded := false
if tf.Spec.LiveTraffic && tf.Spec.DroppedOnly {
Expand Down Expand Up @@ -339,22 +338,12 @@ func (c *Controller) checkTraceflowStatus(tf *crdv1alpha1.Traceflow) error {
return c.updateTraceflowStatus(tf, crdv1alpha1.Succeeded, "", 0)
}

var timeout time.Duration
if tf.Spec.Timeout != 0 {
timeout = time.Duration(tf.Spec.Timeout) * time.Second
} else {
timeout = defaultTimeoutDuration
}
var startTime time.Time
if tf.Status.StartTime != nil {
startTime = tf.Status.StartTime.Time
} else {
// a fallback that should not be needed in general since we are in the Running phase
// when upgrading Antrea from a previous version, the field would be empty
klog.V(2).InfoS("StartTime field in Traceflow Status should not be empty", "Traceflow", klog.KObj(tf))
startTime = tf.CreationTimestamp.Time
timeoutSeconds := int64(tf.Spec.Timeout)
if timeoutSeconds == 0 {
timeoutSeconds = int64(defaultTimeoutDuration.Seconds())
}
if startTime.Add(timeout).Before(time.Now()) {
// CreationTimestamp is of second accuracy.
if time.Now().Unix() > tf.CreationTimestamp.Unix()+timeoutSeconds {
c.deallocateTagForTF(tf)
return c.updateTraceflowStatus(tf, crdv1alpha1.Failed, traceflowTimeout, 0)
}
Expand All @@ -364,10 +353,6 @@ func (c *Controller) checkTraceflowStatus(tf *crdv1alpha1.Traceflow) error {
func (c *Controller) updateTraceflowStatus(tf *crdv1alpha1.Traceflow, phase crdv1alpha1.TraceflowPhase, reason string, dataPlaneTag uint8) error {
update := tf.DeepCopy()
update.Status.Phase = phase
if phase == crdv1alpha1.Running && tf.Status.StartTime == nil {
t := metav1.Now()
update.Status.StartTime = &t
}
update.Status.DataplaneTag = dataPlaneTag
if reason != "" {
update.Status.Reason = reason
Expand Down

0 comments on commit 7fb2c3c

Please sign in to comment.