GoogleCloudPlatform / cloud-code-intellij

Plugin to support the Google Cloud Platform in IntelliJ IDEA - Docs and Issues Repository
Apache License 2.0
318 stars 59 forks source link

Plugin reports "no modules defined" when there are modules defined in skaffold.yaml #3157

Open dallasvaughan opened 10 months ago

dallasvaughan commented 10 months ago

Expected Behavior

When there are multiple skaffold.yaml modules defined, these modules aren't listed in the Build/Deploy configuration "Skaffold modules" section and cannot be selected to be run for a particular Run/Debug config.

Running with a particular module works correctly via CLI:

skaffold run -m <module>

Actual Behavior

When there are multiple skaffold.yaml modules defined, these modules are listed in the Build/Deploy configuration "Skaffold modules" section and are able to be selected to be run for a particular Run/Debug config.

Additional Information

ivanporty commented 10 months ago

Thanks for the report @dallasvaughan!

What is your version of skaffold on CLI you use to run, vs. bundled skaffold version in IDE (Tools -> Google Cloud Code -> Tools -> Terminal, and then which skaffold && skaffold version - according to settings, this seems to be 2.6.0) - are they the same?

ivanporty commented 10 months ago

Another question - current version of your skaffold.yaml (apiVersion: skaffold/v...)

dallasvaughan commented 10 months ago

The apiVersion of both configs in the skaffold.yaml is skaffold/v4beta6. The Managed Skaffold version in Google Cloud Code settings is v2.6.0

My locally-installed version is 2.6.2:

$ which skaffold && skaffold version
/opt/homebrew/bin/skaffold
v2.6.2
ivanporty commented 10 months ago

Thanks! We don't see issues with this setup with our module-based guestbook application so far. Are there any exceptions logged in idea.log (Help -> Show Log...)?

Other option - is there a single skaffold file in your project or multiple ones? Sometimes a module skaffold.yaml file gets selected in skaffold configuration file drop down instead of the one with all modules defined, if they are in the same project, and that could lead to no modules. I.e. for guestbook sample:

Screenshot 2023-08-17 at 1 41 14 PM

You will see different set of modules depending on which skaffold.yaml file is selected.

dallasvaughan commented 10 months ago

Apparently, the presence of #nonk8s at the top of the skaffold.yaml file is causing this issue. After removing this comment, it shows the modules as expected. (Please see #3125)

However, having this comment at the top of the skaffold.yaml file is necessary to prevent the Kubernetes Plugin from validating the skaffold.yaml file - otherwise it validates it as if it were a Kubernetes file, causing it to display multiple syntax errors, etc.

Can the plugin's module processing logic be updated to ignore comments on the first line of skaffold.yaml?

ivanporty commented 10 months ago

@dallasvaughan we tried to reproduce same steps, with K8s plugin installed and #nonk8s and we still see modules detected properly. Can you please create a guestbook K8s sample, add #nonk8s and see if modules are still detected? Again, it would be helpful if you could check for exceptions related to skaffold in idea.log file.

dallasvaughan commented 10 months ago

Okay, it's weird. It seems to have "worked itself out" somehow... I noticed while trying to edit my own project with different apiVersions that perhaps the error is intermittent. Here is the log which contains errors that might explain it. Notice the later entry 2023-08-18 14:57:11,850 [98212766] WARN - #com.google.cloud.tools.intellij.kubernetes.skaffold.modules.SkaffoldModuleService - Error reading and parsing skaffold modules

which seems like it might be why the UI doesn't display the modules at that moment (but this seems like a temporary state that eventually is corrected).

idea.log

ivanporty commented 10 months ago

Thank you for the log, indeed, this is the command used for getting module list behind the scenes, and it fails (intermittent, as you said):

2023-08-18 14:57:11,850 [98212766]   WARN - #com.google.cloud.tools.intellij.kubernetes.skaffold.modules.SkaffoldModuleService - Error reading and parsing skaffold modules
java.lang.UnsupportedOperationException: Exit code `1` when listing skaffold modules: `/Users/dallas/Library/Application Support/cloud-code/bin/versions/51eeb6552821471de759eca7bca6bddfbffcb626539e9866d0262357c042e157/skaffold inspect modules list --filename /Users/dallas/IdeaProjects/ngss-docs-site/skaffold.yaml`.
    at com.google.cloud.tools.intellij.kubernetes.skaffold.modules.SkaffoldModuleService.runSkaffoldCommand(SkaffoldModuleService.kt:98)
    at com.google.cloud.tools.intellij.kubernetes.skaffold.modules.SkaffoldModuleService.runSkaffoldCommand$default(SkaffoldModuleService.kt:80)
    at com.google.cloud.tools.intellij.kubernetes.skaffold.modules.SkaffoldModuleService.getModules(SkaffoldModuleService.kt:56)
    at com.google.cloud.tools.intellij.kubernetes.skaffold.run.ui.module.SkaffoldModuleSelectorPanel$updateModuleSettings$1$moduleList$1.invokeSuspend(SkaffoldModuleSelectorPanel.kt:135)

One possibility is somehow corrupted state of the skaffold.yaml file not saved yet, or not in valid state when a run configuration was opened - do you recall anything like this - opening a run configuration while in the middle of editing cycle?

It looks like around the same time when all skaffold inspection / configuration command failed for a selected skaffold.yaml file which might point to the same conclusion

ivanporty commented 10 months ago

@dallasvaughan any updates on the last comment - do you think this could be a probable cause of what you are seeing?

dallasvaughan commented 10 months ago

@dallasvaughan any updates on the last comment - do you think this could be a probable cause of what you are seeing?

Yes, that is a definite possibility since I was frequently editing the skaffold.yaml at the time.