Update dev tooling and related docs

This commit is contained in:
Gene Liverman 2022-01-19 14:59:12 -05:00
parent 49822bff31
commit f7eaeedbfc
No known key found for this signature in database
GPG key ID: 3AF83985B6C857C6
21 changed files with 506 additions and 463 deletions

View file

@ -3,7 +3,6 @@
**/*.md **/*.md
**/*example **/*example
**/Dockerfile* **/Dockerfile*
Gemfile.lock
Rakefile Rakefile
Vagrantfile Vagrantfile
coverage coverage

View file

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

View file

@ -1,29 +0,0 @@
name: Verify Pre-Deploy Status
on: pull_request
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checkout repo
- name: Checkout
uses: actions/checkout@v2
# Run checks
- name: Lightstep Pre-Deploy Check
uses: lightstep/lightstep-action-predeploy@v0.2.6
id: lightstep-predeploy
with:
lightstep_api_key: ${{ secrets.LIGHTSTEP_API_KEY }}
pagerduty_api_token: ${{ secrets.PAGERDUTY_API_TOKEN }}
# Output status as a comment
- name: Add a Comment
uses: unsplash/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: ${{ steps.lightstep-predeploy.outputs.lightstep_predeploy_md }}
check_for_duplicate_msg: true

View file

@ -20,10 +20,10 @@ jobs:
draft: false draft: false
prerelease: false prerelease: false
generateReleaseNotes: true generateReleaseNotes: true
- name: Install Ruby 2.5.8 - name: Install Ruby jruby-9.2.12.0
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
ruby-version: '2.5.8' ruby-version: 'jruby-9.2.12.0'
- name: Build gem - name: Build gem
run: gem build *.gemspec run: gem build *.gemspec
- name: Publish gem - name: Publish gem

View file

@ -18,7 +18,8 @@ jobs:
strategy: strategy:
matrix: matrix:
ruby-version: ruby-version:
- '2.5.8' # - '2.5.8'
- 'jruby-9.2.12.0'
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Set up Ruby - name: Set up Ruby
@ -34,7 +35,7 @@ jobs:
strategy: strategy:
matrix: matrix:
ruby-version: ruby-version:
- '2.5.8' # - '2.5.8'
- 'jruby-9.2.12.0' - 'jruby-9.2.12.0'
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2

2
.gitignore vendored
View file

@ -5,7 +5,5 @@ vendor/
.dccache .dccache
.ruby-version .ruby-version
Gemfile.local Gemfile.local
Gemfile.lock
results.xml results.xml
/vmpooler.yaml /vmpooler.yaml

View file

@ -1,10 +0,0 @@
organization: Puppet Inc
project: puppet-inc-prod
conditions:
# API /status error >0%
- SZcJVQfy
integrations:
pagerduty:
# VMPooler service
service: P714ID4

194
Gemfile.lock Normal file
View file

@ -0,0 +1,194 @@
PATH
remote: .
specs:
vmpooler (2.2.0)
concurrent-ruby (~> 1.1)
connection_pool (~> 2.2)
deep_merge (~> 1.2)
net-ldap (~> 0.16)
nokogiri (~> 1.10)
opentelemetry-exporter-jaeger (= 0.20.1)
opentelemetry-instrumentation-concurrent_ruby (= 0.19.2)
opentelemetry-instrumentation-redis (= 0.21.2)
opentelemetry-instrumentation-sinatra (= 0.19.3)
opentelemetry-resource_detectors (= 0.19.1)
opentelemetry-sdk (~> 1.0, >= 1.0.2)
pickup (~> 0.0.11)
prometheus-client (~> 2.0)
puma (~> 5.0, >= 5.0.4)
rack (~> 2.2)
rake (~> 13.0)
redis (~> 4.1)
sinatra (~> 2.0)
spicy-proton (~> 2.1)
statsd-ruby (~> 1.4)
GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
bindata (2.4.10)
builder (3.2.4)
climate_control (1.0.1)
coderay (1.1.3)
concurrent-ruby (1.1.9)
connection_pool (2.2.5)
deep_merge (1.2.2)
diff-lcs (1.5.0)
docile (1.4.0)
faraday (1.9.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.3)
multipart-post (>= 1.2, < 3)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
ffi (1.15.5-java)
google-cloud-env (1.5.0)
faraday (>= 0.17.3, < 2.0)
method_source (1.0.0)
mock_redis (0.29.0)
ruby2_keywords
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
net-ldap (0.17.0)
nio4r (2.5.8-java)
nokogiri (1.12.5-java)
racc (~> 1.4)
opentelemetry-api (1.0.1)
opentelemetry-common (0.19.3)
opentelemetry-api (~> 1.0)
opentelemetry-exporter-jaeger (0.20.1)
opentelemetry-api (~> 1.0)
opentelemetry-common (~> 0.19.2)
opentelemetry-sdk (~> 1.0)
thrift
opentelemetry-instrumentation-base (0.19.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-concurrent_ruby (0.19.2)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.19.0)
opentelemetry-instrumentation-redis (0.21.2)
opentelemetry-api (~> 1.0)
opentelemetry-common (~> 0.19.3)
opentelemetry-instrumentation-base (~> 0.19.0)
opentelemetry-instrumentation-sinatra (0.19.3)
opentelemetry-api (~> 1.0)
opentelemetry-common (~> 0.19.3)
opentelemetry-instrumentation-base (~> 0.19.0)
opentelemetry-resource_detectors (0.19.1)
google-cloud-env
opentelemetry-sdk
opentelemetry-sdk (1.0.2)
opentelemetry-api (~> 1.0)
opentelemetry-common (~> 0.19.3)
opentelemetry-instrumentation-base (~> 0.19.0)
opentelemetry-semantic_conventions
opentelemetry-semantic_conventions (1.8.0)
opentelemetry-api (~> 1.0)
parallel (1.21.0)
parser (3.1.0.0)
ast (~> 2.4.1)
pickup (0.0.11)
prometheus-client (2.1.0)
pry (0.14.1-java)
coderay (~> 1.1)
method_source (~> 1.0)
spoon (~> 0.0)
puma (5.5.2-java)
nio4r (~> 2.0)
racc (1.6.0-java)
rack (2.2.3)
rack-protection (2.1.0)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rainbow (3.1.1)
rake (13.0.6)
redis (4.5.1)
regexp_parser (2.2.0)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.3)
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.15.1)
parser (>= 3.0.1.1)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.3)
sinatra (2.1.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.1.0)
tilt (~> 2.0)
spicy-proton (2.1.13)
bindata (~> 2.3)
spoon (0.0.6)
ffi
statsd-ruby (1.5.0)
thor (1.2.1)
thrift (0.15.0)
tilt (2.0.10)
unicode-display_width (1.8.0)
yarjuf (2.0.0)
builder
rspec (~> 3)
PLATFORMS
universal-java-1.8
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!
yarjuf (>= 2.0)
BUNDLED WITH
2.3.5

View file

@ -14,19 +14,23 @@ As of version 2.0.0, all providers other than the dummy one are now separate gem
## Installation ## Installation
### Prerequisites The recommended method of installation is via the Helm chart located in [puppetlabs/vmpooler-deployment](https://github.com/puppetlabs/vmpooler-deployment). That repository also provides Docker images of VMPooler.
VMPooler is available as a gem. To use the gem run `gem install vmpooler` or add it to your Gemfile and install via bundler. You will also need to install any needed providers in the same manner.
### Dependencies ### Dependencies
#### Redis
VMPooler requires a [Redis](http://redis.io/) server. This is the data store used for VMPooler's inventory and queuing services. VMPooler requires a [Redis](http://redis.io/) server. This is the data store used for VMPooler's inventory and queuing services.
### Configuration #### Other gems
VMPooler itself and the dev environment talked about below require additional Ruby gems to function. You can update the currently required ones for VMPooler by running `./update-gemfile-lock.sh`. The gems for the dev environment can be updated by running `./docker/update-gemfile-lock.sh`. These scripts will utilize the container on the FROM line of the Dockerfile to update the Gemfile.lock in the root of this repo and in the docker folder, respectively.
## Configuration
Configuration for VMPooler may be provided via environment variables, or a configuration file. Configuration for VMPooler may be provided via environment variables, or a configuration file.
#### Note on JRuby 9.2.11.x ### Note on JRuby 9.2.11.x
We have found when running VMPooler on JRuby 9.2.11.x we occasionally encounter a stack overflow error that causes the pool\_manager application component to fail and stop doing work. To address this issue on JRuby 9.2.11.x we recommend setting the JRuby option `invokedynamic.yield=false`. To set this with JRuby 9.2.11.1 you can specify the environment variable `JRUBY_OPTS` with the value `-Xinvokedynamic.yield=false`. We have found when running VMPooler on JRuby 9.2.11.x we occasionally encounter a stack overflow error that causes the pool\_manager application component to fail and stop doing work. To address this issue on JRuby 9.2.11.x we recommend setting the JRuby option `invokedynamic.yield=false`. To set this with JRuby 9.2.11.1 you can specify the environment variable `JRUBY_OPTS` with the value `-Xinvokedynamic.yield=false`.
@ -71,39 +75,7 @@ The following YAML configuration sets up two pools, `debian-7-i386` and `debian-
See the provided YAML configuration example, [vmpooler.yaml.example](vmpooler.yaml.example), for additional configuration options and parameters or for supporting multiple providers. See the provided YAML configuration example, [vmpooler.yaml.example](vmpooler.yaml.example), for additional configuration options and parameters or for supporting multiple providers.
### Running via Docker ## Components
A [Dockerfile](/docker/Dockerfile) is included in this repository to allow running VMPooler inside a Docker container. A configuration file can be used via volume mapping, and specifying the destination as the configuration file via environment variables, or the application can be configured with environment variables alone. The Dockerfile provides an entrypoint so you may choose whether to run API, or manager services. The default behavior will run both. To build and run:
```bash
docker build -t vmpooler . && docker run -e VMPOOLER_CONFIG -p 80:4567 -it vmpooler
```
To run only the API and dashboard:
```bash
docker run -p 80:4567 -it vmpooler api
```
To run only the manager component:
```bash
docker run -it vmpooler manager
```
### docker-compose
A docker-compose file is provided to support running VMPooler easily via docker-compose. This is useful for development because your local code is used to build the gem used in the docker-compose environment.
```bash
docker-compose -f docker/docker-compose.yml up
```
### Running Docker inside Vagrant
A Vagrantfile is included in this repository. Please see [vagrant instructions](docs/vagrant.md) for details.
## API and Dashboard
VMPooler provides an API and web front-end (dashboard) on port `:4567`. See the provided YAML configuration example, [vmpooler.yaml.example](vmpooler.yaml.example), to specify an alternative port to listen on. VMPooler provides an API and web front-end (dashboard) on port `:4567`. See the provided YAML configuration example, [vmpooler.yaml.example](vmpooler.yaml.example), to specify an alternative port to listen on.
@ -129,13 +101,45 @@ A dashboard is provided to offer real-time statistics and historical graphs. It
- [vagrant-vmpooler](https://github.com/briancain/vagrant-vmpooler): Use Vagrant to create and manage your VMPooler instances. - [vagrant-vmpooler](https://github.com/briancain/vagrant-vmpooler): Use Vagrant to create and manage your VMPooler instances.
## Development and further documentation ## Development
### docker-compose
A docker-compose file is provided to support running VMPooler and associated tools locally. This is useful for development because your local code is used to build the gem used in the docker-compose environment. The compose environment also pulls in the latest providers via git. Details of this setup are stored in the `docker/` folder.
```bash
docker-compose -f docker/docker-compose.yml build && \
docker-compose -f docker/docker-compose.yml up
```
### Running docker-compose inside Vagrant
A Vagrantfile is included in this repository so as to provide a reproducible development environment.
```bash
vagrant up
vagrant ssh
cd /vagrant
docker-compose -f docker/docker-compose.yml build && \
docker-compose -f docker/docker-compose.yml up
```
The Vagrant environment also contains multiple rubies you can utilize for spec test and the like. You can see a list of the pre-installed ones when you log in as part of the message of the day.
For more information about setting up a development instance of VMPooler or other subjects, see the [docs/](docs) directory. For more information about setting up a development instance of VMPooler or other subjects, see the [docs/](docs) directory.
### Build status ### URLs when using docker-compose
[![Testing](https://github.com/puppetlabs/vmpooler/actions/workflows/testing.yml/badge.svg)](https://github.com/puppetlabs/vmpooler/actions/workflows/testing.yml) | Endpoint | URL |
|-------------------|-----------------------------------------------------------------------|
| Redis Commander | [http://localhost:8079](http://localhost:8079) |
| API | [http://localhost:8080/api/v1]([http://localhost:8080/api/v1) |
| Dashboard | [http://localhost:8080/dashboard/](http://localhost:8080/dashboard/) |
| Metrics (API) | [http://localhost:8080/prometheus]([http://localhost:8080/prometheus) |
| Metrics (Manager) | [http://localhost:8081/prometheus]([http://localhost:8081/prometheus) |
| Jaeger | [http://localhost:8082](http://localhost:8082) |
Additionally, the Redis instance can be accessed at `localhost:6379`.
## License ## License

2
Vagrantfile vendored
View file

@ -2,6 +2,8 @@
Vagrant.configure("2") do |config| Vagrant.configure("2") do |config|
config.vm.box = "genebean/centos-7-rvm-multi" config.vm.box = "genebean/centos-7-rvm-multi"
config.vm.network "forwarded_port", guest: 4567, host: 4567 # for when not running docker-compose config.vm.network "forwarded_port", guest: 4567, host: 4567 # for when not running docker-compose
config.vm.network "forwarded_port", guest: 6379, host: 6379 # Redis
config.vm.network "forwarded_port", guest: 8079, host: 8079 # Redis Commander
config.vm.network "forwarded_port", guest: 8080, host: 8080 # VMPooler api in docker-compose config.vm.network "forwarded_port", guest: 8080, host: 8080 # VMPooler api in docker-compose
config.vm.network "forwarded_port", guest: 8081, host: 8081 # VMPooler manager in docker-compose config.vm.network "forwarded_port", guest: 8081, host: 8081 # VMPooler manager in docker-compose
config.vm.network "forwarded_port", guest: 8082, host: 8082 # Jaeger in docker-compose config.vm.network "forwarded_port", guest: 8082, host: 8082 # Jaeger in docker-compose

View file

@ -1,21 +1,9 @@
# Run vmpooler in a Docker container! Configuration can either be embedded # This Dockerfile is intended to be used with the
# and built within the current working directory, or stored in a # docker-compose file in the same directory.
# VMPOOLER_CONFIG environment value and passed to the Docker daemon.
#
# BUILD:
# docker build -t vmpooler .
#
# RUN:
# docker run -e VMPOOLER_CONFIG -p 80:4567 -it vmpooler
FROM jruby:9.2-jdk FROM jruby:9.2-jdk
ARG vmpooler_version=0.11.3 ENV RACK_ENV=production
COPY docker/docker-entrypoint.sh /usr/local/bin/
ENV LOGFILE=/dev/stdout \
RACK_ENV=production
RUN apt-get update -qq && \ RUN apt-get update -qq && \
apt-get install -y --no-install-recommends make && \ apt-get install -y --no-install-recommends make && \
@ -23,7 +11,16 @@ RUN apt-get update -qq && \
apt-get autoremove -y && \ apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
RUN gem install vmpooler -v ${vmpooler_version} && \ COPY docker/docker-entrypoint.sh /usr/local/bin/
chmod +x /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
COPY docker/Gemfile* ./
COPY ./ ./vmpooler-source
RUN gem install bundler && \
bundle config set --local jobs 3 && \
bundle install
ENTRYPOINT ["docker-entrypoint.sh"] ENTRYPOINT ["docker-entrypoint.sh"]

View file

@ -1,39 +0,0 @@
# Run vmpooler in a Docker container! Configuration can either be embedded
# and built within the current working directory, or stored in a
# VMPOOLER_CONFIG environment value and passed to the Docker daemon.
#
# BUILD:
# docker build -t vmpooler .
#
# RUN:
# docker run -e VMPOOLER_CONFIG -p 80:4567 -it vmpooler
FROM jruby:9.2.9-jdk
RUN mkdir -p /var/lib/vmpooler
WORKDIR /var/lib/vmpooler
RUN echo "deb http://httpredir.debian.org/debian jessie main" >/etc/apt/sources.list.d/jessie-main.list
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends make redis-server && \
apt-get clean autoclean && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
ADD Gemfile* /var/lib/vmpooler/
RUN bundle install --system
RUN ln -s /opt/jruby/bin/jruby /usr/bin/jruby
COPY . /var/lib/vmpooler
ENV VMPOOLER_LOG /var/log/vmpooler.log
CMD \
/etc/init.d/redis-server start \
&& /var/lib/vmpooler/scripts/vmpooler_init.sh start \
&& while [ ! -f ${VMPOOLER_LOG} ]; do sleep 1; done ; \
tail -f ${VMPOOLER_LOG}

View file

@ -1,36 +0,0 @@
# Run vmpooler in a Docker container! Configuration can either be embedded
# and built within the current working directory, or stored in a
# VMPOOLER_CONFIG environment value and passed to the Docker daemon.
#
# BUILD:
# docker build -t vmpooler .
#
# RUN:
# docker run -e VMPOOLER_CONFIG -p 80:4567 -it vmpooler
FROM jruby:9.2-jdk
ENV RACK_ENV=production
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends make && \
apt-get clean autoclean && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
COPY docker/docker-entrypoint.sh /usr/local/bin/
COPY ./Gemfile ./
COPY ./vmpooler.gemspec ./
COPY ./lib/vmpooler/version.rb ./lib/vmpooler/version.rb
RUN gem install bundler && \
bundle config set --local jobs 3 && \
bundle install
COPY ./ ./
RUN gem build vmpooler.gemspec && \
gem install vmpooler*.gem && \
chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]

5
docker/Gemfile Normal file
View file

@ -0,0 +1,5 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
gem 'vmpooler', path: './vmpooler-source'
gem 'vmpooler-provider-gce', git: 'https://github.com/puppetlabs/vmpooler-provider-gce.git'
gem 'vmpooler-provider-vsphere', git: 'https://github.com/puppetlabs/vmpooler-provider-vsphere.git'

205
docker/Gemfile.lock Normal file
View file

@ -0,0 +1,205 @@
GIT
remote: https://github.com/puppetlabs/vmpooler-provider-gce.git
revision: 614c474305f707ef52b4e3e92aabccec5880fba6
specs:
vmpooler-provider-gce (0.1.2)
google-apis-compute_v1 (~> 0.14)
google-cloud-dns (~> 0.35.1)
googleauth (~> 0.16.2)
GIT
remote: https://github.com/puppetlabs/vmpooler-provider-vsphere.git
revision: a9662622d5574a7f9f6e97ff4c8bc82786982266
specs:
vmpooler-provider-vsphere (1.5.0)
rbvmomi (>= 2.1, < 4.0)
PATH
remote: vmpooler-source
specs:
vmpooler (2.2.0)
concurrent-ruby (~> 1.1)
connection_pool (~> 2.2)
deep_merge (~> 1.2)
net-ldap (~> 0.16)
nokogiri (~> 1.10)
opentelemetry-exporter-jaeger (= 0.20.1)
opentelemetry-instrumentation-concurrent_ruby (= 0.19.2)
opentelemetry-instrumentation-redis (= 0.21.2)
opentelemetry-instrumentation-sinatra (= 0.19.3)
opentelemetry-resource_detectors (= 0.19.1)
opentelemetry-sdk (~> 1.0, >= 1.0.2)
pickup (~> 0.0.11)
prometheus-client (~> 2.0)
puma (~> 5.0, >= 5.0.4)
rack (~> 2.2)
rake (~> 13.0)
redis (~> 4.1)
sinatra (~> 2.0)
spicy-proton (~> 2.1)
statsd-ruby (~> 1.4)
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
bindata (2.4.10)
builder (3.2.4)
concurrent-ruby (1.1.9)
connection_pool (2.2.5)
declarative (0.0.20)
deep_merge (1.2.2)
faraday (1.9.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.3)
multipart-post (>= 1.2, < 3)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
google-apis-compute_v1 (0.23.0)
google-apis-core (>= 0.4, < 2.a)
google-apis-core (0.4.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-apis-dns_v1 (0.17.0)
google-apis-core (>= 0.4, < 2.a)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0)
google-cloud-dns (0.35.1)
google-apis-dns_v1 (~> 0.1)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
zonefile (~> 1.04)
google-cloud-env (1.5.0)
faraday (>= 0.17.3, < 2.0)
google-cloud-errors (1.2.0)
googleauth (0.16.2)
faraday (>= 0.17.3, < 2.0)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (~> 0.14)
httpclient (2.8.3)
json (2.6.1-java)
jwt (2.3.0)
memoist (0.16.2)
mini_mime (1.1.2)
multi_json (1.15.0)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
net-ldap (0.17.0)
nio4r (2.5.8-java)
nokogiri (1.12.5-java)
racc (~> 1.4)
opentelemetry-api (1.0.1)
opentelemetry-common (0.19.3)
opentelemetry-api (~> 1.0)
opentelemetry-exporter-jaeger (0.20.1)
opentelemetry-api (~> 1.0)
opentelemetry-common (~> 0.19.2)
opentelemetry-sdk (~> 1.0)
thrift
opentelemetry-instrumentation-base (0.19.0)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-concurrent_ruby (0.19.2)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.19.0)
opentelemetry-instrumentation-redis (0.21.2)
opentelemetry-api (~> 1.0)
opentelemetry-common (~> 0.19.3)
opentelemetry-instrumentation-base (~> 0.19.0)
opentelemetry-instrumentation-sinatra (0.19.3)
opentelemetry-api (~> 1.0)
opentelemetry-common (~> 0.19.3)
opentelemetry-instrumentation-base (~> 0.19.0)
opentelemetry-resource_detectors (0.19.1)
google-cloud-env
opentelemetry-sdk
opentelemetry-sdk (1.0.2)
opentelemetry-api (~> 1.0)
opentelemetry-common (~> 0.19.3)
opentelemetry-instrumentation-base (~> 0.19.0)
opentelemetry-semantic_conventions
opentelemetry-semantic_conventions (1.8.0)
opentelemetry-api (~> 1.0)
optimist (3.0.1)
os (1.1.4)
pickup (0.0.11)
prometheus-client (2.1.0)
public_suffix (4.0.6)
puma (5.5.2-java)
nio4r (~> 2.0)
racc (1.6.0-java)
rack (2.2.3)
rack-protection (2.1.0)
rack
rake (13.0.6)
rbvmomi (3.0.0)
builder (~> 3.2)
json (~> 2.3)
nokogiri (~> 1.10)
optimist (~> 3.0)
redis (4.5.1)
representable (3.1.1)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.2.5)
ruby2_keywords (0.0.5)
signet (0.16.0)
addressable (~> 2.8)
faraday (>= 0.17.3, < 2.0)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
sinatra (2.1.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.1.0)
tilt (~> 2.0)
spicy-proton (2.1.13)
bindata (~> 2.3)
statsd-ruby (1.5.0)
thrift (0.15.0)
tilt (2.0.10)
trailblazer-option (0.1.2)
uber (0.1.0)
webrick (1.7.0)
zonefile (1.06)
PLATFORMS
universal-java-1.8
DEPENDENCIES
vmpooler!
vmpooler-provider-gce!
vmpooler-provider-vsphere!
BUNDLED WITH
2.3.5

View file

@ -4,7 +4,7 @@ services:
vmpooler-api: vmpooler-api:
build: build:
context: ../ context: ../
dockerfile: docker/Dockerfile_local dockerfile: docker/Dockerfile
volumes: volumes:
- type: bind - type: bind
source: ${PWD}/vmpooler.yaml source: ${PWD}/vmpooler.yaml
@ -28,7 +28,7 @@ services:
vmpooler-manager: vmpooler-manager:
build: build:
context: ../ context: ../
dockerfile: docker/Dockerfile_local dockerfile: docker/Dockerfile
volumes: volumes:
- type: bind - type: bind
source: ${PWD}/vmpooler.yaml source: ${PWD}/vmpooler.yaml
@ -57,6 +57,19 @@ services:
- "6379:6379" - "6379:6379"
networks: networks:
- redis-net - redis-net
redis-commander:
container_name: redis-commander
hostname: redis-commander
image: rediscommander/redis-commander:latest
restart: always
environment:
- REDIS_HOSTS=local:redislocal:6379
ports:
- "8079:8081"
networks:
- redis-net
depends_on:
- redislocal
jaeger-aio: jaeger-aio:
image: jaegertracing/all-in-one:1.18 image: jaegertracing/all-in-one:1.18
ports: ports:

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
set -e set -e
set -- vmpooler "$@" set -- bundle exec vmpooler "$@"
exec "$@" exec "$@"

8
docker/update-gemfile-lock.sh Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
docker run -it --rm \
-v $(pwd)/docker:/app \
-v $(pwd):/app/vmpooler-source \
$(grep ^FROM docker/Dockerfile |cut -d ' ' -f2) \
/bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends make && cd /app && gem install bundler && bundle install --jobs 3 && bundle update; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"'
rmdir docker/vmpooler-source

View file

@ -1,236 +0,0 @@
# Setting up a vmpooler development environment
## Docker is the preferred development environment
The docker compose file is the easiest way to get vmpooler running with any local code changes. The docker compose file expects to find a vmpooler.yaml configuration file in the root vmpooler directory. The file is mapped into the running container for the vmpooler application. This file primarily contains the pools configuration. Nearly all other configuration can be supplied with environment variables.
## Requirements for local installation directly on your system (not recommended)
* Supported on OSX, Windows and Linux
* Ruby or JRuby
Note - It is recommended to user Bundler instead of installing gems into the system repository
* A local Redis server
Either a containerized instance of Redis or a local version is fine.
## Setup source and ruby
* Clone repository, either from your own fork or the original source
* Perform a bundle install
```
~/ > git clone https://github.com/puppetlabs/vmpooler.git
Cloning into 'vmpooler'...
remote: Counting objects: 3411, done.
...
~/ > cd vmpooler
~/vmpooler/ > bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Installing rake 12.0.0
...
Bundle complete! 16 Gemfile dependencies, 37 gems now installed.
```
## Setup environment variables
### `VMPOOLER_DEBUG`
Setting the `VMPOOLER_DEBUG` environment variable will instruct vmpooler to:
* Output log messages to STDOUT
* Allow the use of the dummy authentication method
* Add interrupt traps so you can stop vmpooler when run interactively
Linux, OSX
```bash
~/vmpooler/ > export VMPOOLER_DEBUG=true
```
Windows (PowerShell)
```powershell
C:\vmpooler > $ENV:VMPOOLER_DEBUG = 'true'
```
### `VMPOOLER_CONFIG`
When `VMPOOLER_CONFIG` is set, vmpooler will read its configuration from the content of the environment variable.
Note that this variable does not point to a different configuration file, but stores the contents of a configuration file. You may use `VMPOOLER_CONFIG_FILE` instead to specify a filename.
### `VMPOOLER_CONFIG_FILE`
When `VMPOOLER_CONFIG_FILE` is set, vmpooler will read its configuration from the file specified in the environment variable.
Note that this variable points to a different configuration file, unlike `VMPOOLER_CONFIG`.
## Setup vmpooler Configuration
You can create a `vmpooler.yaml` file, set the `VMPOOLER_CONFIG` environment variable with the equivalent content, or set the `VMPOOLER_CONFIG_FILE` environment variable with the name of another configuration file to use. `VMPOOLER_CONFIG` takes precedence over `VMPOOLER_CONFIG_FILE`.
Example minimal configuration file:
```yaml
---
:providers:
:dummy:
:redis:
server: 'localhost'
:auth:
provider: dummy
:tagfilter:
url: '(.*)\/'
:config:
site_name: 'vmpooler'
# Need to change this on Windows
logfile: '/var/log/vmpooler.log'
task_limit: 10
timeout: 15
vm_lifetime: 12
vm_lifetime_auth: 24
allowed_tags:
- 'created_by'
- 'project'
domain: 'example.com'
prefix: 'poolvm-'
# Uncomment the lines below to suppress metrics to STDOUT
# :statsd:
# server: 'localhost'
# prefix: 'vmpooler'
# port: 8125
:pools:
- name: 'pool01'
size: 5
provider: dummy
- name: 'pool02'
size: 5
provider: dummy
```
## Running vmpooler locally
* Run `bundle exec ruby vmpooler`
If using JRuby, you may need to use `bundle exec jruby vmpooler`
You should see output similar to:
```
~/vmpooler/ > bundle exec ruby vmpooler
[2017-06-16 14:50:31] starting vmpooler
[2017-06-16 14:50:31] [!] Creating provider 'dummy'
[2017-06-16 14:50:31] [dummy] ConnPool - Creating a connection pool of size 1 with timeout 10
[2017-06-16 14:50:31] [*] [disk_manager] starting worker thread
[2017-06-16 14:50:31] [*] [snapshot_manager] starting worker thread
[2017-06-16 14:50:31] [*] [pool01] starting worker thread
[2017-06-16 14:50:31] [*] [pool02] starting worker thread
[2017-06-16 14:50:31] [dummy] ConnPool - Creating a connection object ID 1784
== Sinatra (v1.4.8) has taken the stage on 4567 for production with backup from Puma
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 3.9.1 (ruby 2.3.1-p112), codename: Private Caller
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://0.0.0.0:4567
Use Ctrl-C to stop
[2017-06-16 14:50:31] [!] [pool02] is empty
[2017-06-16 14:50:31] [!] [pool01] is empty
[2017-06-16 14:50:31] [ ] [pool02] Starting to clone 'poolvm-nexs1w50m4djap5'
[2017-06-16 14:50:31] [ ] [pool01] Starting to clone 'poolvm-r543eibo4b6tjer'
[2017-06-16 14:50:31] [ ] [pool01] Starting to clone 'poolvm-neqmu7wj7aukyjy'
[2017-06-16 14:50:31] [ ] [pool02] Starting to clone 'poolvm-nsdnrhhy22lnemo'
[2017-06-16 14:50:31] [ ] [pool01] 'poolvm-r543eibo4b6tjer' is being cloned from ''
[2017-06-16 14:50:31] [ ] [pool01] 'poolvm-neqmu7wj7aukyjy' is being cloned from ''
[2017-06-16 14:50:31] [ ] [pool02] 'poolvm-nexs1w50m4djap5' is being cloned from ''
[2017-06-16 14:50:31] [ ] [pool01] Starting to clone 'poolvm-edzlp954lyiozli'
[2017-06-16 14:50:31] [ ] [pool01] Starting to clone 'poolvm-nb0uci0yrwbxr6x'
[2017-06-16 14:50:31] [ ] [pool02] Starting to clone 'poolvm-y2yxgnovaneymvy'
[2017-06-16 14:50:31] [ ] [pool01] Starting to clone 'poolvm-nur59d25s1y8jko'
...
```
### Common Errors
* Forget to set VMPOOLER_DEBUG environment variable
vmpooler will fail to start with an error similar to below
```
~/vmpooler/ > bundle exec ruby vmpooler
~/vmpooler/lib/vmpooler.rb:44:in `config': Dummy authentication should not be used outside of debug mode; please set environment variable VMPOOLER_DEBUG to 'true' if you want to use dummy authentication (RuntimeError)
from vmpooler:8:in `<main>'
...
```
* Error in vmpooler configuration
If there is an error in the vmpooler configuration file, or any other fatal error in the Pool Manager, vmpooler will appear to be running but no log information is displayed. This is due to the error not being displayed until you press `Ctrl-C` and then suddenly you can see the cause of the issue.
For example, when running vmpooler on Windows, but with a unix style filename for the vmpooler log
```powershell
C:\vmpooler > bundle exec ruby vmpooler
[2017-06-16 14:49:57] starting vmpooler
== Sinatra (v1.4.8) has taken the stage on 4567 for production with backup from Puma
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 3.9.1 (ruby 2.3.1-p112), codename: Private Caller
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://0.0.0.0:4567
Use Ctrl-C to stop
# [ NOTHING ELSE IS LOGGED ]
```
Once `Ctrl-C` is pressed the error is shown
```powershell
...
== Sinatra has ended his set (crowd applauds)
Shutting down.
C:/tools/ruby2.3.1x64/lib/ruby/2.3.0/open-uri.rb:37:in `initialize': No such file or directory @ rb_sysopen - /var/log/vmpooler.log (Errno::ENOENT)
from C:/tools/ruby2.3.1x64/lib/ruby/2.3.0/open-uri.rb:37:in `open'
from C:/tools/ruby2.3.1x64/lib/ruby/2.3.0/open-uri.rb:37:in `open'
from C:/vmpooler/lib/vmpooler/logger.rb:17:in `log'
from C:/vmpooler/lib/vmpooler/pool_manager.rb:709:in `execute!'
from vmpooler:26:in `block in <main>'
```
## Default vmpooler URLs
| Endpoint | URL |
|-----------|----------------------------------------------------------------------|
| Dashboard | [http://localhost:4567/dashboard/](http://localhost:4567/dashboard/) |
| API | [http://localhost:4567/api/v1]([http://localhost:4567/api/v1) |
## Use the vmpooler API locally
Once a local vmpooler instance is running you can use any tool you need to interact with the API. The dummy authentication provider will allow a user to connect if the username and password are not the same:
* Authentication is successful for username `Alice` with password `foo`
* Authentication will fail for username `Alice` with password `Alice`
Like normal vmpooler, tokens will be created for the user and can be used for regular vmpooler operations.

View file

@ -1,45 +0,0 @@
A [Vagrantfile](Vagrantfile) is also included in this repository so that you dont have to run Docker on your local computer.
To use it run:
```
vagrant up
vagrant ssh
docker run -p 8080:4567 -v /vagrant/vmpooler.yaml.example:/var/lib/vmpooler/vmpooler.yaml -it --rm --name pooler vmpooler
```
To run vmpooler with the example dummy provider you can replace the above docker command with this:
```
docker run -e VMPOOLER_DEBUG=true -p 8080:4567 -v /vagrant/vmpooler.yaml.dummy-example:/var/lib/vmpooler/vmpooler.yaml -e VMPOOLER_LOG='/var/log/vmpooler/vmpooler.log' -it --rm --name pooler vmpooler
```
Either variation will allow you to access the dashboard from [localhost:8080](http://localhost:8080/).
### Running directly in Vagrant
You can also run vmpooler directly in the Vagrant box. To do so run this:
```
vagrant up
vagrant ssh
cd /vagrant
# Do this if using the dummy provider
export VMPOOLER_DEBUG=true
cp vmpooler.yaml.dummy-example vmpooler.yaml
# vmpooler needs a redis server.
sudo yum -y install redis
sudo systemctl start redis
# Optional: Choose your ruby version or use jruby
# ruby 2.4.x is used by default
rvm list
rvm use jruby-9.1.7.0
gem install bundler
bundle install
bundle exec ruby vmpooler
```
When run this way you can access vmpooler from your local computer via [localhost:4567](http://localhost:4567/).

6
update-gemfile-lock.sh Executable file
View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
docker run -it --rm \
-v $(pwd):/app \
$(grep ^FROM docker/Dockerfile |cut -d ' ' -f2) \
/bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends make && cd /app && gem install bundler && bundle install --jobs 3 && bundle update; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"'