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

check_http and integrate into apache::vhost #1

Closed
7 tasks done
DavidS opened this issue Apr 7, 2021 · 6 comments
Closed
7 tasks done

check_http and integrate into apache::vhost #1

DavidS opened this issue Apr 7, 2021 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@DavidS
Copy link
Contributor

DavidS commented Apr 7, 2021

check_http checks a HTTP or HTTPS endpoint for its status. To avoid false failures because of network issues (or delays in the service starting up) requests get retried a configurable amount of time until a good result is received.

  • Update the check_http type to have the following attributes:
  • url, namevar, String: the URL to test, allows http and https requests
  • headers, parameter, Hash[String, String]: a hash of headers to pass along with the request, defaults to {}
  • expected_statuses, parameter, Array[Integer]: an array of acceptable HTTP status codes. If a request returns one of these status codes, it is considered a success. Defaults to [200]
  • body_matcher, parameter, Regexp: a request is considered a success if the body of the HTTP response matches this regular expression. Defaults to //
  • request_timeout, parameter, Numeric: number of seconds for a single request to wait for a response to return a success before aborting, defaults to 10
  • retries, parameter, Integer: number of requests to make before giving up, defaults to 3
  • backoff, parameter, Numeric: initial number of seconds to wait between requests, defaults to 1
  • exponential_backoff_base, parameter, Numeric: exponential base for the exponential backoff calculations, defaults to 2
  • max_backoff, parameter, Numeric: an upper limit to the backoff duration, defaults to 10
  • timeout, parameter, Numeric: number of seconds allocated overall for the check to return a success before giving up, defaults to 60
  • Update the check_http provider to use the insync? feature from Allow custom insync? checking for resources puppet-resource_api#225 to be quiet (in sync) when the check succeeds, and report a regular error otherwise. See a7f60f2 for an example.

  • Update the check_http provider to use the above attributes to execute up to retries number of times with success being defined as having one of the expected_statuses and the body of the response matches body_matcher while taking into account request_timeout.

  • Update the check_http provider to wait for backoff ** (exponential_backoff_base * (number_of_attempt - 1) seconds between attempts (up to max_backoff), but aborting completely after timeout seconds if no successful request could be made. Evaluate https://github.com/kamui/retriable for this.

  • Update the check_http provider to log detailed messages at the debug level of requests, responses and backoff waits.

  • Add unit tests for check_http provider changes

  • Update Opv puppetlabs-apache#2128 to use this resource for checking a configured vhost for correct deployment. Do not merge that PR as this is still experimental work.

Each change needs to be accompanied with appropriate unit and (changes to) acceptance tests proving the functionality.

@sheenaajay
Copy link
Contributor

Updated the check_http type with the required attributes.

@sheenaajay
Copy link
Contributor

Update the check_http provider to use the insync? feature for url attribute.

sheenaajay added a commit to sheenaajay/opv that referenced this issue May 18, 2021
@sheenaajay
Copy link
Contributor

Updated the check_http provider with retry code, reusing the existing https://github.com/kamui/retriable gem

@sheenaajay
Copy link
Contributor

Updated the check_http provider with debug messages

@sheenaajay
Copy link
Contributor

Updated the unit tests to test retry mechanism, success, failure conditions

@sheenaajay
Copy link
Contributor

Update the vhosts.pp for apache module
Notice: Compiled catalog for alkaline-notion.delivery.puppetlabs.net in environment production in 1.08 seconds Info: Applying configuration version '1623768785' Notice: /Stage[main]/Apache/File[/etc/apache2/sites-available/25-first.example.com.conf]/ensure: removed Info: /etc/apache2/sites-available: Scheduling refresh of Class[Apache::Service] Notice: /Stage[main]/Apache/File[/etc/apache2/sites-enabled/25-first.example.com.conf]/ensure: removed Info: /etc/apache2/sites-enabled: Scheduling refresh of Class[Apache::Service] Notice: /Stage[main]/Apache::Mod::Rewrite/Apache::Mod[rewrite]/File[rewrite.load symlink]/ensure: created Info: /Stage[main]/Apache::Mod::Rewrite/Apache::Mod[rewrite]/File[rewrite.load symlink]: Scheduling refresh of Class[Apache::Service] Info: check_http: The base_interval is '0' and retrying for '1' time Info: check_http: The return response '200' is matching with the expected_statuses '[200]' Info: check_http: The return response body 'Hello from vhost ' is matching with body_matcher '(?-mix:).to_s' Info: check_http: Successfully connected to 'http://test.server' Notice: /Stage[main]/Main/Apache::Vhost[test.server]/Concat[25-test.server.conf]/File[/etc/apache2/sites-available/25-test.server.conf]/ensure: defined content as '{sha256}0f6ddf836c82982b357187bdb2044bc0e44419c2208c2e207bdebe4933f56275' Info: Concat[25-test.server.conf]: Scheduling refresh of Class[Apache::Service] Notice: /Stage[main]/Main/Apache::Vhost[test.server]/File[25-test.server.conf symlink]/ensure: created Info: /Stage[main]/Main/Apache::Vhost[test.server]/File[25-test.server.conf symlink]: Scheduling refresh of Class[Apache::Service] Info: Class[Apache::Service]: Scheduling refresh of Service[httpd] Notice: /Stage[main]/Apache::Service/Service[httpd]: Triggered 'refresh' from 1 event Notice: Applied catalog in 1.11 seconds root@alkaline-notion:~#

DavidS added a commit that referenced this issue Jun 30, 2021
(#1) update check_http provider and type with new attributes
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

No branches or pull requests

2 participants