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

show unused environments #140

Closed
rwaffen opened this issue Feb 8, 2023 · 4 comments · Fixed by #146
Closed

show unused environments #140

rwaffen opened this issue Feb 8, 2023 · 4 comments · Fixed by #146
Labels
enhancement New feature or request

Comments

@rwaffen
Copy link
Member

rwaffen commented Feb 8, 2023

get all environments from puppetdb even if no node is running against it

@tuxmea
Copy link
Member

tuxmea commented Feb 23, 2023

Show unused envs

The actual state of HDM works as follows:
HDM reads from PuppetDB which environments are in use (by at least one node which did a complete puppet agent run).
Only after a complete Puppet agent run, the PuppetDB has all data for that node (environment, facts, reports).
Once we select an environment, we read the nodes facts which use the selected environment.

Now we want to also show unused Puppet environments.
Unused environments are located on the filesystem, but don't show up in PuppetDB.
Within HDM we should mark the unused environment (e.g. by prefixing the string 'unused')
When selecting an unused environment, we want the user to select ANY node from the node list.
On unused environments no data changes should be possible (read-only mode).

2nd use case:

Which hiera data does the node retrieve if the node switches its environment?

Solution:

As we want to achieve different results for different use cases we came up with the following proposal:

  1. Environments:
  • read all environments from file system
  • read environments from PuppetDB
  • mark unused environments
  1. Nodes
  • we need a toogle switch which defaults to "show nodes from env only" and which can be set to "all nodes"
  • Node list then shows nodes depending on toggle.

API endpoints to use: https://www.puppet.com/docs/puppetdb/7/api/query/v4/nodes.html#pdbqueryv4nodesnodefacts

@oneiros
Copy link
Collaborator

oneiros commented Mar 22, 2023

I am currently struggling with our test data here as we reuse node names between environments. So just to confirm: In an actual production environment a node can only belong to one environment, correct?

@oneiros
Copy link
Collaborator

oneiros commented Mar 22, 2023

I am currently struggling with our test data here as we reuse node names between environments. So just to confirm: In an actual production environment a node can only belong to one environment, correct?

The trouble with the test data goes even deeper than I feared. With this change, we would need to query for a node's facts without specifying an environment. We already talked about how that is possible. But in our test data we have node facts in yaml files per environment. This would make it impossible (or at least ugly) to access the correct node data in tests.

I would proprose that we move out the node fact yaml files from the individual environments and into a single folder, e.g. test/fixtures/files/puppet/nodes/.

Each file should contain the current environment of the node. This means we will no longer have all nodes in all environments that they were previously in. I would try to see which ones are actually used in tests and thus important to be in a specific environment and try to divide the remaining ones up equally between those environments where it makes sense to have many nodes.

@tuxmea, since you created most of this test data, do you see any problem with this approach?

oneiros added a commit that referenced this issue Mar 23, 2023
In addition to environments from puppetdb, hdm will now
also query the file system and distinguish between
environments that are in use (i.e. known by puppetdb) and
unused (only present in the file system).
oneiros added a commit that referenced this issue Mar 23, 2023
This includes a huge shuffling around of test data as
node names can no longer be reused in different
environments.

Also includes an update to the vendored slim-select
js library.
@oneiros
Copy link
Collaborator

oneiros commented Mar 23, 2023

I believe my assumption above is OK, so I went ahead and moved test data around a lot, but with a different approach as outlined above: I put all existing nodes in the development environment, created 25 new nodes in all other environments that had the full set formerly and 5 nodes in the one case where it only had a handfull before.

Tests work fine so far, so I created #146.

@oneiros oneiros removed their assignment Mar 23, 2023
tuxmea pushed a commit that referenced this issue Mar 23, 2023
…ts (#146)

* Consider unused environments #140

In addition to environments from puppetdb, hdm will now
also query the file system and distinguish between
environments that are in use (i.e. known by puppetdb) and
unused (only present in the file system).

* Allow selection of nodes from different env #140

This includes a huge shuffling around of test data as
node names can no longer be reused in different
environments.

Also includes an update to the vendored slim-select
js library.

* Fix bug introduced by blindly trusting rubocop #140
@rwaffen rwaffen added the enhancement New feature or request label Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants