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

Unknown API Version warning for skaffold/v4beta1 #3125

Closed dallasvaughan closed 1 year ago

dallasvaughan commented 1 year ago

What did you do? Initialized a new skaffold.yaml using Cloud Code

What did you expect to see? Valid schema for apiVersion: skaffold/v4beta1 loaded and which provides accurate assistance for editing skaffold.yaml, and no warnings displayed

What did you see instead? A warning in skaffold.yaml for apiVersion: skaffold/v4beta1 stating "Unknown API Version"

Screenshot 2023-01-18 at 11 44 13 PM
etanshaul commented 1 year ago

Thanks! we'll aim to fix this in the next release.

ivanporty commented 1 year ago

Hi @dallasvaughan, did the updated latest insiders build (IB.3) release fix the issue for you?

dallasvaughan commented 1 year ago

@ivanporty Unfortunately, no.

ivanporty commented 1 year ago

@dallasvaughan We have just made some updates in the latest release 23.1.1, could you please try to upgrade and see if it helps you?

ivanporty commented 1 year ago

Newer insider build is also available.

dallasvaughan commented 1 year ago

EDIT: Found a workaround by setting "Mark this file as non-Kubernetes" (which adds # nonk8s to the first line of the file), since I guess the Kubernetes plugin tries to find a CRD for skaffold.yaml because it uses the same field names as standard k8s files.

Just updated to 23.1.1-222-IB.1 and still is giving a warning. However, it properly auto-suggests skaffold.yaml fields even though it displays warnings about the fields it suggests. The schema listed in the bottom toolbar is v3.json (pointing to the docs-v2 directory in the Skaffold project). When I select Tools/Cloud Code/Kubernetes/Check for Skaffold Schemas Upgrade it displays the pop-up "Skaffold Schema Upgrades Available", but what does that mean? Is there another action to take to actually upgrade the Skaffold schemas? Or does it automatically update? Should I configure JSON Schemas somehow to enable them?

Thanks!

ivanporty commented 1 year ago

With newer releases, you should be able to see when Cloud Code provides editing support. For example, you can see the messages are coming from Cloud Code below:

Screen Shot 2023-01-26 at 12 19 12 PM

We are trying to disable YAML editing support for YAML files when Jetbrains Kubernetes plugin is present, which is what you seem to have installed, correct? I assume you don't see Cloud Code messages and quick docs in your skaffold.yaml. Here is our setting which gets disabled when we detect JetBrains Kubernetes plugin:

lsp-setting

When I select Tools/Cloud Code/Kubernetes/Check for Skaffold Schemas Upgrade it displays the pop-up "Skaffold Schema Upgrades Available", but what does that mean? Is there another action to take to actually upgrade the Skaffold schemas? Or does it automatically update? Should I configure JSON Schemas somehow to enable them?

Due to some changes in the way notifications show, actual action to upgrade is not popping up, but it is there in the new Notifications toolwindow - you can click upgrade to the latest and your skaffold.yaml will be updated. One note though: we cannot preserve comments in the file and they will be gone after schema upgrade.

Screen Shot 2023-01-26 at 12 36 28 PM

If you upgrade to the latest (skaffold/v4beta2 in the latest release), you should see editing support for Cloud Code since JB plugin won't support this version.

dallasvaughan commented 1 year ago

Thanks for your assistance @ivanporty! I never opened the Notifications window so thanks for informing me. I clicked upgrade but no difference...

It's weird because I get Cloud Code indicators with every field except the apiVersion and kind fields (which are apparently being checked by the standard Kubernetes plugin). Checking or unchecking the Cloud Code/Kubernetes "Enable Kubernetes manifest editing features" has no effect on that.

Screenshot 2023-01-26 at 1 03 47 PM Screenshot 2023-01-26 at 1 04 31 PM

I guess something is borked with my own config somehow and so the Kubernetes plugin takes precedence when it shouldn't.

canmanmake commented 1 year ago

Same here: apiVersion: skaffold/v4beta2 kind: Config

It says unknown apiVersion (and unknown resource for kind).

I updated the plugin in IntelliJ and also have insider updates. Upgrade for Skaffold Schema from notification bar had no effect.

Same file was working with apiVersion: skaffold/v2beta18 which I tried again (and many other versions)

@dallasvaughan workaround (#nok8s) did not work for me. Final result from running "develop on kubernetes" is error in "Render Manifests": "replacing images in manifest: reading Kubernetes YAML: yaml: unmarshal errors: line 2: cannot unmarshal !!seq into map[string]interface {}"

ivanporty commented 1 year ago

@canmanmake thank you for the report. It seems that something is wrong with you skaffold version seeing an issue with deployment. Could you please tell us your plugin version, IDE version, and your skaffold version (Tools -> Google Cloud Code -> Dependencies)?

canmanmake commented 1 year ago

@ivanporty The plugin version is 23.3.3-222-IB.1 (updated today), IDE version is IntelliJ IDEA 2022.3.3 (Build #IU-223.8836.41), skaffold is v2.1.0

canmanmake commented 1 year ago

I might have found the error. Two things: 1) When disabling the kubernetes plugin, the "unknown apiVersion and kind" notification is gone in the skaffold.yaml. But enabling/disbaling the kubernets plugin seems to have no effect on the unmarshal error after pressing Develop on Kubernetes. See next. 2) The unmarshal error went away after cutting and pasting back the (unchanged!) contents of my deployment yaml file. Might be some refreshing/cache issue

ivanporty commented 1 year ago

@canmanmake thank you for the further investigation. (1) seems to be happening with combination of JB K8s plugin and Cloud Code as K8s plugin seems to be treating anything similar to K8s manifests as such and marking them unknown. #nok8s usually works for this but it seems for some reason it doesn't for you?

(2) indeed looks like IDE caching file changes? We do not use IDE file state when deploying but read skaffold.yaml directly from disk. Let us know if that reproduces again please.

ivanporty commented 1 year ago

Closing this as it seems to be only related to Jetbrains Kubernetes plugin presence and use of #nonK8s on skaffold.yaml files usually resolves the problem. There are no deployment or version issues in the latest plugin versions. please reopen if this reoccurs.

dallasvaughan commented 1 year ago

Adding #noK8s has no effect

image
anthonyalayo commented 1 year ago

I'm still encountering this and I don't understand exactly how/what the fix is?

dallasvaughan commented 1 year ago

Not sure if this changed recently (I'm on IntelliJ IDEA 2023.1.1 RC), but the skaffold.yaml file now has an option to "Mark this file as non-Kubernetes", which adds the #nonk8s line at the top (not #nok8s as I tried before with no luck).

This works for me.

ivanporty commented 1 year ago

@anthonyalayo Please confirm that adding #nonk8s helps IDE recognize this file as a skaffold yaml file.

anthonyalayo commented 1 year ago

@ivanporty still no luck, and I think I'm on the latest version? Note that it definitely works, just the IDE complaining.

image
dallasvaughan commented 1 year ago

It's case-sensitive, apparently - the K should be lowercase (#nonk8s)

anthonyalayo commented 1 year ago

I tried it with another project, another JetBrains IDE, still no luck: image

ivanporty commented 1 year ago

@anthonyalayo to help with debugging, if you disable Jetbrains K8s plugin for a test, and restart the IDE, do you see the skaffold.yaml file properly recognized?

anthonyalayo commented 1 year ago

@ivanporty I disabled the K8s plugin, restarted, and tried again:

image image

ivanporty commented 1 year ago

Oh I see what you have, sorry I missed that you have the very latest skaffold version (v4beta4). The latest we support right now is v4beta2. We probably should not show warnings if deployment still work, and try to pull the latest schemas which we do but it seems something is not working with it. We'll upgrage skaffold to the latest schema in the next release and work on the unknown revisions better.

anthonyalayo commented 1 year ago

Aha, that's the secret. Thanks!

ivanporty commented 1 year ago

@anthonyalayo @dallasvaughan we've updated the skaffold schemas to the latest in 23.5.2. Please use the latest release and see if that works for your latest schemas. Closing for now, please reopen if something is not right.