@@ -19,6 +19,7 @@ import (
1919 "context"
2020 "errors"
2121 "fmt"
22+ "strconv"
2223 "strings"
2324 "time"
2425
@@ -41,7 +42,6 @@ import (
4142 "github.com/devfile/devworkspace-operator/pkg/provision/sync"
4243 wsprovision "github.com/devfile/devworkspace-operator/pkg/provision/workspace"
4344 "github.com/devfile/devworkspace-operator/pkg/provision/workspace/rbac"
44- "github.com/devfile/devworkspace-operator/pkg/timing"
4545 "github.com/go-logr/logr"
4646 "github.com/google/uuid"
4747 coputil "github.com/redhat-cop/operator-utils/pkg/util"
@@ -184,9 +184,7 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
184184
185185 // Handle stopped workspaces
186186 if ! workspace .Spec .Started {
187- timing .ClearAnnotations (workspace )
188187 r .removeStartedAtFromCluster (ctx , workspace , reqLogger )
189- r .syncTimingToCluster (ctx , workspace , map [string ]string {}, reqLogger )
190188 return r .stopWorkspace (ctx , workspace , reqLogger )
191189 }
192190
@@ -217,12 +215,8 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
217215 clusterWorkspace := & common.DevWorkspaceWithConfig {}
218216 clusterWorkspace .DevWorkspace = workspace .DevWorkspace .DeepCopy ()
219217 clusterWorkspace .Config = workspace .Config
220- timingInfo := map [string ]string {}
221- timing .SetTime (timingInfo , timing .DevWorkspaceStarted )
222218
223219 defer func () (reconcile.Result , error ) {
224- r .syncTimingToCluster (ctx , clusterWorkspace , timingInfo , reqLogger )
225-
226220 // Don't accidentally suppress errors by overwriting here; only check for timeout when no error
227221 // encountered in main reconcile loop.
228222 if err == nil {
@@ -252,7 +246,6 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
252246 return reconcile.Result {Requeue : true }, err
253247 }
254248
255- timing .SetTime (timingInfo , timing .ComponentsCreated )
256249 flattenHelpers := flatten.ResolverTools {
257250 WorkspaceNamespace : workspace .Namespace ,
258251 Context : ctx ,
@@ -346,8 +339,6 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
346339 }
347340 reconcileStatus .setConditionTrue (conditions .StorageReady , "Storage ready" )
348341
349- timing .SetTime (timingInfo , timing .ComponentsReady )
350-
351342 // Add finalizer to ensure workspace rolebinding gets cleaned up when workspace
352343 // is deleted.
353344 if ! coputil .HasFinalizer (clusterWorkspace , constants .RBACCleanupFinalizer ) {
@@ -369,7 +360,6 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
369360 }
370361
371362 // Step two: Create routing, and wait for routing to be ready
372- timing .SetTime (timingInfo , timing .RoutingCreated )
373363 routingStatus := wsprovision .SyncRoutingToCluster (workspace , clusterAPI )
374364 if ! routingStatus .Continue {
375365 if routingStatus .FailStartup {
@@ -387,7 +377,6 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
387377 return reconcile.Result {Requeue : routingStatus .Requeue }, routingStatus .Err
388378 }
389379 reconcileStatus .setConditionTrue (dw .DevWorkspaceRoutingReady , "Networking ready" )
390- timing .SetTime (timingInfo , timing .RoutingReady )
391380
392381 statusOk , err := syncWorkspaceMainURL (clusterWorkspace , routingStatus .ExposedEndpoints , clusterAPI )
393382 if err != nil {
@@ -488,7 +477,6 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
488477 }
489478
490479 // Step six: Create deployment and wait for it to be ready
491- timing .SetTime (timingInfo , timing .DeploymentCreated )
492480 deploymentStatus := wsprovision .SyncDeploymentToCluster (workspace , allPodAdditions , serviceAcctName , clusterAPI )
493481 if ! deploymentStatus .Continue {
494482 if deploymentStatus .FailStartup {
@@ -503,7 +491,6 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
503491 return reconcile.Result {Requeue : deploymentStatus .Requeue }, deploymentStatus .Err
504492 }
505493 reconcileStatus .setConditionTrue (conditions .DeploymentReady , "DevWorkspace deployment ready" )
506- timing .SetTime (timingInfo , timing .DeploymentReady )
507494
508495 serverReady , err := checkServerStatus (clusterWorkspace )
509496 if err != nil {
@@ -513,8 +500,6 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
513500 reconcileStatus .setConditionFalse (dw .DevWorkspaceReady , "Waiting for editor to start" )
514501 return reconcile.Result {RequeueAfter : 1 * time .Second }, nil
515502 }
516- timing .SetTime (timingInfo , timing .DevWorkspaceReady )
517- timing .SummarizeStartup (clusterWorkspace )
518503 reconcileStatus .setConditionTrue (dw .DevWorkspaceReady , "" )
519504 reconcileStatus .phase = dw .DevWorkspaceStatusRunning
520505 return reconcile.Result {}, nil
@@ -617,27 +602,6 @@ func (r *DevWorkspaceReconciler) failWorkspace(workspace *common.DevWorkspaceWit
617602 return reconcile.Result {}, nil
618603}
619604
620- func (r * DevWorkspaceReconciler ) syncTimingToCluster (
621- ctx context.Context , workspace * common.DevWorkspaceWithConfig , timingInfo map [string ]string , reqLogger logr.Logger ) {
622- if timing .IsEnabled () {
623- if workspace .Annotations == nil {
624- workspace .Annotations = map [string ]string {}
625- }
626- for timingEvent , timestamp := range timingInfo {
627- if _ , set := workspace .Annotations [timingEvent ]; ! set {
628- workspace .Annotations [timingEvent ] = timestamp
629- }
630- }
631- if err := r .Update (ctx , workspace .DevWorkspace ); err != nil {
632- if k8sErrors .IsConflict (err ) {
633- reqLogger .Info ("Got conflict when trying to apply timing annotations to workspace" )
634- } else {
635- reqLogger .Error (err , "Error trying to apply timing annotations to devworkspace" )
636- }
637- }
638- }
639- }
640-
641605func (r * DevWorkspaceReconciler ) syncStartedAtToCluster (
642606 ctx context.Context , workspace * common.DevWorkspaceWithConfig , reqLogger logr.Logger ) {
643607
@@ -649,7 +613,7 @@ func (r *DevWorkspaceReconciler) syncStartedAtToCluster(
649613 return
650614 }
651615
652- workspace .Annotations [constants .DevWorkspaceStartedAtAnnotation ] = timing . CurrentTime ( )
616+ workspace .Annotations [constants .DevWorkspaceStartedAtAnnotation ] = strconv . FormatInt ( time . Now (). UnixNano () / 1e6 , 10 )
653617 if err := r .Update (ctx , workspace .DevWorkspace ); err != nil {
654618 if k8sErrors .IsConflict (err ) {
655619 reqLogger .Info ("Got conflict when trying to apply started-at annotations to workspace" )
0 commit comments