winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.6k stars 180 forks source link

feat(sdk): containers logs and improved simulator stability #6408

Closed eladb closed 1 week ago

eladb commented 2 weeks ago

Container improvements

Revisit how we are running containers in sim.Container to improve robustness and capture logs from docker build/pull commands and from running containers.

To do that we've changed how container lifecycle is managed by running it without --detach and monitoring the child process for exit codes, errors and stdio capture.

Simulator stability improvements

Additionally, this fixes a few long standing issues in the simulator which caused it to hang when one of the resources failed to start (e.g. due to unresolvable token). To fix this, we track failures and if there were any failing resources, we stop all the started resources and throw an error. Additionally, in the CLI we needed to catch this error, stop the spinner and bail out from the test execution routine. I believe this fixes #6052 and #5426.

Logging improvements

Add some initial support for log levels, because, come on, currently errors emitted from the simulator or resources are hidden by default because they are treated as "verbose". This includes the relevant Console fixes.

Tweak a little how logs are displayed when DEBUG=1 so that log entries are separated by a newline and removed the indentation of the first line (basically like jest/vitest is doing).

Other improvements

Hide the cloud.Endpoint nodes from the graph because it was a mistake (mine) to suggest to show them.

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

github-actions[bot] commented 2 weeks ago

Thanks for opening this pull request! :tada: Please consult the contributing guidelines for details on how to contribute to this project. If you need any assistence, don't hesitate to ping the relevant owner over Slack.

Topic Owner
Wing SDK and utility APIs @chriscbr
Wing Console @ainvoner, @skyrpex, @polamoros
JSON, structs, primitives and collections @hasanaburayyan
Platforms and plugins @hasanaburayyan
Frontend resources (website, react, etc) @tsuf239
Language design @chriscbr
VSCode extension and language server @markmcculloh
Compiler architecture, inflights, lifting @yoav-steinberg
Wing Testing Framework @tsuf239
Wing CLI @markmcculloh
Build system, dev environment, releases @markmcculloh
Library Ecosystem @chriscbr
Documentation @hasanaburayyan
SDK test suite @tsuf239
Examples @hasanaburayyan
Wing Playground @eladcon
monadabot commented 2 weeks ago

Console preview environment is available at https://wing-console-pr-6408.fly.dev :rocket:

Last Updated (UTC) 2024-05-06 18:18
monadabot commented 2 weeks ago

Benchmarks

Comparison to Baseline ⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜ | Benchmark | Before | After | Change | | :-- | --: | --: | --: | | version | 56ms±0.75 | 57ms±0.93 | +1ms (+2.35%)⬜ | | functions_1.test.w -t sim | 404ms±22.12 | 394ms±3.03 | -10ms (-2.42%)⬜ | | functions_1.test.w -t tf-aws | 809ms±3.32 | 819ms±9.55 | +10ms (+1.29%)⬜ | | jsii_big.test.w -t sim | 2766ms±14.18 | 2778ms±15.41 | +12ms (+0.44%)⬜ | | jsii_big.test.w -t tf-aws | 2971ms±8.14 | 2974ms±6.91 | +3ms (+0.1%)⬜ | | functions_10.test.w -t sim | 488ms±6.27 | 485ms±10.39 | -3ms (-0.61%)⬜ | | functions_10.test.w -t tf-aws | 1982ms±12.2 | 1996ms±6.72 | +14ms (+0.7%)⬜ | | jsii_small.test.w -t sim | 365ms±4.57 | 365ms±4.38 | 0ms (-0.01%)⬜ | | jsii_small.test.w -t tf-aws | 599ms±3.57 | 601ms±5.04 | +2ms (+0.3%)⬜ | | empty.test.w -t sim | 355ms±4.33 | 356ms±4.3 | +1ms (+0.24%)⬜ | | empty.test.w -t tf-aws | 590ms±3.41 | 588ms±4.09 | -3ms (-0.43%)⬜ | | hello_world.test.w -t sim | 398ms±3.77 | 394ms±5.09 | -4ms (-0.96%)⬜ | | hello_world.test.w -t tf-aws | 1498ms±5.66 | 1507ms±8.66 | +9ms (+0.59%)⬜ | ⬜ Within 1.5 standard deviations 🟩 Faster, Above 1.5 standard deviations 🟥 Slower, Above 1.5 standard deviations _Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI._
Results |name|mean|min|max|moe|sd| |----|----|----|----|----|----| |version|57ms|56ms|60ms|1ms|1ms| |functions_1.test.w -t sim|394ms|389ms|403ms|3ms|4ms| |functions_1.test.w -t tf-aws|819ms|801ms|843ms|10ms|13ms| |jsii_big.test.w -t sim|2778ms|2743ms|2809ms|15ms|22ms| |jsii_big.test.w -t tf-aws|2974ms|2954ms|2983ms|7ms|10ms| |functions_10.test.w -t sim|485ms|465ms|514ms|10ms|15ms| |functions_10.test.w -t tf-aws|1996ms|1981ms|2009ms|7ms|9ms| |jsii_small.test.w -t sim|365ms|354ms|372ms|4ms|6ms| |jsii_small.test.w -t tf-aws|601ms|588ms|609ms|5ms|7ms| |empty.test.w -t sim|356ms|347ms|369ms|4ms|6ms| |empty.test.w -t tf-aws|588ms|581ms|599ms|4ms|6ms| |hello_world.test.w -t sim|394ms|383ms|404ms|5ms|7ms| |hello_world.test.w -t tf-aws|1507ms|1491ms|1532ms|9ms|12ms|
Last Updated (UTC) 2024-05-06 18:24
monadabot commented 1 week ago

:x: Unstable Self-Mutation :x:

Self-mutation has run twice in a row. There may be a something non-deterministic in the build or test process. Check the last mutation commit (7f73b9798a13a042fa8bf7141edc686174d287c8) for suspicious changes. This is typically caused by:

eladb commented 1 week ago

@MarkMcCulloh ready for review

Chriscbr commented 1 week ago

@eladb Hrm - it seems like errors that start from outside of the the unit tests aren't getting printed anymore, can we fix this?

sample wing app
```js bring cloud; bring util; let f = new cloud.Function(inflight () => { throw "ah!"; }); test "my test" { log("my log"); f.invokeAsync(""); util.sleep(0.5s); log("my log 2"); } ```

Before:

Screenshot 2024-05-06 at 10 59 49 AM

After:

Screenshot 2024-05-06 at 11 00 08 AM
mergify[bot] commented 1 week ago

Thanks for contributing, @eladb! This PR will now be added to the merge queue, or immediately merged if eladb/container-logs is up-to-date with main and the queue is empty.

monadabot commented 1 week ago

Congrats! :rocket: This was released in Wing 0.73.30.