def create_policy_pod(hostname, owner, token):
def _create_pod():
if db.session.query(Pod).filter_by(
name=KUBERDOCK_POLICY_POD_NAME, owner=owner).first():
return True
try:
policy_conf = get_policy_agent_config(MASTER_IP, token)
check_internal_pod_data(policy_conf, owner)
policy_pod = PodCollection(owner).add(policy_conf, skip_check=True)
PodCollection(owner).update(policy_pod['id'],
{'command': 'synchronous_start'})
return True
except (IntegrityError, APIError):
# Either pod already exists or an error occurred during it's
# creation - log and retry
current_app.logger.exception(
'During "{}" node creation tried to create a Network Policy '
'service pod but got an error.'.format(hostname))
return retry(_create_pod, 1, 5, exc=APIError('Could not create Network '
'Policy service POD'))
评论列表
文章目录