Compare commits

..

No commits in common. "main" and "0.1.1" have entirely different histories.
main ... 0.1.1

22 changed files with 110 additions and 654 deletions

View file

@ -3,11 +3,6 @@ updates:
- package-ecosystem: bundler
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
interval: daily
time: "13:00"
open-pull-requests-limit: 10

View file

@ -1,12 +0,0 @@
name: Automated release prep
on:
workflow_dispatch:
jobs:
auto_release_prep:
uses: puppetlabs/release-engineering-repo-standards/.github/workflows/auto_release_prep.yml@v1
secrets: inherit
with:
project-type: ruby
version-file-path: lib/vmpooler-provider-gce/version.rb

View file

@ -1,8 +0,0 @@
name: Dependabot auto-merge
on: pull_request
jobs:
dependabot_merge:
uses: puppetlabs/release-engineering-repo-standards/.github/workflows/dependabot_merge.yml@v1
secrets: inherit

View file

@ -1,8 +0,0 @@
name: Ensure label
on: pull_request
jobs:
ensure_label:
uses: puppetlabs/release-engineering-repo-standards/.github/workflows/ensure_label.yml@v1
secrets: inherit

View file

@ -1,4 +1,4 @@
name: Release Gem
name: Release
on: workflow_dispatch
@ -7,77 +7,25 @@ jobs:
runs-on: ubuntu-latest
if: github.repository == 'puppetlabs/vmpooler-provider-gce'
steps:
- uses: actions/checkout@v4
- name: Get Current Version
uses: actions/github-script@v7
id: cv
with:
script: |
const { data: response } = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
})
console.log(`The latest release is ${response.tag_name}`)
return response.tag_name
result-encoding: string
- name: Get Next Version
id: nv
- uses: actions/checkout@v2
- name: Get Version
id: gv
run: |
version=$(grep VERSION lib/vmpooler-provider-gce/version.rb |rev |cut -d "'" -f2 |rev)
echo "version=$version" >> $GITHUB_OUTPUT
echo "Found version $version from lib/vmpooler-provider-gce/version.rb"
- name: Generate Changelog
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
with:
args: >-
--future-release ${{ steps.nv.outputs.version }}
env:
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Validate Changelog
run : |
set -e
if [[ -n $(git status --porcelain) ]]; then
echo "Here is the current git status:"
git status
echo
echo "The following changes were detected:"
git --no-pager diff
echo "Uncommitted PRs found in the changelog. Please submit a release prep PR of changes after running `./update-changelog`"
exit 1
fi
- name: Generate Release Notes
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
with:
args: >-
--since-tag ${{ steps.cv.outputs.result }}
--future-release ${{ steps.nv.outputs.version }}
--output release-notes.md
env:
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
echo "::set-output name=ver::$(grep VERSION lib/vmpooler-provider-gce/version.rb |rev |cut -d "'" -f2 |rev)"
- name: Tag Release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.nv.outputs.version }}
tag: ${{ steps.gv.outputs.ver }}
token: ${{ secrets.GITHUB_TOKEN }}
bodyfile: release-notes.md
draft: false
prerelease: false
# This step should closely match what is used in `docker/Dockerfile` in vmpooler-deployment
- name: Install Ruby jruby-9.4.3.0
generateReleaseNotes: true
- name: Install Ruby 2.5.8
uses: ruby/setup-ruby@v1
with:
ruby-version: 'jruby-9.4.3.0'
ruby-version: '2.5.8'
- name: Build gem
run: gem build *.gemspec
- name: Publish gem
run: |
mkdir -p $HOME/.gem

View file

@ -1,39 +0,0 @@
name: Security
on:
workflow_dispatch:
push:
branches:
- main
jobs:
scan:
name: Mend Scanning
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
# setup a package lock if one doesn't exist, otherwise do nothing
- name: check lock
run: '[ -f "Gemfile.lock" ] && echo "package lock file exists, skipping" || bundle lock'
# install java
- uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
# download mend
- name: download_mend
run: curl -o wss-unified-agent.jar https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar
- name: run mend
run: java -jar wss-unified-agent.jar
env:
WS_APIKEY: ${{ secrets.MEND_API_KEY }}
WS_WSS_URL: https://saas-eu.whitesourcesoftware.com/agent
WS_USERKEY: ${{ secrets.MEND_TOKEN }}
WS_PRODUCTNAME: RE
WS_PROJECTNAME: ${{ github.event.repository.name }}

View file

@ -18,9 +18,9 @@ jobs:
strategy:
matrix:
ruby-version:
- 'jruby-9.4.3.0'
- '2.5.8'
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
@ -34,9 +34,10 @@ jobs:
strategy:
matrix:
ruby-version:
- 'jruby-9.4.3.0'
- '2.5.8'
- 'jruby-9.2.12.0'
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:

View file

@ -1,3 +0,0 @@
project=vmpooler-provider-gce
user=puppetlabs
exclude_labels=maintenance

View file

@ -1,110 +0,0 @@
# Changelog
## [1.3.0](https://github.com/puppetlabs/vmpooler-provider-gce/tree/1.3.0) (2023-08-18)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-gce/compare/1.2.0...1.3.0)
**Implemented enhancements:**
- \(POD-10\) Log reason for failed VM checks. [\#33](https://github.com/puppetlabs/vmpooler-provider-gce/pull/33) ([isaac-hammes](https://github.com/isaac-hammes))
## [1.2.0](https://github.com/puppetlabs/vmpooler-provider-gce/tree/1.2.0) (2023-08-10)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-gce/compare/1.1.0...1.2.0)
**Implemented enhancements:**
- Bump jruby to 9.4.3.0 and update lockfile [\#31](https://github.com/puppetlabs/vmpooler-provider-gce/pull/31) ([yachub](https://github.com/yachub))
**Merged pull requests:**
- Bump thor from 1.2.1 to 1.2.2 [\#29](https://github.com/puppetlabs/vmpooler-provider-gce/pull/29) ([dependabot[bot]](https://github.com/apps/dependabot))
## [1.1.0](https://github.com/puppetlabs/vmpooler-provider-gce/tree/1.1.0) (2023-05-01)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-gce/compare/1.0.0...1.1.0)
**Merged pull requests:**
- Migrate issue management to Jira [\#27](https://github.com/puppetlabs/vmpooler-provider-gce/pull/27) ([yachub](https://github.com/yachub))
- Bump jruby to 9.4.2.0 [\#26](https://github.com/puppetlabs/vmpooler-provider-gce/pull/26) ([yachub](https://github.com/yachub))
- Bump rack-test from 2.0.2 to 2.1.0 [\#24](https://github.com/puppetlabs/vmpooler-provider-gce/pull/24) ([dependabot[bot]](https://github.com/apps/dependabot))
- Update googleauth requirement from \>= 0.16.2, \< 1.3.0 to \>= 0.16.2, \< 1.4.0 [\#18](https://github.com/puppetlabs/vmpooler-provider-gce/pull/18) ([dependabot[bot]](https://github.com/apps/dependabot))
## [1.0.0](https://github.com/puppetlabs/vmpooler-provider-gce/tree/1.0.0) (2023-04-19)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-gce/compare/0.5.0...1.0.0)
**Breaking changes:**
- \(RE-15124\) Decouple DNS Record Management into DNS Plugins [\#21](https://github.com/puppetlabs/vmpooler-provider-gce/pull/21) ([yachub](https://github.com/yachub))
## [0.5.0](https://github.com/puppetlabs/vmpooler-provider-gce/tree/0.5.0) (2023-03-06)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-gce/compare/0.4.0...0.5.0)
**Implemented enhancements:**
- \(RE-15161\) Update to jruby-9.4.1.0 and move socket timeout to new method. [\#22](https://github.com/puppetlabs/vmpooler-provider-gce/pull/22) ([isaac-hammes](https://github.com/isaac-hammes))
**Merged pull requests:**
- Add docs and update actions [\#20](https://github.com/puppetlabs/vmpooler-provider-gce/pull/20) ([yachub](https://github.com/yachub))
- \(RE-15111\) Migrate Snyk to Mend Scanning [\#19](https://github.com/puppetlabs/vmpooler-provider-gce/pull/19) ([yachub](https://github.com/yachub))
- \(RE-14811\) Remove DIO as codeowners [\#17](https://github.com/puppetlabs/vmpooler-provider-gce/pull/17) ([yachub](https://github.com/yachub))
- Add Snyk action [\#16](https://github.com/puppetlabs/vmpooler-provider-gce/pull/16) ([yachub](https://github.com/yachub))
- Add release-engineering to codeowners [\#15](https://github.com/puppetlabs/vmpooler-provider-gce/pull/15) ([yachub](https://github.com/yachub))
## [0.4.0](https://github.com/puppetlabs/vmpooler-provider-gce/tree/0.4.0) (2022-07-27)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-gce/compare/0.3.0...0.4.0)
**Merged pull requests:**
- \(maint\) Refactor cloud dns [\#13](https://github.com/puppetlabs/vmpooler-provider-gce/pull/13) ([sbeaulie](https://github.com/sbeaulie))
- Update googleauth requirement from \>= 0.16.2, \< 1.2.0 to \>= 0.16.2, \< 1.3.0 [\#12](https://github.com/puppetlabs/vmpooler-provider-gce/pull/12) ([dependabot[bot]](https://github.com/apps/dependabot))
## [0.3.0](https://github.com/puppetlabs/vmpooler-provider-gce/tree/0.3.0) (2022-06-21)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-gce/compare/0.2.0...0.3.0)
**Merged pull requests:**
- release prep 0.3.0 [\#11](https://github.com/puppetlabs/vmpooler-provider-gce/pull/11) ([sbeaulie](https://github.com/sbeaulie))
- \(DIO-3162\) vmpooler gce provider to support disk type \(to use ssd\) [\#10](https://github.com/puppetlabs/vmpooler-provider-gce/pull/10) ([sbeaulie](https://github.com/sbeaulie))
## [0.2.0](https://github.com/puppetlabs/vmpooler-provider-gce/tree/0.2.0) (2022-04-19)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-gce/compare/0.1.2...0.2.0)
**Implemented enhancements:**
- Set hostname for instance during create\_vm [\#8](https://github.com/puppetlabs/vmpooler-provider-gce/pull/8) ([yachub](https://github.com/yachub))
**Merged pull requests:**
- 0.2.0 release prep [\#9](https://github.com/puppetlabs/vmpooler-provider-gce/pull/9) ([yachub](https://github.com/yachub))
- Update vmpooler requirement from ~\> 1.3, \>= 1.3.0 to \>= 1.3.0, ~\> 2.3 [\#7](https://github.com/puppetlabs/vmpooler-provider-gce/pull/7) ([dependabot[bot]](https://github.com/apps/dependabot))
- Update googleauth requirement from ~\> 0.16.2 to \>= 0.16.2, \< 1.2.0 [\#6](https://github.com/puppetlabs/vmpooler-provider-gce/pull/6) ([dependabot[bot]](https://github.com/apps/dependabot))
## [0.1.2](https://github.com/puppetlabs/vmpooler-provider-gce/tree/0.1.2) (2022-01-10)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-gce/compare/0.1.1...0.1.2)
## [0.1.1](https://github.com/puppetlabs/vmpooler-provider-gce/tree/0.1.1) (2022-01-10)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-gce/compare/0.1.0...0.1.1)
## [0.1.0](https://github.com/puppetlabs/vmpooler-provider-gce/tree/0.1.0) (2022-01-10)
[Full Changelog](https://github.com/puppetlabs/vmpooler-provider-gce/compare/588e29b6e100327336bf0910ae16b6a85ffe279a...0.1.0)
**Merged pull requests:**
- Adding the cloud DNS API library and related methods [\#4](https://github.com/puppetlabs/vmpooler-provider-gce/pull/4) ([sbeaulie](https://github.com/sbeaulie))
- fix simplecov with jruby, add a .rubocop.yml config file [\#3](https://github.com/puppetlabs/vmpooler-provider-gce/pull/3) ([sbeaulie](https://github.com/sbeaulie))
- Add a release workflow for pushing to Rubygems [\#1](https://github.com/puppetlabs/vmpooler-provider-gce/pull/1) ([genebean](https://github.com/genebean))
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*

View file

@ -1,10 +1,10 @@
# This will cause RE to be assigned review of any opened PRs against
# This will cause DIO to be assigned review of any opened PRs against
# the branches containing this file.
# See https://help.github.com/en/articles/about-code-owners for info on how to
# take ownership of parts of the code base that should be reviewed by another
# team.
# RE will be the default owners for everything in the repo.
* @puppetlabs/release-engineering
# DIO will be the default owners for everything in the repo.
* @puppetlabs/dio

View file

@ -1,239 +0,0 @@
PATH
remote: .
specs:
vmpooler-provider-gce (1.3.0)
google-apis-compute_v1 (~> 0.14)
googleauth (>= 0.16.2, < 1.4.0)
vmpooler (~> 3.0)
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
bindata (2.4.15)
builder (3.2.4)
climate_control (1.2.0)
coderay (1.1.3)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
declarative (0.0.20)
deep_merge (1.2.2)
diff-lcs (1.5.0)
docile (1.4.0)
faraday (2.7.10)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
ffi (1.15.5-java)
google-apis-compute_v1 (0.75.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.1)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
webrick
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
googleauth (1.3.0)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
httpclient (2.8.3)
jwt (2.7.1)
memoist (0.16.2)
method_source (1.0.0)
mini_mime (1.1.5)
mock_redis (0.37.0)
multi_json (1.15.0)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
net-ldap (0.18.0)
nio4r (2.5.9)
nio4r (2.5.9-java)
opentelemetry-api (1.2.1)
opentelemetry-common (0.20.0)
opentelemetry-api (~> 1.0)
opentelemetry-exporter-jaeger (0.23.0)
opentelemetry-api (~> 1.1)
opentelemetry-common (~> 0.20)
opentelemetry-sdk (~> 1.2)
opentelemetry-semantic_conventions
thrift
opentelemetry-instrumentation-base (0.22.2)
opentelemetry-api (~> 1.0)
opentelemetry-registry (~> 0.1)
opentelemetry-instrumentation-concurrent_ruby (0.21.1)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-http_client (0.22.2)
opentelemetry-api (~> 1.0)
opentelemetry-common (~> 0.20.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-rack (0.23.4)
opentelemetry-api (~> 1.0)
opentelemetry-common (~> 0.20.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-redis (0.25.3)
opentelemetry-api (~> 1.0)
opentelemetry-common (~> 0.20.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-sinatra (0.23.2)
opentelemetry-api (~> 1.0)
opentelemetry-common (~> 0.20.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-rack (~> 0.21)
opentelemetry-registry (0.3.0)
opentelemetry-api (~> 1.1)
opentelemetry-resource_detectors (0.24.1)
google-cloud-env
opentelemetry-sdk (~> 1.0)
opentelemetry-sdk (1.3.0)
opentelemetry-api (~> 1.1)
opentelemetry-common (~> 0.20)
opentelemetry-registry (~> 0.2)
opentelemetry-semantic_conventions
opentelemetry-semantic_conventions (1.10.0)
opentelemetry-api (~> 1.0)
os (1.1.4)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pickup (0.0.11)
prometheus-client (4.2.1)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry (0.14.2-java)
coderay (~> 1.1)
method_source (~> 1.0)
spoon (~> 0.0)
public_suffix (5.0.3)
puma (6.3.0)
nio4r (~> 2.0)
puma (6.3.0-java)
nio4r (~> 2.0)
racc (1.7.1)
racc (1.7.1-java)
rack (2.2.8)
rack-protection (3.1.0)
rack (~> 2.2, >= 2.2.4)
rack-test (2.1.0)
rack (>= 1.3)
rainbow (3.1.1)
rake (13.0.6)
redis (4.8.1)
regexp_parser (2.8.1)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.2.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.6)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
rubocop (1.1.0)
parallel (~> 1.10)
parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8)
rexml
rubocop-ast (>= 1.0.1)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
signet (0.17.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sinatra (3.1.0)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.1.0)
tilt (~> 2.0)
spicy-proton (2.1.15)
bindata (~> 2.3)
spoon (0.0.6)
ffi
statsd-ruby (1.5.0)
thor (1.2.2)
thrift (0.18.1)
tilt (2.2.0)
trailblazer-option (0.1.2)
uber (0.1.0)
unicode-display_width (1.8.0)
vmpooler (3.2.0)
concurrent-ruby (~> 1.1)
connection_pool (~> 2.2)
deep_merge (~> 1.2)
net-ldap (~> 0.16)
opentelemetry-exporter-jaeger (= 0.23.0)
opentelemetry-instrumentation-concurrent_ruby (= 0.21.1)
opentelemetry-instrumentation-http_client (= 0.22.2)
opentelemetry-instrumentation-redis (= 0.25.3)
opentelemetry-instrumentation-sinatra (= 0.23.2)
opentelemetry-resource_detectors (= 0.24.1)
opentelemetry-sdk (~> 1.3, >= 1.3.0)
pickup (~> 0.0.11)
prometheus-client (>= 2, < 5)
puma (>= 5.0.4, < 7)
rack (>= 2.2, < 4.0)
rake (~> 13.0)
redis (~> 4.1)
sinatra (>= 2, < 4)
spicy-proton (~> 2.1)
statsd-ruby (~> 1.4)
webrick (1.8.1)
yarjuf (2.0.0)
builder
rspec (~> 3)
PLATFORMS
universal-java-1.8
universal-java-11
x86_64-linux
DEPENDENCIES
climate_control (>= 0.2.0)
mock_redis (>= 0.17.0)
pry
rack-test (>= 0.6)
rspec (>= 3.2)
rubocop (~> 1.1.0)
simplecov (>= 0.11.2)
thor (~> 1.0, >= 1.0.1)
vmpooler-provider-gce!
yarjuf (>= 2.0)
BUNDLED WITH
2.4.7

View file

@ -1,15 +1,5 @@
# vmpooler-provider-gce
- [vmpooler-provider-gce](#vmpooler-provider-gce)
- [Usage](#usage)
- [Migrating to v1](#migrating-to-v1)
- [DNS](#dns)
- [Labels](#labels)
- [Pre-requisite](#pre-requisite)
- [Update the Gemfile Lock](#update-the-gemfile-lock)
- [Releasing](#releasing)
- [License](#license)
This is a provider for [VMPooler](https://github.com/puppetlabs/vmpooler) allows using GCE to create instances, disks,
snapshots, or destroy instances for specific pools.
@ -24,42 +14,6 @@ GCE authorization is handled via a service account (or personal account) private
1. GOOGLE_APPLICATION_CREDENTIALS environment variable eg GOOGLE_APPLICATION_CREDENTIALS=/my/home/directory/my_account_key.json
### Migrating to v1
Starting with the v1.x release, management of DNS records has been extracted from this compute provider and implemented as DNS plugins, similar to compute providers. This means each pool configuration should be pointing to a configuration object in `:dns_config` to determine it's method of record management.
For those using DNS management via this provider, the DNS related options should be moved under `:dns_configs:<INSERT_YOUR_OWN_SYMBOL>` with the value for `dns_class`.
For example, the following keys in a v0.x GCE provider config:
```yaml
:providers:
:gce:
domain: vmpooler.example.com
dns_zone_resource_name: vmpooler-example-com
```
Would be moved to:
```yaml
:dns_configs:
:example:
dns_class: gcp-clouddns
project: jake-vmpooler-dev
domain: vmpooler.example.com
zone_name: vmpooler-example-com
```
Then any pools that should have records created via the dns config above should now reference the named dns config in the `dns_plugin` key:
```yaml
:pools:
- name: 'debian-11-x86_64'
dns_plugin: 'example'
```
For complete examples on how to use the GCP DNS plugin see [vmpooler-dns-gcp](https://github.com/puppetlabs/vmpooler-dns-gcp).
### DNS
DNS is integrated via Google's CloudDNS service. To enable, a CloudDNS zone name must be provided in the config (see the example yaml file dns_zone_resource_name)
@ -83,20 +37,6 @@ do not have the pool label, and can be configured to allow a specific list of un
- The service account needs to be given permissions to the project (broad permissions would be compute v1 admin and dns admin). A yaml file is provided that lists the least-privilege permissions needed
- if using DNS, a DNS zone needs to be created in CloudDNS, and configured in the provider's config section with the name of that zone (dns_zone_resource_name). When not specified, the DNS setup and teardown is skipped.
## Update the Gemfile Lock
To update the `Gemfile.lock` run `./update-gemfile-lock`.
Verify, and update if needed, that the docker tag in the script and GitHub action workflows matches what is used in the [vmpooler-deployment Dockerfile](https://github.com/puppetlabs/vmpooler-deployment/blob/main/docker/Dockerfile).
## Releasing
Follow these steps to publish a new GitHub release, and build and push the gem to <https://rubygems.org>.
1. Bump the "VERSION" in `lib/vmpooler-provider-gce/version.rb` appropriately based on changes in `CHANGELOG.md` since the last release.
2. Run `./release-prep` to update `Gemfile.lock` and `CHANGELOG.md`.
3. Commit and push changes to a new branch, then open a pull request against `main` and be sure to add the "maintenance" label.
4. After the pull request is approved and merged, then navigate to Actions --> Release Gem --> run workflow --> Branch: main --> Run workflow.
## License

View file

@ -1,7 +0,0 @@
#!/usr/bin/env bash
# The container tag should closely match what is used in `docker/Dockerfile` in vmpooler-deployment
docker run -it --rm \
-v $(pwd):/app \
jruby:9.4.3.0-jdk11 \
/bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends make git netbase && cd /app && gem install bundler && bundle install --jobs 3; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"'

View file

@ -1,5 +1,5 @@
# frozen_string_literal: true
module VmpoolerProviderGce
VERSION = '1.3.0'
VERSION = '0.1.1'
end

View file

@ -1,10 +1,10 @@
# frozen_string_literal: true
require 'googleauth'
require 'google/apis/compute_v1'
require 'google/cloud/dns'
require 'bigdecimal'
require 'bigdecimal/util'
require 'google/apis/compute_v1'
require 'googleauth'
require 'vmpooler/dns/base'
require 'vmpooler/providers/base'
module Vmpooler
@ -58,6 +58,11 @@ module Vmpooler
end
end
def dns
@dns ||= Google::Cloud::Dns.new(project_id: project)
@dns
end
# main configuration options
def project
provider_config['project']
@ -82,9 +87,12 @@ module Vmpooler
return provider_config['machine_type'] if provider_config['machine_type']
end
def domain(pool_name)
dns_plugin_name = pool_config(pool_name)['dns_plugin']
dns_config(dns_plugin_name)
def domain
provider_config['domain']
end
def dns_zone_resource_name
provider_config['dns_zone_resource_name']
end
# Base methods that are implemented:
@ -173,28 +181,19 @@ module Vmpooler
network: network_name
)
network_interfaces.subnetwork = subnetwork_name(pool_name) if subnetwork_name(pool_name)
init_params = Google::Apis::ComputeV1::AttachedDiskInitializeParams.new(
init_params = {
source_image: pool['template'], # The source image to create this disk.
labels: { 'vm' => new_vmname, 'pool' => pool_name },
disk_name: "#{new_vmname}-disk0"
)
# rubocop:disable Style/IfUnlessModifier
if pool['disk_type'] && !pool['disk_type'].empty?
init_params.disk_type = "https://www.googleapis.com/compute/v1/projects/#{project}/zones/#{zone(pool_name)}/diskTypes/#{pool['disk_type']}"
end
# rubocop:enable Style/IfUnlessModifier
}
disk = Google::Apis::ComputeV1::AttachedDisk.new(
auto_delete: true,
boot: true,
initialize_params: init_params
initialize_params: Google::Apis::ComputeV1::AttachedDiskInitializeParams.new(init_params)
)
append_domain = domain(pool_name)
fqdn = "#{new_vmname}.#{append_domain}" if append_domain
# Assume all pool config is valid i.e. not missing
client = ::Google::Apis::ComputeV1::Instance.new(
name: new_vmname,
hostname: fqdn,
machine_type: pool['machine_type'],
disks: [disk],
network_interfaces: [network_interfaces],
@ -205,12 +204,9 @@ module Vmpooler
debug_logger('trigger insert_instance')
result = connection.insert_instance(project, zone(pool_name), client)
wait_for_operation(project, pool_name, result)
get_vm(pool_name, new_vmname)
end
def get_vm_ip_address(vm_name, pool_name)
vm_object = get_vm(pool_name, vm_name)
vm_object['ip']
created_instance = get_vm(pool_name, new_vmname)
dns_setup(created_instance)
created_instance
end
# create_disk creates an additional disk for an existing VM. It will name the new
@ -424,8 +420,10 @@ module Vmpooler
unless deleted
debug_logger("trigger delete_instance #{vm_name}")
vm_hash = get_vm(pool_name, vm_name)
result = connection.delete_instance(project, zone(pool_name), vm_name)
wait_for_operation(project, pool_name, result, 10)
dns_teardown(vm_hash)
end
# list and delete any leftover disk, for instance if they were detached from the instance
@ -460,17 +458,13 @@ module Vmpooler
true
end
def vm_ready?(pool_name, vm_name, redis)
debug_logger('vm_ready?')
def vm_ready?(_pool_name, vm_name)
begin
# TODO: we could use a healthcheck resource attached to instance
domain = domain(pool_name)
open_socket(vm_name, domain)
rescue StandardError => e
redis.hset("vmpooler__vm__#{vm_name}", 'open_socket_error', e.to_s)
open_socket(vm_name, domain || global_config[:config]['domain'])
rescue StandardError => _e
return false
end
redis.hdel("vmpooler__vm__#{vm_name}", 'open_socket_error')
true
end
@ -499,6 +493,9 @@ module Vmpooler
debug_logger("trigger async delete_instance #{vm.name}")
result = connection.delete_instance(project, zone, vm.name)
vm_pool = vm.labels&.key?('pool') ? vm.labels['pool'] : nil
existing_vm = generate_vm_hash(vm, vm_pool)
dns_teardown(existing_vm)
result_list << result
end
# now check they are done
@ -559,6 +556,31 @@ module Vmpooler
# END BASE METHODS
def dns_setup(created_instance)
dns_zone = dns.zone(dns_zone_resource_name) if dns_zone_resource_name
return unless dns_zone && created_instance && created_instance['name'] && created_instance['ip']
name = created_instance['name']
begin
change = dns_zone.add(name, 'A', 60, [created_instance['ip']])
debug_logger("#{change.id} - #{change.started_at} - #{change.status} DNS address added") if change
rescue Google::Cloud::AlreadyExistsError => _e
# DNS setup is done only for new instances, so in the rare case where a DNS record already exists (it is stale) and we replace it.
# the error is Google::Cloud::AlreadyExistsError: alreadyExists: The resource 'entity.change.additions[0]' named 'instance-8.test.vmpooler.net. (A)' already exists
change = dns_zone.replace(name, 'A', 60, [created_instance['ip']])
debug_logger("#{change.id} - #{change.started_at} - #{change.status} DNS address previously existed and was replaced") if change
end
end
def dns_teardown(created_instance)
dns_zone = dns.zone(dns_zone_resource_name) if dns_zone_resource_name
return unless dns_zone && created_instance
name = created_instance['name']
change = dns_zone.remove(name, 'A')
debug_logger("#{change.id} - #{change.started_at} - #{change.status} DNS address removed") if change
end
def should_be_ignored(item, allowlist)
return false if allowlist.nil?
@ -672,13 +694,15 @@ module Vmpooler
# This should supercede the open_socket method in the Pool Manager
def open_socket(host, domain = nil, timeout = 5, port = 22, &_block)
target_host = host
target_host = "#{host}.#{domain}" if domain
sock = TCPSocket.new(target_host, port, connect_timeout: timeout)
begin
yield sock if block_given?
ensure
sock.close
Timeout.timeout(timeout) do
target_host = host
target_host = "#{host}.#{domain}" if domain
sock = TCPSocket.new target_host, port
begin
yield sock if block_given?
ensure
sock.close
end
end
end

View file

@ -1,15 +0,0 @@
#!/usr/bin/env bash
# The container tag should closely match what is used in `docker/Dockerfile` in vmpooler-deployment
#
# Update Gemfile.lock
docker run -t --rm \
-v $(pwd):/app \
jruby:9.4.3.0-jdk11 \
/bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends git make netbase && cd /app && gem install bundler && bundle install --jobs 3; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"'
# Update Changelog
docker run -t --rm -e CHANGELOG_GITHUB_TOKEN -v $(pwd):/usr/local/src/your-app \
githubchangeloggenerator/github-changelog-generator:1.16.2 \
github_changelog_generator --future-release $(grep VERSION lib/vmpooler-provider-gce/version.rb |rev |cut -d "'" -f2 |rev)

View file

@ -0,0 +1,9 @@
MockDNS = Struct.new(
# https://rubydoc.info/gems/google-cloud-dns/0.35.1/Google/Cloud/Dns
:change, :credentials, :project, :record, :zone,
keyword_init: true
) do
def zone(zone)
self.zone = zone
end
end

View file

@ -10,6 +10,7 @@ require 'vmpooler'
require 'redis'
require 'vmpooler/metrics'
require 'computeservice_helper'
require 'dnsservice_helper'
def project_root_dir
File.dirname(File.dirname(__FILE__))

View file

@ -18,11 +18,6 @@ describe 'Vmpooler::PoolManager::Provider::Gce' do
:config:
max_tries: 3
retry_factor: 10
:dns_configs:
:gcp-clouddns:
project: vmpooler-test
domain: vmpooler.example.com
dns_zone_resource_name: vmpooler-example-com
:providers:
:gce:
connection_pool_timeout: 1
@ -37,7 +32,6 @@ describe 'Vmpooler::PoolManager::Provider::Gce' do
timeout: 10
ready_ttl: 1440
provider: 'gce'
dns_config: 'gcp-clouddns'
machine_type: 'zones/#{zone}/machineTypes/e2-micro'
EOT
)
@ -57,6 +51,8 @@ EOT
subject { Vmpooler::PoolManager::Provider::Gce.new(config, logger, metrics, redis_connection_pool, 'gce', provider_options) }
before(:each) { allow(subject).to receive(:dns).and_return(MockDNS.new()) }
describe '#name' do
it 'should be gce' do
expect(subject.name).to eq('gce')
@ -65,24 +61,22 @@ EOT
describe '#manual tests live' do
context 'in itsysops' do
let(:vmname) { "instance-31" }
before(:each) { allow(subject).to receive(:dns).and_call_original }
let(:vmname) { "instance-24" }
let(:project) { 'vmpooler-test' }
let(:config) { YAML.load(<<~EOT
---
:config:
max_tries: 3
retry_factor: 10
:dns_configs:
:gcp-clouddns:
project: vmpooler-test
domain: vmpooler.example.com
dns_zone_resource_name: vmpooler-example-com
:providers:
:gce:
connection_pool_timeout: 1
project: '#{project}'
zone: '#{zone}'
network_name: 'projects/itsysopsnetworking/global/networks/shared1'
dns_zone_resource_name: 'test-vmpooler-puppet-net'
domain: 'test.vmpooler.puppet.net'
:pools:
- name: '#{poolname}'
alias: [ 'mockpool' ]
@ -91,14 +85,16 @@ EOT
timeout: 10
ready_ttl: 1440
provider: 'gce'
dns_config: 'gcp-clouddns'
subnetwork_name: 'projects/itsysopsnetworking/regions/us-west1/subnetworks/vmpooler-test'
machine_type: 'zones/#{zone}/machineTypes/e2-micro'
disk_type: 'pd-ssd'
EOT
) }
skip 'gets a vm' do
result = subject.create_vm(poolname, vmname)
#result = subject.destroy_vm(poolname, vmname)
subject.get_vm(poolname, vmname)
#subject.dns_teardown({'name' => vmname})
# subject.dns_setup({'name' => vmname, 'ip' => '1.2.3.5'})
end
end
end
@ -350,20 +346,14 @@ EOT
end
describe '#vm_ready?' do
let(:domain) { 'vmpooler.example.com' }
before(:each) do
allow(subject).to receive(:domain).and_return('vmpooler.example.com')
end
let(:domain) { nil }
context 'When a VM is ready' do
before(:each) do
expect(subject).to receive(:open_socket).with(vmname, domain)
end
it 'should return true' do
redis_connection_pool.with_metrics do |redis|
expect(subject.vm_ready?(poolname, vmname, redis)).to be true
end
expect(subject.vm_ready?(poolname, vmname)).to be true
end
end
@ -373,9 +363,7 @@ EOT
end
it 'should return false' do
redis_connection_pool.with_metrics do |redis|
expect(subject.vm_ready?(poolname, vmname, redis)).to be false
end
expect(subject.vm_ready?(poolname, vmname)).to be false
end
end
end

View file

@ -1,7 +0,0 @@
#!/usr/bin/env bash
# The container tag should closely match what is used in `docker/Dockerfile` in vmpooler-deployment
docker run -it --rm \
-v $(pwd):/app \
jruby:9.4.3.0-jdk11 \
/bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends git make netbase && cd /app && gem install bundler && bundle install --jobs 3 && bundle update; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"'

View file

@ -16,8 +16,10 @@ Gem::Specification.new do |s|
s.files = Dir[ "lib/**/*" ]
s.require_paths = ["lib"]
s.add_dependency "google-apis-compute_v1", "~> 0.14"
s.add_dependency "googleauth", ">= 0.16.2", "< 1.4.0"
s.add_dependency 'vmpooler', '~> 3.0'
s.add_dependency "googleauth", "~> 0.16.2"
s.add_dependency "google-cloud-dns", "~> 0.35.1"
s.add_development_dependency 'vmpooler', '~> 1.3', '>= 1.3.0'
# Testing dependencies
s.add_development_dependency 'climate_control', '>= 0.2.0'

View file

@ -146,10 +146,6 @@
# (optional: default is global provider zone value)
# - machine_type
# Full or partial URL of the machine type resource to use for this instance, in the format: zones/zone/machineTypes/machine-type
# - disk_type
# the disk type to use, see https://cloud.google.com/compute/docs/disks one of
# pd-standard, pd-balanced, pd-ssd or pd-extreme
# (optional, when nil or empty defaults to pd-standard)
# Example:
:pools: