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

(maint) Allow setting of abs subdomain #189

Merged

Conversation

jpartlow
Copy link
Contributor

The provision::abs task was hardcoded to
abs-prod.k8s.infracore.puppet.net. This made it impossible to use the
task to test a new vm available from abs-stage.k8s.infracore.puppet.net
prior to making it live in abs-prod.

Since the allowed parameters for the task tie into the api expected by
Litmus, I added another environment variable here to allow selection of
the subdomain. I didn't allow selection of the entire fqdn because
having your vm source change entirely based on a hidden env variable
seemed dubious to me.


This is based on top of #186 for test coverage. We could either merge this and close that, or merge that and I'll rebase this...

@jpartlow jpartlow requested a review from a team as a code owner February 10, 2022 23:41
@codecov-commenter
Copy link

codecov-commenter commented Feb 10, 2022

Codecov Report

❗ No coverage uploaded for pull request base (main@183fefe). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #189   +/-   ##
=======================================
  Coverage        ?   77.46%           
=======================================
  Files           ?        2           
  Lines           ?      142           
  Branches        ?        0           
=======================================
  Hits            ?      110           
  Misses          ?       32           
  Partials        ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 183fefe...6ecac5b. Read the comment docs.

@jpartlow jpartlow force-pushed the maint-allow-setting-of-abs-subdomain branch from b3b5f83 to 6ecac5b Compare February 10, 2022 23:47
@jpartlow
Copy link
Contributor Author

Need to fix the spec for ruby 2.5, and finish some manual bolt task runs.

@jpartlow jpartlow force-pushed the maint-allow-setting-of-abs-subdomain branch from 6ecac5b to 74400b0 Compare February 11, 2022 00:14
@jpartlow
Copy link
Contributor Author

Provisioning and tearing down relying on default abs-prod:

jpartlow@jpartlow-dev:~/work/src/provision$ be bolt task --modulepath spec/fixtures/modules run provision::abs --targets localhost action=provision platform=redhat-8.4-kurl-beta-x86_64 inventory=/tmp
Bolt might be installed as a gem. To use Bolt reliably and with all of its
dependencies, uninstall the 'bolt' gem and install Bolt as a package:
https://puppet.com/docs/bolt/latest/bolt_installing.html

If you meant to install Bolt as a gem and want to disable this warning,
set the BOLT_GEM environment variable. [ID: gem_install]
Started on localhost...
Finished on localhost:
  {
    "status": "ok",
    "nodes": 1
  }
Successful on 1 target: localhost
Ran on 1 target in 47.75 sec
jpartlow@jpartlow-dev:~/work/src/provision$ cat /tmp/spec/fixtures/litmus_inventory.yaml
---
version: 2
groups:
- name: docker_nodes
  targets: []
- name: ssh_nodes
  targets:
  - uri: iron-maple.delivery.puppetlabs.net
    config:
      transport: ssh
      ssh:
        user:
        host-key-check: false
        password:
    facts:
      provisioner: abs
      platform: redhat-8.4-kurl-beta-x86_64
      job_id: iac-task-pid-31090-1644538809054
- name: winrm_nodes
  targets: []
jpartlow@jpartlow-dev:~/work/src/provision$ floaty list --active --service abs
Your VMs on abs-prod.k8s.infracore.puppet.net:
- [JobID:iac-task-pid-31090-1644538809054] <allocated>
  - iron-maple.delivery.puppetlabs.net (redhat-8.4-kurl-beta-x86_64)
jpartlow@jpartlow-dev:~/work/src/provision$ be bolt task --modulepath spec/fixtures/modules run provision::abs --targets localhost action=tear_down node_name=iron-maple.delivery.puppetlabs.net inventory=/tmp
Bolt might be installed as a gem. To use Bolt reliably and with all of its
dependencies, uninstall the 'bolt' gem and install Bolt as a package:
https://puppet.com/docs/bolt/latest/bolt_installing.html

If you meant to install Bolt as a gem and want to disable this warning,
set the BOLT_GEM environment variable. [ID: gem_install]
Started on localhost...
Finished on localhost:
  {
    "status": "ok",
    "removed": [
      "iron-maple.delivery.puppetlabs.net"
    ]
  }
Successful on 1 target: localhost
Ran on 1 target in 1.53 sec
jpartlow@jpartlow-dev:~/work/src/provision$ floaty list --active --service abs
You have no running VMs on abs-prod.k8s.infracore.puppet.net

Switching ABS_SUBDOMAIN to abs_stage and provisioning and tearing down (after switching out the .fog token to match, and removing the /tmp/spec/fixtures/litmus_inventory.yaml...):

