Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit b84de2b

Browse files
Merge pull request #2224 from ibuildthecloud/main
Make dev logging be able to be capture and not go to stdout/err
2 parents 4266a6a + 2a6c227 commit b84de2b

File tree

13 files changed

+236
-67
lines changed

13 files changed

+236
-67
lines changed

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ replace (
1313
require (
1414
cuelang.org/go v0.6.0
1515
github.com/AlecAivazis/survey/v2 v2.3.6
16-
github.com/acorn-io/aml v0.0.0-20231002033428-fffd2918563a
16+
github.com/acorn-io/aml v0.0.0-20231005222512-6a3f6ee06953
1717
github.com/acorn-io/aml/cli v0.0.0-20231002033428-fffd2918563a
1818
github.com/acorn-io/aml/legacy v0.0.0-20230929081514-1e9f3394432e
1919
github.com/acorn-io/baaah v0.0.0-20230831185433-be0115009281
@@ -41,7 +41,7 @@ require (
4141
github.com/hexops/autogold/v2 v2.2.1
4242
github.com/hexops/valast v1.4.4
4343
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de
44-
github.com/loft-sh/devspace v1.1.1-0.20221217093921-7604c5857f98
44+
github.com/loft-sh/devspace v1.1.1-0.20230918143357-5f97e998676e
4545
github.com/moby/buildkit v0.11.6
4646
github.com/opencontainers/go-digest v1.0.0
4747
github.com/opencontainers/image-spec v1.1.0-rc4
@@ -188,8 +188,8 @@ require (
188188
github.com/leodido/go-urn v1.2.4 // indirect
189189
github.com/letsencrypt/boulder v0.0.0-20221109233200-85aa52084eaf // indirect
190190
github.com/lithammer/fuzzysearch v1.1.5 // indirect
191-
github.com/loft-sh/loft-util v0.0.9-alpha // indirect
192191
github.com/loft-sh/notify v0.0.0-20210827094439-0720dcc7feee // indirect
192+
github.com/loft-sh/utils v0.0.16 // indirect
193193
github.com/magiconair/properties v1.8.7 // indirect
194194
github.com/mailru/easyjson v0.7.7 // indirect
195195
github.com/mattn/go-colorable v0.1.13 // indirect

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ github.com/ThalesIgnite/crypto11 v1.2.5 h1:1IiIIEqYmBvUYFeMnHqRft4bwf/O36jryEUpY
102102
github.com/ThalesIgnite/crypto11 v1.2.5/go.mod h1:ILDKtnCKiQ7zRoNxcp36Y1ZR8LBPmR2E23+wTQe/MlE=
103103
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8=
104104
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
105-
github.com/acorn-io/aml v0.0.0-20231002033428-fffd2918563a h1:vfo2HyUI+9OhHEDgOuQvpVjpS2z8RVwur2SSrDZw860=
106-
github.com/acorn-io/aml v0.0.0-20231002033428-fffd2918563a/go.mod h1:I1qN++bfN+6sOV/FiACluqj2Eu5YaHOy82cTAnjLMf0=
105+
github.com/acorn-io/aml v0.0.0-20231005222512-6a3f6ee06953 h1:uftFqiE7iD8B3gZkSiqvd53ny9Kf6YJbZxpt8bSDGsA=
106+
github.com/acorn-io/aml v0.0.0-20231005222512-6a3f6ee06953/go.mod h1:I1qN++bfN+6sOV/FiACluqj2Eu5YaHOy82cTAnjLMf0=
107107
github.com/acorn-io/aml/cli v0.0.0-20231002033428-fffd2918563a h1:0oMIx6lH47ImOakNyTDCfJGOonJHH1k5s0N1bLinCEU=
108108
github.com/acorn-io/aml/cli v0.0.0-20231002033428-fffd2918563a/go.mod h1:x7Y6lLMTqMD65KWjgVaGem5tQP2ZeevOQiaps9epJj4=
109109
github.com/acorn-io/aml/legacy v0.0.0-20230929081514-1e9f3394432e h1:W67DG9AcoNvBwIOR9OFUCZlSJBaHuvM2kXQ2+C6EnLk=
@@ -693,12 +693,12 @@ github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhn
693693
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
694694
github.com/lithammer/fuzzysearch v1.1.5 h1:Ag7aKU08wp0R9QCfF4GoGST9HbmAIeLP7xwMrOBEp1c=
695695
github.com/lithammer/fuzzysearch v1.1.5/go.mod h1:1R1LRNk7yKid1BaQkmuLQaHruxcC4HmAH30Dh61Ih1Q=
696-
github.com/loft-sh/devspace v1.1.1-0.20221217093921-7604c5857f98 h1:EdaHnOWn24TBX08Yuhjr2p2bqS4R0K0TiljMYMJFgac=
697-
github.com/loft-sh/devspace v1.1.1-0.20221217093921-7604c5857f98/go.mod h1:TWJTlQAUCM0+r21Yeo8ILOvBuWypy2L459arjwwIRHA=
698-
github.com/loft-sh/loft-util v0.0.9-alpha h1:kGcyTQWxWHWy7bbjhS8Hsq/JRdlSztAU++anV6P+sqk=
699-
github.com/loft-sh/loft-util v0.0.9-alpha/go.mod h1:lsjG5Exh5iEf7Z/87nqwkxx3GRQTizFRLGuS1knF6Cg=
696+
github.com/loft-sh/devspace v1.1.1-0.20230918143357-5f97e998676e h1:1io5eZaWJ5mLrO0VDOkvlaXnGPJ7iAPVFFgJTKJ2oUA=
697+
github.com/loft-sh/devspace v1.1.1-0.20230918143357-5f97e998676e/go.mod h1:ZkURPkP4R3O8TGlnoY/GCw79LHmWIIFyUfzrXrV+yk0=
700698
github.com/loft-sh/notify v0.0.0-20210827094439-0720dcc7feee h1:hZ79+pKEbCBrH1dVmgZ4jtFrrDPxgM4zqEP1lHlSnvI=
701699
github.com/loft-sh/notify v0.0.0-20210827094439-0720dcc7feee/go.mod h1:pq83B8lgfCY7tKdegTTXU6DZxGQkcWMowUTOTpTQmqk=
700+
github.com/loft-sh/utils v0.0.16 h1:XnD6Sb6gRWIHgM34U94dHcQ5MtxN5kAGZQ5eddAxC+c=
701+
github.com/loft-sh/utils v0.0.16/go.mod h1:n2L3X4i7d8kb2NF+q5duKa41N+N6fBde6XY2AolgSBI=
702702
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
703703
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
704704
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=

integration/dev/dev_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ func TestDev(t *testing.T) {
8181
}
8282

8383
_, err = appWatcher.ByName(ctx, project.Name, "test-app", func(app *v1.AppInstance) (bool, error) {
84-
return app.Spec.Image == oldImage && app.Status.DevSession != nil && app.Status.DevSession.SpecOverride.Image != "", nil
84+
return app.Spec.Image == oldImage && app.Status.DevSession != nil &&
85+
app.Status.DevSession.SpecOverride.Image != "" &&
86+
app.Status.DevSession.SpecOverride.Image != oldImage, nil
8587
})
8688
if err != nil {
8789
t.Fatal(err)

integration/log/log_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ func TestContainerLog(t *testing.T) {
118118
})
119119

120120
output, err := c.AppLog(ctx, app.Name, &client.LogOptions{
121-
ContainerReplica: replicas[0].Name,
121+
LogOptions: apiv1.LogOptions{
122+
ContainerReplica: replicas[0].Name,
123+
},
122124
})
123125
if err != nil {
124126
t.Fatal(err)
@@ -176,7 +178,9 @@ func TestSidecarContainerLog(t *testing.T) {
176178
})
177179

178180
output, err := c.AppLog(ctx, app.Name, &client.LogOptions{
179-
ContainerReplica: replicas[1].Name,
181+
LogOptions: apiv1.LogOptions{
182+
ContainerReplica: replicas[1].Name,
183+
},
180184
})
181185
if err != nil {
182186
t.Fatal(err)
@@ -223,7 +227,9 @@ func TestLogDuringDeletion(t *testing.T) {
223227
})
224228

225229
output, err := c.AppLog(ctx, app.Name, &client.LogOptions{
226-
Follow: true,
230+
LogOptions: apiv1.LogOptions{
231+
Follow: true,
232+
},
227233
})
228234
if err != nil {
229235
t.Fatal(err)

pkg/cli/log.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cli
33
import (
44
"fmt"
55

6+
apiv1 "github.com/acorn-io/runtime/pkg/apis/api.acorn.io/v1"
67
cli "github.com/acorn-io/runtime/pkg/cli/builder"
78
"github.com/acorn-io/runtime/pkg/client"
89
"github.com/acorn-io/runtime/pkg/log"
@@ -52,9 +53,11 @@ func (s *Logs) Run(cmd *cobra.Command, args []string) error {
5253
tailLines = &s.Tail
5354
}
5455
return log.Output(cmd.Context(), c, args[0], &client.LogOptions{
55-
Follow: s.Follow,
56-
Container: s.Container,
57-
Tail: tailLines,
58-
Since: s.Since,
56+
LogOptions: apiv1.LogOptions{
57+
Follow: s.Follow,
58+
Container: s.Container,
59+
Tail: tailLines,
60+
Since: s.Since,
61+
},
5962
})
6063
}

pkg/client/app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func (c *DefaultClient) appUpdate(ctx context.Context, name string, opts *AppUpd
222222
},
223223
Spec: v1.DevSessionInstanceSpec{
224224
Client: *opts.DevSessionClient,
225-
SessionTimeoutSeconds: 60,
225+
SessionTimeoutSeconds: 360,
226226
SessionStartTime: metav1.Now(),
227227
SessionRenewTime: metav1.Now(),
228228
SpecOverride: &app.Spec,
@@ -308,7 +308,7 @@ func (c *DefaultClient) AppLog(ctx context.Context, name string, opts *LogOption
308308
Resource("apps").
309309
Name(targetName).
310310
SubResource("log").
311-
VersionedParams((*apiv1.LogOptions)(opts), scheme.ParameterCodec).
311+
VersionedParams(&opts.LogOptions, scheme.ParameterCodec).
312312
URL()
313313

314314
conn, _, err := c.Dialer.DialWebsocket(ctx, url.String(), nil)

pkg/client/client.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,15 @@ type AppUpdateOptions struct {
112112
DevSessionClient *v1.DevSessionInstanceClient
113113
}
114114

115-
type LogOptions apiv1.LogOptions
115+
type ContainerLogsWriter interface {
116+
Container(timeStamp metav1.Time, containerName, line string)
117+
}
118+
119+
type LogOptions struct {
120+
apiv1.LogOptions
121+
122+
Logger ContainerLogsWriter
123+
}
116124

117125
type AppRunOptions struct {
118126
Name string

pkg/controller/appstatus/ready.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ func ReadyStatus(req router.Request, resp router.Response) error {
6060
}
6161
}
6262

63+
app.Status.Summary.ErrorMessages = errorMessages.List()
64+
app.Status.Summary.TransitioningMessages = transitioning.List()
65+
emptyMessage := len(app.Status.Summary.ErrorMessages) == 0 &&
66+
len(app.Status.Summary.TransitioningMessages) == 0
67+
6368
var state string
6469
if !app.DeletionTimestamp.IsZero() {
6570
state = "removing"
@@ -68,12 +73,13 @@ func ReadyStatus(req router.Request, resp router.Response) error {
6873
state = "stopped"
6974
} else {
7075
state = "stopping"
76+
if emptyMessage {
77+
app.Status.Summary.TransitioningMessages = append(app.Status.Summary.TransitioningMessages, "Stopping")
78+
}
7179
}
7280
} else if errorMessages.Len() > 0 {
73-
app.Status.Summary.ErrorMessages = []string{errorMessages.List()[0]}
7481
state = "error"
7582
} else if transitioning.Len() > 0 {
76-
app.Status.Summary.TransitioningMessages = []string{transitioning.List()[0]}
7783
state = "provisioning"
7884
} else if app.Status.Ready {
7985
if app.Status.AppStatus.Completed {
@@ -83,6 +89,9 @@ func ReadyStatus(req router.Request, resp router.Response) error {
8389
}
8490
} else {
8591
state = "not ready"
92+
if emptyMessage {
93+
app.Status.Summary.TransitioningMessages = append(app.Status.Summary.TransitioningMessages, "Waiting")
94+
}
8695
}
8796

8897
app.Status.Summary.State = state

0 commit comments

Comments
 (0)