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

fails #4

Closed
yashbhutwala opened this issue Aug 25, 2020 · 7 comments
Closed

fails #4

yashbhutwala opened this issue Aug 25, 2020 · 7 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@yashbhutwala
Copy link

kubectl graph all -o cypher | cypher-shell -u neo4j -p secret

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x1da90d8]

goroutine 1 [running]:
k8s.io/api/core/v1.(*ObjectReference).GroupVersionKind(...)
        /home/runner/go/pkg/mod/k8s.io/[email protected]/core/v1/objectreference.go:30
github.com/steveteuber/kubectl-graph/pkg/graph.(*CoreV1Graph).Endpoints(0xc00064c0f8, 0xc0000e0640, 0xc0000a8010, 0xc000450414, 0xa)
        /home/runner/work/kubectl-graph/kubectl-graph/pkg/graph/core.go:160 +0x278
github.com/steveteuber/kubectl-graph/pkg/graph.(*CoreV1Graph).ServiceTypeClusterIP(0xc00064c0f8, 0xc0002d6900, 0x2126000, 0x1, 0xc0002d6900)
        /home/runner/work/kubectl-graph/kubectl-graph/pkg/graph/core.go:199 +0x1f0
github.com/steveteuber/kubectl-graph/pkg/graph.(*CoreV1Graph).Service(0xc00064c0f8, 0xc0002d6900, 0xc0002d6900, 0x0, 0x0)
        /home/runner/work/kubectl-graph/kubectl-graph/pkg/graph/core.go:178 +0x7d
github.com/steveteuber/kubectl-graph/pkg/graph.(*CoreV1Graph).Unstructured(0xc00064c0f8, 0xc0005d6018, 0x1, 0x1)
        /home/runner/work/kubectl-graph/kubectl-graph/pkg/graph/core.go:64 +0x275
github.com/steveteuber/kubectl-graph/pkg/graph.(*Graph).Unstructured(0xc000721830, 0xc0005d6018, 0x3783308, 0xc00036c0a0)
        /home/runner/work/kubectl-graph/kubectl-graph/pkg/graph/graph.go:200 +0x152
github.com/steveteuber/kubectl-graph/pkg/graph.NewGraph(0xc0000d8420, 0xc00064c0f0, 0x1, 0x1, 0x0, 0x0, 0x0)
        /home/runner/work/kubectl-graph/kubectl-graph/pkg/graph/graph.go:185 +0x157
github.com/steveteuber/kubectl-graph/pkg/cmd.(*GraphOptions).Run(0xc00031a8f0, 0x23d2ae0, 0xc0004bd6b0, 0xc0000e2dc0, 0xc0004bd8c0, 0x1, 0x3, 0x0, 0x0)
        /home/runner/work/kubectl-graph/kubectl-graph/pkg/cmd/cmd.go:164 +0x2cc
github.com/steveteuber/kubectl-graph/pkg/cmd.NewCmdGraph.func1(0xc0000e2dc0, 0xc0004bd8c0, 0x1, 0x3)
        /home/runner/work/kubectl-graph/kubectl-graph/pkg/cmd/cmd.go:80 +0x159
github.com/spf13/cobra.(*Command).execute(0xc0000e2dc0, 0xc0000a6050, 0x3, 0x3, 0xc0000e2dc0, 0xc0000a6050)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:846 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000e2dc0, 0x7, 0xc000142580, 0x238bce0)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:950 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:887
main.main()
        /home/runner/work/kubectl-graph/kubectl-graph/cmd/kubectl-graph/main.go:15 +0xda
Unable to connect to localhost:7687, ensure the database is running and that there is a working network connection to it.

Can you please add documentation if there is additional steps for running this plugin?

@steveteuber
Copy link
Owner

Hey @yashbhutwala,

Thank you for opening this issue. It seems like you have created a Service without a selector and added an Endpoint object manually. I have not tested that particular use case, but I will take a look into it and yes the documentation needs to be improved!

@steveteuber steveteuber added bug Something isn't working documentation Improvements or additions to documentation labels Aug 26, 2020
@steveteuber steveteuber reopened this Aug 26, 2020
@steveteuber
Copy link
Owner

Hey @yashbhutwala,

I have updated the documentation with a usage example.
Tomorrow i'll fix the panic: runtime error: invalid memory address or nil pointer dereference.

@steveteuber
Copy link
Owner

I think this issue should be fixed now. Please upgrade the plugin to a newer version:

$ kubectl krew upgrade graph
Updated the local copy of plugin index.
  Upgrades available for installed plugins:
    * graph v0.1.0 -> v0.1.1
Upgrading plugin: graph
Upgraded plugin: graph

