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

Add get_peadm_config task #187

Merged
merged 5 commits into from
Jul 20, 2021
Merged

Add get_peadm_config task #187

merged 5 commits into from
Jul 20, 2021

Conversation

reidmv
Copy link
Contributor

@reidmv reidmv commented Jul 20, 2021

This task can introspect an existing cluster (when run on a primary node) and return information about how the cluster is currently configured. In the future, this can be used to aid in running plans that need to modify the cluster, by reducing the amount of information the user must supply. For example, the add_compiler plan, or (future) add_postgresql.

The task returns data about the cluster in both primary/replica form, as well as A/B form, since different forms are useful in different scenarios.

@reidmv reidmv requested a review from a team as a code owner July 20, 2021 02:07
@reidmv reidmv force-pushed the get-peadm-config branch from 7222e7d to 0ba1e65 Compare July 20, 2021 02:08
@reidmv reidmv changed the title Add get_cluster_roles task Add get_peadm_config task Jul 20, 2021
@timidri
Copy link
Contributor

timidri commented Jul 20, 2021

@reidmv Can you comment on what's the easiest workflow to test this?
I've tried:

bolt task run peadm::get_peadm_config -t pe-server-fcb0a2-0.us-west1-a.c.puppet-solutions-architects.internal

but get

Failed on pe-server-fcb0a2-0.us-west1-a.c.puppet-solutions-architects.internal:
  Failed to connect to pe-server-fcb0a2-0.us-west1-a.c.puppet-solutions-architects.internal: getaddrinfo: nodename nor servname provided, or not known
Failed on 1 target: pe-server-fcb0a2-0.us-west1-a.c.puppet-solutions-architects.internal
Ran on 1 target in 0.79 sec

as expected.

Also, it's still unclear to me how to quickly bootstrap an environment for bolt to find peadm's tasks. I end up creating /tmp/modules and symlinking the module into that.

@davidsandilands
Copy link
Contributor

davidsandilands commented Jul 20, 2021

david.sandilands@Davids-MacBook-Pro reidtest % bolt task run peadm::get_peadm_config --target pe-server-davidsandprod-0-a6aed9.westus2.cloudapp.azure.com --modulepath /Users/david.sandilands/reidtest/ --inventoryfile /Users/david.sandilands/autope/invetory.yaml   
Started on pe-server-davidsandprod-0-a6aed9.westus2.cloudapp.azure.com...
Failed on pe-server-davidsandprod-0-a6aed9.westus2.cloudapp.azure.com:
  The task failed with exit code 1 and no stdout, but stderr contained:
  /tmp/8c271d54-3661-4590-8473-aec07f3890dd/get_peadm_config.rb:110:in `dig': undefined method `dig' for nil:NilClass (NoMethodError)
  	from /tmp/8c271d54-3661-4590-8473-aec07f3890dd/get_peadm_config.rb:116:in `pinned'
  	from /tmp/8c271d54-3661-4590-8473-aec07f3890dd/get_peadm_config.rb:20:in `config'
  	from /tmp/8c271d54-3661-4590-8473-aec07f3890dd/get_peadm_config.rb:14:in `execute!'
  	from /tmp/8c271d54-3661-4590-8473-aec07f3890dd/get_peadm_config.rb:134:in `<main>'
Failed on 1 target: pe-server-davidsandprod-0-a6aed9.westus2.cloudapp.azure.com
Ran on 1 target in 7.67 sec

@davidsandilands
Copy link
Contributor

davidsandilands commented Jul 20, 2021

@reidmv Can you comment on what's the easiest workflow to test this?
I've tried:

bolt task run peadm::get_peadm_config -t pe-server-fcb0a2-0.us-west1-a.c.puppet-solutions-architects.internal

but get

Failed on pe-server-fcb0a2-0.us-west1-a.c.puppet-solutions-architects.internal:
  Failed to connect to pe-server-fcb0a2-0.us-west1-a.c.puppet-solutions-architects.internal: getaddrinfo: nodename nor servname provided, or not known
Failed on 1 target: pe-server-fcb0a2-0.us-west1-a.c.puppet-solutions-architects.internal
Ran on 1 target in 0.79 sec

as expected.

Also, it's still unclear to me how to quickly bootstrap an environment for bolt to find peadm's tasks. I end up creating /tmp/modules and symlinking the module into that.

@timidri i always do it a bit of a dirty way to hack it together and drop the module in a directory (ensuring its named to only module name and not author-module) and then create a inventory like

targets:
  - uri: pe-server-davidsandprod-0-a6aed9.westus2.cloudapp.azure.com
    config:
      ssh:
        user: centos
        run-as: root
  - uri: pe-server-davidsanddr-0-942534.westus2.cloudapp.azure.com
    config:
      ssh:
        user: centos
        run-as: root

Then something like

bolt task run peadm::get_peadm_config --target pe-server-davidsandprod-0-a6aed9.westus2.cloudapp.azure.com --modulepath /Users/david.sandilands/reidtest/ --inventoryfile /Users/david.sandilands/autope/invetory.yaml 

works although i think a bolt project file is the correct way to do this

@davidsandilands
Copy link
Contributor

davidsandilands commented Jul 20, 2021

@reidmv thats cleaner although not sure on whats happening with internal compiler address, PROD is large server no compilers no replica, DR is large server 2 compilers no replica.

david.sandilands@Davids-MacBook-Pro peadm % bolt task run peadm::get_peadm_config --target pe-server-davidsandprod-0-a6aed9.westus2.cloudapp.azure.com --modulepath /Users/david.sandilands/reidtest/ --inventoryfile /Users/david.sandilands/autope/invetory.yaml  
Started on pe-server-davidsandprod-0-a6aed9.westus2.cloudapp.azure.com...
Finished on pe-server-davidsandprod-0-a6aed9.westus2.cloudapp.azure.com:
  {
    "params": {
      "primary_host": "pe-server-davidsandprod-0-a6aed9.34rbjoayqufe3o5b45fyobmxvf.xx.internal.cloudapp.net",
      "replica_host": null,
      "primary_postgresql_host": null,
      "replica_postgresql_host": null,
      "compilers": [
  
      ],
      "compiler_pool_address": "pe-server-davidsandprod-0-a6aed9.westus2.cloudapp.azure.com",
      "internal_compiler_a_pool_address": null,
      "internal_compiler_b_pool_address": null
    },
    "role-letter": {
      "server": {
        "A": "pe-server-davidsandprod-0-a6aed9.34rbjoayqufe3o5b45fyobmxvf.xx.internal.cloudapp.net",
        "B": null
      },
      "postgresql": {
        "A": null,
        "B": null
      }
    }
  }
Successful on 1 target: pe-server-davidsandprod-0-a6aed9.westus2.cloudapp.azure.com
Ran on 1 target in 7.74 sec`
david.sandilands@Davids-MacBook-Pro peadm % bolt task run peadm::get_peadm_config --target pe-server-davidsanddr-0-942534.westus2.cloudapp.azure.com --modulepath /Users/david.sandilands/reidtest/ --inventoryfile /Users/david.sandilands/autope/invetory.yaml  
Started on pe-server-davidsanddr-0-942534.westus2.cloudapp.azure.com...
Finished on pe-server-davidsanddr-0-942534.westus2.cloudapp.azure.com:
  {
    "params": {
      "primary_host": "pe-server-davidsanddr-0-942534.tak2wxsm5y1e1lh3gvdnzfz1fh.xx.internal.cloudapp.net",
      "replica_host": null,
      "primary_postgresql_host": null,
      "replica_postgresql_host": null,
      "compilers": [
        "pe-compiler-davidsanddr-1-942534.tak2wxsm5y1e1lh3gvdnzfz1fh.xx.internal.cloudapp.net",
        "pe-compiler-davidsanddr-0-942534.tak2wxsm5y1e1lh3gvdnzfz1fh.xx.internal.cloudapp.net"
      ],
      "compiler_pool_address": "pe-compiler-lb-davidsanddr-942534.westus2.cloudapp.azure.com",
      "internal_compiler_a_pool_address": null,
      "internal_compiler_b_pool_address": null
    },
    "role-letter": {
      "server": {
        "A": "pe-server-davidsanddr-0-942534.tak2wxsm5y1e1lh3gvdnzfz1fh.xx.internal.cloudapp.net",
        "B": null
      },
      "postgresql": {
        "A": null,
        "B": null
      }
    }
  }
Successful on 1 target: pe-server-davidsanddr-0-942534.westus2.cloudapp.azure.com
Ran on 1 target in 7.79 sec

reidmv added 4 commits July 20, 2021 13:26
This task can introspect an existing cluster (when run on a primary
node) and return information about how the cluster is currently
configured. This will aid in running plans that need to modify the
cluster, by reducing the amount of information the user must supply.

The task returns data about the cluster in both primary/replica form, as
well as A/B form, since different forms are useful in different
scenarios.
Improve the readability of the task, and the task description.
In the event a group doesn't exist, or a key doesn't return a value.
Don't error, just return nil for those values.
When this was refactored, the wrong defaults were given to the compiler
load balancer address variables. They should default to the A and B
*servers*, not the A and B postgresql hosts.
@reidmv
Copy link
Contributor Author

reidmv commented Jul 20, 2021

The internal_compiler_x_pool_address variables are set when compiler pools command-broadcast to at least two PuppetDB servers. When there is no replica, all compilers are "A" compilers, and they each write to only one PuppetDB server: localhost.

The defaults for those settings are... the values of the $postgresql_x_host parameters? This is actually a bug, it should be the values of the $server_x_host parameters. Adding a commit to fix that.

In your stack, since it was probably provisioned before we always created the B groups, there probably just aren't values for any of that, in any group.

@reidmv reidmv requested review from davidsandilands and removed request for a team July 20, 2021 20:29
@reidmv reidmv force-pushed the get-peadm-config branch from 9e5c182 to 07b3126 Compare July 20, 2021 20:30
@reidmv reidmv requested review from davidsandilands and removed request for davidsandilands July 20, 2021 20:31
Realized this could be a generally useful way of understanding all
letter assignments, if we returned compilers as well.
@reidmv
Copy link
Contributor Author

reidmv commented Jul 20, 2021

Install matrix test action completed successfully with the manifests/setup/node_manager.pp changes here. The remainder of the changes are only to new tasks, and have been taken through the paces a few times. A final output sample is given below. Merging PR.

reidmv@reidmv-shellbox:~/project-1$ bolt task run peadm::get_peadm_config -t pe-server-ff2fc0-0.us-west1-a.c.puppet-solutions-architects.internal
Started on pe-server-ff2fc0-0.us-west1-a.c.puppet-solutions-architects.internal...
Finished on pe-server-ff2fc0-0.us-west1-a.c.puppet-solutions-architects.internal:
  {
    "params": {
      "primary_host": "pe-server-ff2fc0-0.us-west1-a.c.puppet-solutions-architects.internal",
      "replica_host": "pe-server-ff2fc0-1.us-west1-b.c.puppet-solutions-architects.internal",
      "primary_postgresql_host": "pe-psql-ff2fc0-0.us-west1-a.c.puppet-solutions-architects.internal",
      "replica_postgresql_host": "pe-psql-ff2fc0-1.us-west1-b.c.puppet-solutions-architects.internal",
      "compilers": [
        "pe-compiler-ff2fc0-0.us-west1-a.c.puppet-solutions-architects.internal",
        "pe-compiler-ff2fc0-1.us-west1-b.c.puppet-solutions-architects.internal"
      ],
      "compiler_pool_address": "puppet.pe-compiler-lb-ff2fc0.il4.us-west1.lb.puppet-solutions-architects.internal",
      "internal_compiler_a_pool_address": "pe-server-ff2fc0-1.us-west1-b.c.puppet-solutions-architects.internal",
      "internal_compiler_b_pool_address": "pe-server-ff2fc0-0.us-west1-a.c.puppet-solutions-architects.internal"
    },
    "role-letter": {
      "server": {
        "A": "pe-server-ff2fc0-0.us-west1-a.c.puppet-solutions-architects.internal",
        "B": "pe-server-ff2fc0-1.us-west1-b.c.puppet-solutions-architects.internal"
      },
      "postgresql": {
        "A": "pe-psql-ff2fc0-0.us-west1-a.c.puppet-solutions-architects.internal",
        "B": "pe-psql-ff2fc0-1.us-west1-b.c.puppet-solutions-architects.internal"
      },
      "compilers": {
        "A": [
          "pe-compiler-ff2fc0-0.us-west1-a.c.puppet-solutions-architects.internal"
        ],
        "B": [
          "pe-compiler-ff2fc0-1.us-west1-b.c.puppet-solutions-architects.internal"
        ]
      }
    }
  }
Successful on 1 target: pe-server-ff2fc0-0.us-west1-a.c.puppet-solutions-architects.internal
Ran on 1 target in 2.45 sec

@reidmv reidmv merged commit c9f86fc into puppetlabs:main Jul 20, 2021
@reidmv reidmv deleted the get-peadm-config branch July 20, 2021 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants