Skip to content

Commit f5b1475

Browse files
utam0kroboquat
authored andcommitted
workspackit: put the workspace id into log to trace.
1 parent 679d37c commit f5b1475

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

components/workspacekit/cmd/rings.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ var ring0Cmd = &cobra.Command{
6060
Short: "starts ring0 - enter here",
6161
Run: func(_ *cobra.Command, args []string) {
6262
log.Init(ServiceName, Version, true, false)
63-
log := log.WithField("ring", 0)
63+
64+
wsid := os.Getenv("GITPOD_WORKSPACE_ID")
65+
if wsid == "" {
66+
log.Error("cannot find GITPOD_WORKSPACE_ID")
67+
return
68+
}
69+
70+
log := log.WithField("ring", 0).WithField("workspaceId", wsid)
6471

6572
common_grpc.SetupLogging()
6673

@@ -113,6 +120,7 @@ var ring0Cmd = &cobra.Command{
113120
cmd.Env = append(os.Environ(),
114121
"WORKSPACEKIT_FSSHIFT="+prep.FsShift.String(),
115122
fmt.Sprintf("WORKSPACEKIT_NO_WORKSPACE_MOUNT=%v", prep.FullWorkspaceBackup || prep.PersistentVolumeClaim),
123+
"GITPOD_WORKSPACE_ID="+wsid,
116124
)
117125

118126
if err := cmd.Start(); err != nil {
@@ -186,7 +194,13 @@ var ring1Cmd = &cobra.Command{
186194
Short: "starts ring1",
187195
Run: func(_cmd *cobra.Command, args []string) {
188196
log.Init(ServiceName, Version, true, false)
189-
log := log.WithField("ring", 1)
197+
198+
wsid := os.Getenv("GITPOD_WORKSPACE_ID")
199+
if wsid == "" {
200+
log.Error("cannot find GITPOD_WORKSPACE_ID")
201+
return
202+
}
203+
log := log.WithField("ring", 1).WithField("workspaceId", wsid)
190204

191205
common_grpc.SetupLogging()
192206

@@ -359,6 +373,7 @@ var ring1Cmd = &cobra.Command{
359373
}
360374

361375
env = append(env, "WORKSPACEKIT_WRAP_NETNS=true")
376+
env = append(env, "GITPOD_WORKSPACE_ID="+wsid)
362377

363378
socketFN := filepath.Join(os.TempDir(), fmt.Sprintf("workspacekit-ring1-%d.unix", time.Now().UnixNano()))
364379
skt, err := net.Listen("unix", socketFN)
@@ -738,7 +753,13 @@ var ring2Cmd = &cobra.Command{
738753
Args: cobra.ExactArgs(1),
739754
Run: func(_cmd *cobra.Command, args []string) {
740755
log.Init(ServiceName, Version, true, false)
741-
log := log.WithField("ring", 2)
756+
757+
wsid := os.Getenv("GITPOD_WORKSPACE_ID")
758+
if wsid == "" {
759+
log.Error("cannot find GITPOD_WORKSPACE_ID")
760+
return
761+
}
762+
log := log.WithField("ring", 2).WithField("workspaceId", wsid)
742763

743764
common_grpc.SetupLogging()
744765

0 commit comments

Comments
 (0)