Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

Commit

Permalink
Merge pull request #88 from djosborne/catch-etcd-exceptions
Browse files Browse the repository at this point in the history
Added etcd connection error catcher to all ipam functions
  • Loading branch information
djosborne committed Feb 22, 2016
2 parents 4702169 + 0891e01 commit c3c3b44
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions calico_containers/pycalico/ipam.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import logging
import random

from pycalico.datastore import handle_errors
from pycalico.datastore_datatypes import IPPool
from pycalico.datastore import DatastoreClient
from pycalico.datastore import (IPAM_HOST_AFFINITY_PATH,
Expand Down Expand Up @@ -51,6 +52,7 @@ class BlockHandleReaderWriter(DatastoreClient):
class.
"""

@handle_errors
def _read_block(self, block_cidr):
"""
Read the block from the data store.
Expand All @@ -68,6 +70,7 @@ def _read_block(self, block_cidr):
block = AllocationBlock.from_etcd_result(result)
return block

@handle_errors
def _compare_and_swap_block(self, block):
"""
Write the block using an atomic Compare-and-swap.
Expand All @@ -89,6 +92,7 @@ def _compare_and_swap_block(self, block):
except EtcdAlreadyExist:
raise CASError(str(block.cidr))

@handle_errors
def _get_affine_blocks(self, host, version, pool):
"""
Get the blocks for which this host has affinity.
Expand Down Expand Up @@ -121,6 +125,7 @@ def _get_affine_blocks(self, host, version, pool):

return block_ids

@handle_errors
def _new_affine_block(self, host, version, pool):
"""
Create and register a new affine block for the host.
Expand Down Expand Up @@ -160,6 +165,7 @@ def _new_affine_block(self, host, version, pool):
return block_cidr
raise NoFreeBlocksError()

@handle_errors
def _claim_block_affinity(self, host, block_cidr):
"""
Claim a block we think is free.
Expand Down Expand Up @@ -294,6 +300,7 @@ def _decrement_handle(self, handle_id, block_cidr, amount):
return
raise RuntimeError("Max retries hit.") # pragma: no cover

@handle_errors
def _read_handle(self, handle_id):
"""
Read the handle with the given handle ID from the data store.
Expand All @@ -308,6 +315,7 @@ def _read_handle(self, handle_id):
handle = AllocationHandle.from_etcd_result(result)
return handle

@handle_errors
def _compare_and_swap_handle(self, handle):
"""
Write the handle using an atomic Compare-and-swap.
Expand Down

0 comments on commit c3c3b44

Please sign in to comment.