@@ -11,12 +11,14 @@ import (
1111 "os"
1212
1313 "github.com/gitpod-io/gitpod/common-go/log"
14+ "github.com/gitpod-io/gitpod/common-go/tracing"
1415 "github.com/gitpod-io/gitpod/content-service/pkg/initializer"
1516 "github.com/gitpod-io/gitpod/content-service/pkg/storage"
1617 "github.com/gitpod-io/gitpod/ws-daemon/api"
1718 "github.com/gitpod-io/gitpod/ws-daemon/pkg/internal/session"
1819 "github.com/gitpod-io/gitpod/ws-daemon/pkg/iws"
1920 "github.com/gitpod-io/gitpod/ws-daemon/pkg/quota"
21+ "github.com/opentracing/opentracing-go"
2022 "golang.org/x/xerrors"
2123)
2224
@@ -50,7 +52,10 @@ func workspaceLifecycleHooks(cfg Config, kubernetesNamespace string, workspaceEx
5052
5153// hookSetupRemoteStorage configures the remote storage for a workspace
5254func hookSetupRemoteStorage (cfg Config ) session.WorkspaceLivecycleHook {
53- return func (ctx context.Context , ws * session.Workspace ) error {
55+ return func (ctx context.Context , ws * session.Workspace ) (err error ) {
56+ span , ctx := opentracing .StartSpanFromContext (ctx , "hook.SetupRemoteStorage" )
57+ defer tracing .FinishSpan (span , & err )
58+
5459 if _ , ok := ws .NonPersistentAttrs [session .AttrRemoteStorage ]; ! ws .RemoteStorageDisabled && ! ok {
5560 remoteStorage , err := storage .NewDirectAccess (& cfg .Storage )
5661 if err != nil {
@@ -75,7 +80,10 @@ func hookSetupRemoteStorage(cfg Config) session.WorkspaceLivecycleHook {
7580}
7681
7782// hookSetupWorkspaceLocation recreates the workspace location
78- func hookSetupWorkspaceLocation (ctx context.Context , ws * session.Workspace ) error {
83+ func hookSetupWorkspaceLocation (ctx context.Context , ws * session.Workspace ) (err error ) {
84+ //nolint:ineffassign
85+ span , _ := opentracing .StartSpanFromContext (ctx , "hook.SetupWorkspaceLocation" )
86+ defer tracing .FinishSpan (span , & err )
7987 location := ws .Location
8088
8189 // 1. Clean out the workspace directory
@@ -90,7 +98,7 @@ func hookSetupWorkspaceLocation(ctx context.Context, ws *session.Workspace) erro
9098 }
9199
92100 // Chown the workspace directory
93- err : = os .Chown (location , initializer .GitpodUID , initializer .GitpodGID )
101+ err = os .Chown (location , initializer .GitpodUID , initializer .GitpodGID )
94102 if err != nil {
95103 return xerrors .Errorf ("cannot create workspace: %w" , err )
96104 }
@@ -99,7 +107,10 @@ func hookSetupWorkspaceLocation(ctx context.Context, ws *session.Workspace) erro
99107
100108// hookInstallQuota enforces filesystem quota on the workspace location (if the filesystem supports it)
101109func hookInstallQuota (xfs * quota.XFS , isHard bool ) session.WorkspaceLivecycleHook {
102- return func (ctx context.Context , ws * session.Workspace ) error {
110+ return func (ctx context.Context , ws * session.Workspace ) (err error ) {
111+ span , _ := opentracing .StartSpanFromContext (ctx , "hook.InstallQuota" )
112+ defer tracing .FinishSpan (span , & err )
113+
103114 if xfs == nil {
104115 return nil
105116 }
@@ -114,7 +125,6 @@ func hookInstallQuota(xfs *quota.XFS, isHard bool) session.WorkspaceLivecycleHoo
114125
115126 var (
116127 prj int
117- err error
118128 )
119129 if ws .XFSProjectID != 0 {
120130 xfs .RegisterProject (ws .XFSProjectID )
@@ -134,7 +144,10 @@ func hookInstallQuota(xfs *quota.XFS, isHard bool) session.WorkspaceLivecycleHoo
134144
135145// hookRemoveQuota removes the filesystem quota, freeing up resources if need be
136146func hookRemoveQuota (xfs * quota.XFS ) session.WorkspaceLivecycleHook {
137- return func (ctx context.Context , ws * session.Workspace ) error {
147+ return func (ctx context.Context , ws * session.Workspace ) (err error ) {
148+ span , _ := opentracing .StartSpanFromContext (ctx , "hook.RemoveQuota" )
149+ defer tracing .FinishSpan (span , & err )
150+
138151 if xfs == nil {
139152 return nil
140153 }
0 commit comments