puppet-vscode icon indicating copy to clipboard operation
puppet-vscode copied to clipboard

Node Graph: "There are no resources created ..." error message

Open rajeshr264 opened this issue 4 years ago • 4 comments

Describe the Bug

When I selected "Puppet Node Graph" in VS Code on my clone of https://github.com/puppetlabs/puppetlabs-ntp/blob/main/manifests/service.pp, I get this error message:

"There were no resources created in the node graph. Is there an include statement missing?"

Expected Behavior

I expect to see resources being recognized and a node graph of the resources drawn.

Steps to Reproduce

Steps to reproduce the behavior:

  1. clone of https://github.com/puppetlabs/puppetlabs-ntp/blob/main/manifests/service.pp
  2. Open VS Code and open the Node Graph
  3. You will see the error message
  4. Try another file: I have tried another file : https://github.com/RARYates/ourapp/blob/master/manifests/init.pp and you will get the same error.

Environment

  • VS Code 1.54.3
  • Platform : Windows 10
  • pdk 2.0.0.0
  • Ruby 2.5.8
  • Puppet 6.17.0

Additional Context

rajeshr264 avatar Mar 26 '21 01:03 rajeshr264

@rajeshr264 The (admittingly minimal) error message is pointing you to the problem. Both of the example files don't include the class you're trying to graph. You will need to add a temporary include <NAME> in the manifest, then run Open Node Graph for it to parse successfully.

jpogran avatar Mar 29 '21 14:03 jpogran

@rajeshr264 think about it this way. If you wrote a bash script like this, what would it do when you ran it?

#! /bin/bash

function do_a_thing {
    echo "did a thing"
}

It would do nothing, because it just defines a function and never invokes it. Same thing with a Puppet class. Unless you declare it, it doesn't add anything to the catalog.

binford2k avatar Mar 30 '21 15:03 binford2k

ah ok. user needs to "instantiate" the class into the catalog. I thought there was an embedded parser inside the puppet-plugin, that creates the graph on the fly.

The error message was not useful as I have other 'include' statements in my example so got confused.

In the README for the Node Graph in VS Code feature, can we add: "The class that needs to be instantiated in the catalog by creating a temporary 'include <NAME>' in the manifest and then running 'Open Node Graph'. "?

rajeshr264 avatar Mar 30 '21 15:03 rajeshr264

ah ok. user needs to "instantiate" the class into the catalog. I thought there was an embedded parser inside the puppet-plugin, that creates the graph on the fly.

The parser absolutely parses the code. But like the bash script I showed, parsing the code results in an empty catalog since you don't do anything with the class that you define.

The manifests in the examples directory are what does something with the class.

binford2k avatar Mar 30 '21 16:03 binford2k