@steveteuber
Copy link
Owner

@yashbhutwala?

@yashbhutwala
Copy link
Author

failure no longer happens, but the docs are still not clear to me to make use of this tool. I spun up the neo4j container and I ran kubectl graph all -n kube-system -o cypher | cypher-shell.. now what? I don't see a graph in the neo4j ui...

I do see data when I don't pipe it to cypher-shell

// create nodes
:begin
MERGE (node:Cluster {UID: "cluster_127.0.0.1"}) ON CREATE SET node.Name = "127.0.0.1";
MERGE (node:Namespace {UID: "namespace_kube-system"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Name = "kube-system";
MERGE (node:Endpoints {UID: "0ec3f2ac-a94d-48f3-b228-a1afe028b6a6"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "kube-dns";
MERGE (node:Pod {UID: "11bfbae5-eeef-4da1-b825-ebb2a946e54b"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "kube-scheduler-kind-control-plane";
MERGE (node:Container {UID: "2bb1b09b-967c-115e-157f-195b0c65d612"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "kindnet-cni";
MERGE (node:Container {UID: "3d436918-a4dd-a347-a59e-4a51440fa421"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "coredns";
MERGE (node:Pod {UID: "4458d1a1-4914-4f8e-9100-a6eae77d34f4"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "coredns-5d4dd4b4db-vdfjn";
MERGE (node:Pod {UID: "4df6a9ef-fffa-4ec1-965d-cfc7117d79be"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "etcd-kind-control-plane";
MERGE (node:Pod {UID: "5728b70d-b9d5-4c93-b8c7-3ca5389a9d4f"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "coredns-5d4dd4b4db-n57hm";
MERGE (node:Deployment {UID: "5844277c-d6ab-4e2f-b268-ef4500e22755"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "coredns";
MERGE (node:DaemonSet {UID: "5d02bba5-69c3-42f2-af32-c8de05d9676a"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "kindnet";
MERGE (node:Container {UID: "5f67823b-6d92-caf9-2ffe-418ad7031971"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "kube-scheduler";
MERGE (node:Pod {UID: "6d4a5bc6-d053-4a7f-bcdd-4277c7a9a89f"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "kube-apiserver-kind-control-plane";
MERGE (node:Container {UID: "6ff73eeb-71a7-11e5-c790-5e6991e35a4e"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "kube-proxy";
MERGE (node:Container {UID: "7d807607-03ed-b50e-da60-3d122d456334"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "kube-apiserver";
MERGE (node:Container {UID: "7d9c5b9f-161a-74a1-9e78-15d503f221ab"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "etcd";
MERGE (node:Pod {UID: "883d0094-4d70-44e5-9bc1-c029be48d1c1"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "kube-proxy-mt4gh";
MERGE (node:DaemonSet {UID: "89f096b0-2d51-4fde-87d3-5c45bcd48cac"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "kube-proxy";
MERGE (node:Pod {UID: "8b44f716-80db-4f26-a531-e914a8cfd1d5"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "kube-controller-manager-kind-control-plane";
MERGE (node:Container {UID: "91aa60ce-e2a2-0d4e-ca6f-8faa2605e3d3"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "coredns";
MERGE (node:Container {UID: "bc63ed66-931a-d006-21bf-67c4ca5e9fb9"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "kube-controller-manager";
MERGE (node:Service {UID: "d357fc06-76c6-4033-9f97-62344224890a"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "kube-dns";
MERGE (node:Pod {UID: "e57a1308-424c-470c-a1f0-30be62431043"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "kindnet-dszss";
MERGE (node:ReplicaSet {UID: "f18e0947-02a1-4a7d-801f-4d8623f0f078"}) ON CREATE SET node.ClusterName = "127.0.0.1", node.Namespace = "kube-system", node.Name = "coredns-5d4dd4b4db";
:commit

// wait for index completion
call db.awaitIndexes();

// create relationships
:begin
MATCH (from:Endpoints),(to:Pod) WHERE from.UID = "0ec3f2ac-a94d-48f3-b228-a1afe028b6a6" AND to.UID = "4458d1a1-4914-4f8e-9100-a6eae77d34f4" MERGE (from)-[:Pod]->(to);
MATCH (from:Endpoints),(to:Pod) WHERE from.UID = "0ec3f2ac-a94d-48f3-b228-a1afe028b6a6" AND to.UID = "5728b70d-b9d5-4c93-b8c7-3ca5389a9d4f" MERGE (from)-[:Pod]->(to);
MATCH (from:Pod),(to:Container) WHERE from.UID = "11bfbae5-eeef-4da1-b825-ebb2a946e54b" AND to.UID = "5f67823b-6d92-caf9-2ffe-418ad7031971" MERGE (from)-[:Container]->(to);
MATCH (from:Pod),(to:Container) WHERE from.UID = "4458d1a1-4914-4f8e-9100-a6eae77d34f4" AND to.UID = "3d436918-a4dd-a347-a59e-4a51440fa421" MERGE (from)-[:Container]->(to);
MATCH (from:Pod),(to:Container) WHERE from.UID = "4df6a9ef-fffa-4ec1-965d-cfc7117d79be" AND to.UID = "7d9c5b9f-161a-74a1-9e78-15d503f221ab" MERGE (from)-[:Container]->(to);
MATCH (from:Pod),(to:Container) WHERE from.UID = "5728b70d-b9d5-4c93-b8c7-3ca5389a9d4f" AND to.UID = "91aa60ce-e2a2-0d4e-ca6f-8faa2605e3d3" MERGE (from)-[:Container]->(to);
MATCH (from:Deployment),(to:ReplicaSet) WHERE from.UID = "5844277c-d6ab-4e2f-b268-ef4500e22755" AND to.UID = "f18e0947-02a1-4a7d-801f-4d8623f0f078" MERGE (from)-[:ReplicaSet]->(to);
MATCH (from:DaemonSet),(to:Pod) WHERE from.UID = "5d02bba5-69c3-42f2-af32-c8de05d9676a" AND to.UID = "e57a1308-424c-470c-a1f0-30be62431043" MERGE (from)-[:Pod]->(to);
MATCH (from:Pod),(to:Container) WHERE from.UID = "6d4a5bc6-d053-4a7f-bcdd-4277c7a9a89f" AND to.UID = "7d807607-03ed-b50e-da60-3d122d456334" MERGE (from)-[:Container]->(to);
MATCH (from:Pod),(to:Container) WHERE from.UID = "883d0094-4d70-44e5-9bc1-c029be48d1c1" AND to.UID = "6ff73eeb-71a7-11e5-c790-5e6991e35a4e" MERGE (from)-[:Container]->(to);
MATCH (from:DaemonSet),(to:Pod) WHERE from.UID = "89f096b0-2d51-4fde-87d3-5c45bcd48cac" AND to.UID = "883d0094-4d70-44e5-9bc1-c029be48d1c1" MERGE (from)-[:Pod]->(to);
MATCH (from:Pod),(to:Container) WHERE from.UID = "8b44f716-80db-4f26-a531-e914a8cfd1d5" AND to.UID = "bc63ed66-931a-d006-21bf-67c4ca5e9fb9" MERGE (from)-[:Container]->(to);
MATCH (from:Service),(to:Endpoints) WHERE from.UID = "d357fc06-76c6-4033-9f97-62344224890a" AND to.UID = "0ec3f2ac-a94d-48f3-b228-a1afe028b6a6" MERGE (from)-[:Endpoints]->(to);
MATCH (from:Pod),(to:Container) WHERE from.UID = "e57a1308-424c-470c-a1f0-30be62431043" AND to.UID = "2bb1b09b-967c-115e-157f-195b0c65d612" MERGE (from)-[:Container]->(to);
MATCH (from:ReplicaSet),(to:Pod) WHERE from.UID = "f18e0947-02a1-4a7d-801f-4d8623f0f078" AND to.UID = "5728b70d-b9d5-4c93-b8c7-3ca5389a9d4f" MERGE (from)-[:Pod]->(to);
MATCH (from:ReplicaSet),(to:Pod) WHERE from.UID = "f18e0947-02a1-4a7d-801f-4d8623f0f078" AND to.UID = "4458d1a1-4914-4f8e-9100-a6eae77d34f4" MERGE (from)-[:Pod]->(to);
MATCH (cl:Cluster) WHERE cl.UID = "cluster_127.0.0.1" MATCH (node) WHERE node.ClusterName = cl.Name AND node.Namespace IS NULL AND NOT(()-[]->(node)) MERGE (node)-[:Cluster]->(cl);
MATCH (ns:Namespace) WHERE ns.UID = "namespace_kube-system" MATCH (node) WHERE node.Namespace = ns.Name AND NOT(()-[]->(node)) MERGE (node)-[:Namespace]->(ns);
:commit

Can you please make documentation even more clear please?

@yashbhutwala
Copy link
Author

OK I see the results now. 2 things:

  1. can you improve docs on how to explore within neo4j? as a total noob to neo4j, it was kinda difficult for me.
  2. can you add proper logging in your tool for failures, success, and long running processes? since it takes a while to run and there is no log, it's easy to assume something's wrong or the program is hung...

@steveteuber
Copy link
Owner

Thanks for your feedback, I will improve these things!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants