Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an on-demand single-target sync method
- Adds `target_sync`, a method invoked only via RPC (probably) by an admin API call. That somewhat intelligently replays all the changes from a specific timestamp (serial #) on a given target. - This came about from the following situation: I run N number of nameservers, and I don't want all my zones going to ERROR if I have to take one out of rotation of an emergency. I want to be able to set my threshold percentage at N-1/100, and sync back up all the changes that have happened while I was doing maintenance. Unfortunately, Designate's periodic_recovery, nor periodic_sync would work well for this method. Recovery only fixes ERRORs, and sync simply sends NOTIFYs (and is too deeply entombed in spaghetti code to be dug out) and is run automatically on a set time interval, for a specific number of seconds, for all targets. - Includes a very simple Admin API call that looks like: ```json POST /admin/target_sync { "target_id": "f02a0c72-c701-4ec2-85d7-197b30992ce9", "timestamp": 1454071711 } { "message": "Syncing 79 zones on f02a0c72-c701-4ec2-85d7-197b30992ce9" } ``` Change-Id: I3e3b608049a67b2258cd05d208af46f19df8cbdb
- Loading branch information
1 parent
57c29fd
commit 863bc14
Showing
7 changed files
with
155 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# COPYRIGHT 2015 Rackspace Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import pecan | ||
from oslo_log import log as logging | ||
from oslo_config import cfg | ||
|
||
from designate.api.v2.controllers import rest | ||
from designate import exceptions | ||
|
||
LOG = logging.getLogger(__name__) | ||
CONF = cfg.CONF | ||
|
||
|
||
class TargetSyncController(rest.RestController): | ||
|
||
@staticmethod | ||
def get_path(): | ||
return '.target_sync' | ||
|
||
@pecan.expose(template='json:', content_type='application/json') | ||
def post_all(self): | ||
"""Initialize a Target Syncing""" | ||
request = pecan.request | ||
context = request.environ['context'] | ||
|
||
body = request.body_dict | ||
|
||
fields = ['target_id', 'timestamp'] | ||
for f in fields: | ||
if f not in body: | ||
raise exceptions.BadRequest('Failed to supply correct fields') | ||
|
||
if (not isinstance(body['timestamp'], int) or body['timestamp'] < 0): | ||
raise exceptions.BadRequest( | ||
'Timestamp should be a positive integer') | ||
|
||
pool_id = CONF['service:pool_manager'].pool_id | ||
|
||
return { | ||
'message': self.pool_mgr_api.target_sync(context, pool_id, | ||
body['target_id'], body['timestamp']) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters