SAP-archive / ytt-lint

ytt lint validates ytt-templates and plain yaml-files. It is designed for Kubernetes artifacts, but works with other yaml-files.
Apache License 2.0
11 stars 2 forks source link

SIGSEGV when pulling schemas in VS Code #3

Closed MPV closed 3 years ago

MPV commented 3 years ago

I'm not able to pull CRD schemas using v0.2.0 of the VS Code plugin.

When I run ytt-lint: Pull crd schemas from Kubernetes cluster, I just get:

Pulling from k8s...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1e7351f]

goroutine 1 [running]:
k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset.(*Clientset).ApiextensionsV1(...)
    /home/d060677/go/pkg/mod/k8s.io/apiextensions-apiserver@v0.17.4/pkg/client/clientset/clientset/clientset.go:52
github.com/SAP/ytt-lint/pkg/pull.Pull(0x22af280, 0xc00000e018)
    /home/d060677/git/ytt-lint/pkg/pull/k8s.go:35 +0x35f
main.main()
    /home/d060677/git/ytt-lint/cmd/ytt-lint/ytt-lint.go:34 +0x7df
Exit code: 2

I.e. from here: https://github.com/SAP/ytt-lint/blob/03765f7e556f8c36a356a2398f86c40098a0113b/pkg/pull/k8s.go#L35

Any ideas?

MPV commented 3 years ago

@phil9909 😊

phil9909 commented 3 years ago

What kubernetes version are you using? What type of cluster is it (GKE, AKS, Gardener, Azure, minikube)?

phil9909 commented 3 years ago

The latest release v0.2.1 contains a bugfix 36e46cce1ab3615b52d7f1ed41b2efe8425b884b for a missing error check. Because of that bug ytt lint crashes with a SIGSEGV instead of printing a proper error message. Can you try it again and post the real error message?

MPV commented 3 years ago

Tried on a kind cluster (with no custom CRDs installed yet):

Pulling from k8s...
Exit code: 0
MPV commented 3 years ago

Tried on a cluster-api cluster:

Pulling from k8s...
Writing schema for Alertmanager version v1 of group monitoring.coreos.com to /Users/vs/.ytt-lint/schema/k8s/monitoring.coreos.com/v1/alertmanager.json
Writing schema for BGPConfiguration version v1 of group crd.projectcalico.org to /Users/vs/.ytt-lint/schema/k8s/crd.projectcalico.org/v1/bgpconfiguration.json
Writing schema for BGPPeer version v1 of group crd.projectcalico.org to /Users/vs/.ytt-lint/schema/k8s/crd.projectcalico.org/v1/bgppeer.json
Writing schema for BlockAffinity version v1 of group crd.projectcalico.org to /Users/vs/.ytt-lint/schema/k8s/crd.projectcalico.org/v1/blockaffinity.json
Writing schema for ClusterInformation version v1 of group crd.projectcalico.org to /Users/vs/.ytt-lint/schema/k8s/crd.projectcalico.org/v1/clusterinformation.json
Writing schema for ExternalSecret version v1 of group kubernetes-client.io to /Users/vs/.ytt-lint/schema/k8s/kubernetes-client.io/v1/externalsecret.json
Writing schema for FelixConfiguration version v1 of group crd.projectcalico.org to /Users/vs/.ytt-lint/schema/k8s/crd.projectcalico.org/v1/felixconfiguration.json
Writing schema for GlobalNetworkPolicy version v1 of group crd.projectcalico.org to /Users/vs/.ytt-lint/schema/k8s/crd.projectcalico.org/v1/globalnetworkpolicy.json
Writing schema for GlobalNetworkSet version v1 of group crd.projectcalico.org to /Users/vs/.ytt-lint/schema/k8s/crd.projectcalico.org/v1/globalnetworkset.json
Writing schema for HostEndpoint version v1 of group crd.projectcalico.org to /Users/vs/.ytt-lint/schema/k8s/crd.projectcalico.org/v1/hostendpoint.json
Writing schema for IPAMBlock version v1 of group crd.projectcalico.org to /Users/vs/.ytt-lint/schema/k8s/crd.projectcalico.org/v1/ipamblock.json
Writing schema for IPAMConfig version v1 of group crd.projectcalico.org to /Users/vs/.ytt-lint/schema/k8s/crd.projectcalico.org/v1/ipamconfig.json
Writing schema for IPAMHandle version v1 of group crd.projectcalico.org to /Users/vs/.ytt-lint/schema/k8s/crd.projectcalico.org/v1/ipamhandle.json
Writing schema for IPPool version v1 of group crd.projectcalico.org to /Users/vs/.ytt-lint/schema/k8s/crd.projectcalico.org/v1/ippool.json
Writing schema for KubeControllersConfiguration version v1 of group crd.projectcalico.org to /Users/vs/.ytt-lint/schema/k8s/crd.projectcalico.org/v1/kubecontrollersconfiguration.json
Writing schema for NetworkPolicy version v1 of group crd.projectcalico.org to /Users/vs/.ytt-lint/schema/k8s/crd.projectcalico.org/v1/networkpolicy.json
Writing schema for NetworkSet version v1 of group crd.projectcalico.org to /Users/vs/.ytt-lint/schema/k8s/crd.projectcalico.org/v1/networkset.json
Writing schema for PodMonitor version v1 of group monitoring.coreos.com to /Users/vs/.ytt-lint/schema/k8s/monitoring.coreos.com/v1/podmonitor.json
Writing schema for Prometheus version v1 of group monitoring.coreos.com to /Users/vs/.ytt-lint/schema/k8s/monitoring.coreos.com/v1/prometheus.json
Writing schema for PrometheusRule version v1 of group monitoring.coreos.com to /Users/vs/.ytt-lint/schema/k8s/monitoring.coreos.com/v1/prometheusrule.json
Writing schema for ServiceMonitor version v1 of group monitoring.coreos.com to /Users/vs/.ytt-lint/schema/k8s/monitoring.coreos.com/v1/servicemonitor.json
Exit code: 0
MPV commented 3 years ago

Tried on a GKE cluster:

Pulling from k8s...
Error: apiextensionsclientset.NewForConfig(): no Auth Provider found for name "gcp"
Exit code: 1

Most of my clusters are GKE clusters, so having this supported would be nice.

Any ideas what might be going wrong?

Let me know if there's anything else I can do to help?

MPV commented 3 years ago

@phil9909 Would you be up for releasing a new version with the fix in 887114e?

phil9909 commented 3 years ago

Just published release v0.2.2 and also uploaded it to Visual Studio Marketplace and Open VSX Registry so you should get an auto-update soon. You can also manually download the VSIX file and then install it using code --install-extension /path/to/extension or codium --install-extension /path/to/extension.

MPV commented 3 years ago

Wonderful! Worked like a charm:

Pulling from k8s...
Writing schema for Alertmanager version v1 of group monitoring.coreos.com to /Users/vs/.ytt-lint/schema/k8s/monitoring.coreos.com/v1/alertmanager.json
Writing schema for Application version v1alpha1 of group argoproj.io to /Users/vs/.ytt-lint/schema/k8s/argoproj.io/v1alpha1/application.json
Writing schema for AppProject version v1alpha1 of group argoproj.io to /Users/vs/.ytt-lint/schema/k8s/argoproj.io/v1alpha1/appproject.json
Writing schema for BackendConfig version v1 of group cloud.google.com to /Users/vs/.ytt-lint/schema/k8s/cloud.google.com/v1/backendconfig.json
Writing schema for BackendConfig version v1beta1 of group cloud.google.com to /Users/vs/.ytt-lint/schema/k8s/cloud.google.com/v1beta1/backendconfig.json
Writing schema for CertificateRequest version v1 of group cert-manager.io to /Users/vs/.ytt-lint/schema/k8s/cert-manager.io/v1/certificaterequest.json
Writing schema for CertificateRequest version v1alpha1 of group certmanager.k8s.io to /Users/vs/.ytt-lint/schema/k8s/certmanager.k8s.io/v1alpha1/certificaterequest.json
Writing schema for Certificate version v1 of group cert-manager.io to /Users/vs/.ytt-lint/schema/k8s/cert-manager.io/v1/certificate.json
Writing schema for Certificate version v1alpha1 of group certmanager.k8s.io to /Users/vs/.ytt-lint/schema/k8s/certmanager.k8s.io/v1alpha1/certificate.json
Writing schema for Challenge version v1 of group acme.cert-manager.io to /Users/vs/.ytt-lint/schema/k8s/acme.cert-manager.io/v1/challenge.json
Writing schema for Challenge version v1alpha1 of group certmanager.k8s.io to /Users/vs/.ytt-lint/schema/k8s/certmanager.k8s.io/v1alpha1/challenge.json
Writing schema for ClusterIssuer version v1 of group cert-manager.io to /Users/vs/.ytt-lint/schema/k8s/cert-manager.io/v1/clusterissuer.json
Writing schema for ClusterIssuer version v1alpha1 of group certmanager.k8s.io to /Users/vs/.ytt-lint/schema/k8s/certmanager.k8s.io/v1alpha1/clusterissuer.json
Writing schema for ExternalSecret version v1 of group kubernetes-client.io to /Users/vs/.ytt-lint/schema/k8s/kubernetes-client.io/v1/externalsecret.json
Writing schema for GithubActionRunner version v1alpha1 of group garo.tietoevry.com to /Users/vs/.ytt-lint/schema/k8s/garo.tietoevry.com/v1alpha1/githubactionrunner.json
Writing schema for Issuer version v1 of group cert-manager.io to /Users/vs/.ytt-lint/schema/k8s/cert-manager.io/v1/issuer.json
Writing schema for Issuer version v1alpha1 of group certmanager.k8s.io to /Users/vs/.ytt-lint/schema/k8s/certmanager.k8s.io/v1alpha1/issuer.json
Writing schema for ManagedCertificate version v1beta1 of group networking.gke.io to /Users/vs/.ytt-lint/schema/k8s/networking.gke.io/v1beta1/managedcertificate.json
Writing schema for ManagedCertificate version v1beta2 of group networking.gke.io to /Users/vs/.ytt-lint/schema/k8s/networking.gke.io/v1beta2/managedcertificate.json
Writing schema for Order version v1 of group acme.cert-manager.io to /Users/vs/.ytt-lint/schema/k8s/acme.cert-manager.io/v1/order.json
Writing schema for Order version v1alpha1 of group certmanager.k8s.io to /Users/vs/.ytt-lint/schema/k8s/certmanager.k8s.io/v1alpha1/order.json
Writing schema for PodMonitor version v1 of group monitoring.coreos.com to /Users/vs/.ytt-lint/schema/k8s/monitoring.coreos.com/v1/podmonitor.json
Writing schema for Prometheus version v1 of group monitoring.coreos.com to /Users/vs/.ytt-lint/schema/k8s/monitoring.coreos.com/v1/prometheus.json
Writing schema for PrometheusRule version v1 of group monitoring.coreos.com to /Users/vs/.ytt-lint/schema/k8s/monitoring.coreos.com/v1/prometheusrule.json
Writing schema for Provider version v1alpha3 of group clusterctl.cluster.x-k8s.io to /Users/vs/.ytt-lint/schema/k8s/clusterctl.cluster.x-k8s.io/v1alpha3/provider.json
Writing schema for ServiceMonitor version v1 of group monitoring.coreos.com to /Users/vs/.ytt-lint/schema/k8s/monitoring.coreos.com/v1/servicemonitor.json
Writing schema for UpdateInfo version v1alpha1 of group nodemanagement.gke.io to /Users/vs/.ytt-lint/schema/k8s/nodemanagement.gke.io/v1alpha1/updateinfo.json
Exit code: 0