jpartlow@jpartlow-dev:~/work/src/provision$ export ABS_SUBDOMAIN=abs-stage
jpartlow@jpartlow-dev:~/work/src/provision$ be bolt task --modulepath spec/fixtures/modules run provision::abs --targets localhost action=provision platform=redhat-8.4-kurl-beta-x86_64 inventory=/tmp
Bolt might be installed as a gem. To use Bolt reliably and with all of its
dependencies, uninstall the 'bolt' gem and install Bolt as a package:
https://puppet.com/docs/bolt/latest/bolt_installing.html

If you meant to install Bolt as a gem and want to disable this warning,
set the BOLT_GEM environment variable. [ID: gem_install]
Started on localhost...
Finished on localhost:
  {
    "status": "ok",
    "nodes": 1
  }
Successful on 1 target: localhost
Ran on 1 target in 46.67 sec
jpartlow@jpartlow-dev:~/work/src/provision$ cat /tmp/spec/fixtures/litmus_inventory.yaml
---
version: 2
groups:
- name: docker_nodes
  targets: []
- name: ssh_nodes
  targets:
  - uri: isotonic-skirt.delivery.puppetlabs.net
    config:
      transport: ssh
      ssh:
        user:
        host-key-check: false
        password:
    facts:
      provisioner: abs
      platform: redhat-8.4-kurl-beta-x86_64
      job_id: iac-task-pid-31569-1644541357375
- name: winrm_nodes
  targets: []
jpartlow@jpartlow-dev:~/work/src/provision$ floaty list --active --service abs-stage
Your VMs on abs-stage.k8s.infracore.puppet.net:
- [JobID:iac-task-pid-31569-1644541357375] <allocated>
  - isotonic-skirt.delivery.puppetlabs.net (redhat-8.4-kurl-beta-x86_64)
jpartlow@jpartlow-dev:~/work/src/provision$ be bolt task --modulepath spec/fixtures/modules run provision::abs --targets localhost action=tear_down node_name=isotonic-skirt.delivery.puppetlabs.net inventory=/tmp

Bolt might be installed as a gem. To use Bolt reliably and with all of its
dependencies, uninstall the 'bolt' gem and install Bolt as a package:
https://puppet.com/docs/bolt/latest/bolt_installing.html

If you meant to install Bolt as a gem and want to disable this warning,
set the BOLT_GEM environment variable. [ID: gem_install]
Started on localhost...
Finished on localhost:
  {
    "status": "ok",
    "removed": [
      "isotonic-skirt.delivery.puppetlabs.net"
    ]
  }
Successful on 1 target: localhost
Ran on 1 target in 1.29 sec
jpartlow@jpartlow-dev:~/work/src/provision$ floaty list --active --service abs-stage
You have no running VMs on abs-stage.k8s.infracore.puppet.net

@chelnak
Copy link
Contributor

chelnak commented Feb 11, 2022

@jpartlow I've approved the other two 🙂

Please could you merge and rebase this PR, then i'll approve.

The abs.rb is refactored into a class that is executed only if the task
file is the executing program. This allows the spec to load the task and
manipulate the class while mocking externals. The webmock gem is used to
provide HTTP::Net mocking.

The spec is not exhaustive, but hopefully covers enough to validate that
the refactor didn't break the task, and that the bug I added in puppetlabs#182 is
patched.

It could be expanded, and could serve as a template for adding specs
for other tasks in the module.

It does look to expose an edge case bug of calling the provision task
with an inventory directory specified that contains a pre-existing
inventory file.
The provision::abs task was hardcoded to
abs-prod.k8s.infracore.puppet.net. This made it impossible to use the
task to test a new vm available from abs-stage.k8s.infracore.puppet.net
prior to making it live in abs-prod.

Since the allowed parameters for the task tie into the api expected by
Litmus, I added another environment variable here to allow selection of
the subdomain. I didn't allow selection of the entire fqdn because
having your vm source change entirely based on a hidden env variable
seemed dubious to me.
Later versions require Ruby 3. This looks to be a
github_changelog_generator dependency.

There may be a better solution here? Possibly dropping
github_changelog_generator?
@jpartlow jpartlow force-pushed the maint-allow-setting-of-abs-subdomain branch from 74400b0 to 119a5f4 Compare February 11, 2022 17:59
@jpartlow jpartlow merged commit 45b1290 into puppetlabs:main Feb 11, 2022
@jpartlow jpartlow deleted the maint-allow-setting-of-abs-subdomain branch February 11, 2022 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants