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

Revamp configuration loading #270

Merged
merged 17 commits into from
Mar 3, 2017
Merged

Revamp configuration loading #270

merged 17 commits into from
Mar 3, 2017

Conversation

mikz
Copy link
Contributor

@mikz mikz commented Feb 24, 2017

closes #230

Breaking Change

Accidentally previous APIcast would try to lazy load configuration even in the production mode.

That means that newly started APIcast would fetch configuration for service 1.
When receiving request for service 1 it would use the downloaded configuration.
But when receiving configuration of non existing service, it would try to lazy lookup the configuration and it would access the remote API.

This is "fixed" in this branch and when APIcast is in boot mode it won't lazy load configuration, ever.

This could break @3scale/qe workflow when publishing production service and immediately trying production APIcast. Because it would not have to be reloaded in up to 5 minutes.

Environment variables

This PR removes:

  • AUTO_UPDATE_INTERVAL
  • AUTO_UPDATE_INTERVAL
  • AUTO_UPDATE_INTERVAL

And adds:

  • APICAST_CONFIGURATION_CACHE
  • APICAST_CONFIGURATION_LOADER

APICAST_CONFIGURATION_LOADER

Can be set either to boot or lazy.
Boot will load configuration on boot or exit if there are any errors (but empty configuration will work).
Lazy will try to load configuration on incoming request.

APICAST_CONFIGURATION_CACHE

Controls for how long (in seconds) the configuration will be stored. Can be set to 0 for not caching it at all.
Default is empty value which will cache it forever.

@octobot
Copy link

octobot commented Feb 24, 2017

1 Warning
⚠️ Big PR

Proselint found issues

README.md

Line Message Severity

doc/parameters.md

Line Message Severity

Spell Checker found issues

README.md

Line Typo
11 This Dockerfile creates a [3scale](http://www
11 self according to your 3scale params.
32 * THREESCALE_PORTAL_ENDPOINT
32 * THREESCALE_PORTAL_ENDPOINT****
32 * THREESCALE_PORTAL_ENDPOINT****
43 * THREESCALE_CONFIG_FILE
43 * THREESCALE_CONFIG_FILE****
43 * THREESCALE_CONFIG_FILE****
55 vice.json)). The optional APICAST_SERVICES environment variab
55 on)). The optional APICAST_SERVICES**** environment variable allows
82 enable this by adjusting the APICAST_CONFIGURATION_CACHE (seconds)
82 this by adjusting the APICAST**_CONFIGURATION_CACHE** (seconds) to some value
82 ting the APICAST_CONFIGURATION**_CACHE** (seconds) to some value great
82 s) to some value greater than 60:
88 This variable is set to 0 by default.
102 d on NGINX core and including LuaJIT and Lua modules. Follow the [
104 - **LuaRocks** - the
106 For Mac OS X the following **Homebrew** formula can
122 - **redis** in-memory
122 for the OAuth flow require a redis instance running on `localhos
170 l REGISTRY value, defaults to quay.io):

doc/parameters.md

Line Typo
3 APIcast v2 has a number of parameters co
3 variables that can modify the behavior of the gateway. The following
5 e that when deploying APIcast v2 with OpenShift, some of thee
12 Default: **stderr**
17 nfo
17 warn
31 Default: "apicast"
69 Values: a number > **60**
70 Default: 0
72 r. The value should be set to 0 or more than 60. For example,
72 ould be set to 0 or more than 60. For example, if `APICAST_CON
72 ONFIGURATION_CACHE` is set to 120, the gateway will reload the
72 eload the configuration every 2 minutes (120 seconds).
72 onfiguration every 2 minutes (120 seconds).
75 Default: "127.0.0.1"
77 ning Redis instance for OAuth 2.0 flow. REDIS_HOST parameter
80 Default: 6379
82 ning Redis instance for OAuth 2.0 flow. REDIS_PORT parameter
86 pty, the DNS resolver will be autodiscovered.

Spell Checker found issues

README.md

Line Typo
11 This Dockerfile creates a [3scale](http://www
11 self according to your 3scale params.
32 * THREESCALE_PORTAL_ENDPOINT
32 * THREESCALE_PORTAL_ENDPOINT****
32 * THREESCALE_PORTAL_ENDPOINT****
43 * THREESCALE_CONFIG_FILE
43 * THREESCALE_CONFIG_FILE****
43 * THREESCALE_CONFIG_FILE****
55 vice.json)). The optional APICAST_SERVICES environment variab
55 on)). The optional APICAST_SERVICES**** environment variable allows
82 enable this by adjusting the APICAST_CONFIGURATION_CACHE (seconds)
82 this by adjusting the APICAST**_CONFIGURATION_CACHE** (seconds) to some value
82 ting the APICAST_CONFIGURATION**_CACHE** (seconds) to some value great
82 s) to some value greater than 60:
88 This variable is set to 0 by default.
102 d on NGINX core and including LuaJIT and Lua modules. Follow the [
104 - **LuaRocks** - the
106 For Mac OS X the following **Homebrew** formula can
122 - **redis** in-memory
122 for the OAuth flow require a redis instance running on `localhos
170 l REGISTRY value, defaults to quay.io):

doc/parameters.md

Line Typo
3 APIcast v2 has a number of parameters co
3 variables that can modify the behavior of the gateway. The following
5 e that when deploying APIcast v2 with OpenShift, some of thee
12 Default: **stderr**
17 nfo
17 warn
31 Default: "apicast"
69 Values: a number > **60**
70 Default: 0
72 r. The value should be set to 0 or more than 60. For example,
72 ould be set to 0 or more than 60. For example, if `APICAST_CON
72 ONFIGURATION_CACHE` is set to 120, the gateway will reload the
72 eload the configuration every 2 minutes (120 seconds).
72 onfiguration every 2 minutes (120 seconds).
75 Default: "127.0.0.1"
77 ning Redis instance for OAuth 2.0 flow. REDIS_HOST parameter
80 Default: 6379
82 ning Redis instance for OAuth 2.0 flow. REDIS_PORT parameter
86 pty, the DNS resolver will be autodiscovered.

Generated by 🚫 Danger

@@ -16,9 +15,18 @@ local mt = { __index = _M }

function _M.new()
return setmetatable({
-- services hashed by id, example: {
-- ["16"] = service1
-- }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of comments are very helpful :) 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Wanted to do it just for sake of having it written when I was changing the data structure :)
Will try to do that more in complicated cases.

@mikz mikz force-pushed the revamp-configuration branch 3 times, most recently from e24d78e to 6bdd136 Compare February 24, 2017 11:45
@mikz mikz removed the in progress label Feb 28, 2017
@mikz mikz force-pushed the revamp-configuration branch from e6db6c5 to 1cbc85b Compare March 2, 2017 12:43
@jcechace
Copy link

jcechace commented Mar 2, 2017

Generally speaking we should be fine with the configuration not being immediate as long as there is a mechanism to trigger the immediate reload manually -- waiting up to 5 minutes for the configuration to be reloaded doesn't really make sense in tests.

I will let @mijaros confirm this since I'm still a bit out of picture after rejoining the team. though

@mikz
Copy link
Contributor Author

mikz commented Mar 2, 2017

Ok. We could:

  • trigger reload by calling POST /boot on the management api (would not work with multiple Pods though)
  • set lower refresh rate
  • trigger deploy on OpenShift

@mikz mikz force-pushed the revamp-configuration branch from 1cbc85b to 01877bc Compare March 2, 2017 18:09
mikz added 4 commits March 2, 2017 19:18
rather return stale configuration than nothing
if services takes longer than expected to refresh it
is better to return stale config than an error
mikz added 2 commits March 3, 2017 08:25
wait for up to 15 seconds to load configuration for the same host
@mikz mikz added this to the On-premise ER4 release milestone Mar 3, 2017
@mikz mikz added the B-current label Mar 3, 2017
@mikz mikz merged commit cf840cc into master Mar 3, 2017
@mikz mikz deleted the revamp-configuration branch March 3, 2017 07:50
@mikz mikz mentioned this pull request Mar 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revamp APIcast configuration loading
4 participants