Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDE error on mirrord errors #26

Open
t4lz opened this issue Jun 27, 2023 · 3 comments
Open

IDE error on mirrord errors #26

t4lz opened this issue Jun 27, 2023 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@t4lz
Copy link
Member

t4lz commented Jun 27, 2023

Bug Description

When the extension runs the CLI and the CLI fails, we want to show a notification with the error, but if there is also other output in stderr before the error, it throws an exception instead, the user sees an IDE error, and there is a stacktrace.

This happens when running with a deployment target, and some error in the config (e.g. non existing agent namespace).

Suggestion for solution (without having looked into it too much):
Iterate over the error stream and create a notification from each line that matches the pattern (starts with Error: , then a valid json), instead of trying to make a notification out of the whole error stream.

Steps to Reproduce

Run with this config:

{
    "target": {
        "path": "deploy/doesnotexist"
    }
}

Because we use a deploy target, the error stream starts with this message:

When targeting multi-pod deployments, mirrord impersonates the first pod in the deployment.
 Support for multi-pod impersonation requires the mirrord operator, which is part of mirrord for Teams.
 To try it out, join the waitlist with `mirrord waitlist <email address>`, or at this link: https://metalbear.co/#waitlist-form

and the extension gives up on creating a notification and throws an error.

Your operating system and version

macOS 13.4

@t4lz t4lz added bug Something isn't working good first issue Good for newcomers labels Jun 27, 2023
@eyalb181
Copy link
Member

@t4lz Aviram thinks we fixed this, does it still reproduce?

@t4lz
Copy link
Member Author

t4lz commented Dec 28, 2023

@t4lz Aviram thinks we fixed this, does it still reproduce?

Following the reproduction instructions I still get an IDE error:
image

mirrord task `"/Users/tal/Library/Application Support/JetBrains/IntelliJIdea2023.3/plugins/mirrord/bin/macos/mirrord" ext -f /Users/tal/Documents/projects/mirrord/sample/node/.mirrord/mirrord.json` failed

com.metalbear.mirrord.MirrordError: mirrord failed
	at com.metalbear.mirrord.MirrordError$Companion.fromStdErr(MirrordError.kt:24)
	at com.metalbear.mirrord.MirrordApi$MirrordExtTask.compute(MirrordApi.kt:138)
	at com.metalbear.mirrord.MirrordApi$MirrordExtTask.compute(MirrordApi.kt:98)
	at com.metalbear.mirrord.MirrordCliTask.computeWithResponsiveCancel$lambda$9(MirrordApi.kt:300)
	at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:249)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at com.intellij.util.concurrency.ContextCallable.call(ContextCallable.java:32)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
	at java.base/java.lang.Thread.run(Thread.java:840)

But only in the first run after starting IntelliJ.

The details of how this error happen might be a bit different than what's described in the issue, I did not investigate further, but running with the config from the issue after starting the IDE does still lead to an IDE error.

@infiniteregrets
Copy link
Contributor

I faced this same thing earlier and found it a bit annoying so fixed it somewhere, by extending the Progress trait with a function that selectively prints to the stdout i.e. if the mode is Json we don't print on the stdout at all but this also means that the message is not propagated back to the user.

Due to the limitation of indicatif and how it messes up the screen for multiline tasks, I think a better way around to this would be to introduce a macro that just checks if the mode is json, if it is not json then we can chunck the string into multiple progress.print() by separating on the newline otherwise we can just issue a warning or error as specified.

Thoughts @t4lz @eyalb181 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants