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

Format with black -l 120 . #199

Merged
merged 1 commit into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 56 additions & 55 deletions fiaas_deploy_daemon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ def configure(self, bind):
def provide_session(self, config):
session = requests.Session()
if config.proxy:
session.proxies = {scheme: config.proxy for scheme in (
"http",
"https"
)}
session.proxies = {scheme: config.proxy for scheme in ("http", "https")}
if config.debug:
session.hooks["response"].append(log_request_response)
return session
Expand All @@ -76,12 +73,14 @@ def __init__(self, deployer, scheduler, crd_watcher, usage_reporter):
pass

def is_healthy(self):
return all((
self._deployer.is_alive(),
self._scheduler.is_alive(),
self._crd_watcher.is_alive(),
self._usage_reporter.is_alive(),
))
return all(
(
self._deployer.is_alive(),
self._scheduler.is_alive(),
self._crd_watcher.is_alive(),
self._usage_reporter.is_alive(),
)
)


class Main(object):
Expand Down Expand Up @@ -138,58 +137,60 @@ def warn_if_env_variable_config(config, log):
"""temporary deprecation warning for https://github.com/fiaas/fiaas-deploy-daemon/issues/12"""

configuration_env_variable_keys = {
'SECRETS_DIRECTORY',
'LOG_FORMAT',
'http_proxy',
'DEBUG',
'FIAAS_ENVIRONMENT',
'FIAAS_SERVICE_TYPE',
'FIAAS_INFRASTRUCTURE',
'PORT',
'ENABLE_CRD_SUPPORT',
'SECRETS_INIT_CONTAINER_IMAGE',
'SECRETS_SERVICE_ACCOUNT_NAME',
'DATADOG_CONTAINER_IMAGE',
'DATADOG_CONTAINER_MEMORY',
'FIAAS_DATADOG_GLOBAL_TAGS',
'PRE_STOP_DELAY',
'STRONGBOX_INIT_CONTAINER_IMAGE',
'ENABLE_DEPRECATED_MULTI_NAMESPACE_SUPPORT',
'USE_INGRESS_TLS',
'TLS_CERTIFICATE_ISSUER',
'USE_IN_MEMORY_EMPTYDIRS',
'DEPLOYMENT_MAX_SURGE',
'DEPLOYMENT_MAX_UNAVAILABLE',
'READY_CHECK_TIMEOUT_MULTIPLIER',
'DISABLE_DEPRECATED_MANAGED_ENV_VARS',
'USAGE_REPORTING_CLUSTER_NAME',
'USAGE_REPORTING_OPERATOR',
'USAGE_REPORTING_ENDPOINT',
'USAGE_REPORTING_TENANT',
'USAGE_REPORTING_TEAM',
'API_SERVER',
'API_TOKEN',
'API_CERT',
'CLIENT_CERT',
'CLIENT_KEY',
'INGRESS_SUFFIXES',
'HOST_REWRITE_RULES',
'FIAAS_GLOBAL_ENV',
'FIAAS_SECRET_INIT_CONTAINERS',
"SECRETS_DIRECTORY",
"LOG_FORMAT",
"http_proxy",
"DEBUG",
"FIAAS_ENVIRONMENT",
"FIAAS_SERVICE_TYPE",
"FIAAS_INFRASTRUCTURE",
"PORT",
"ENABLE_CRD_SUPPORT",
"SECRETS_INIT_CONTAINER_IMAGE",
"SECRETS_SERVICE_ACCOUNT_NAME",
"DATADOG_CONTAINER_IMAGE",
"DATADOG_CONTAINER_MEMORY",
"FIAAS_DATADOG_GLOBAL_TAGS",
"PRE_STOP_DELAY",
"STRONGBOX_INIT_CONTAINER_IMAGE",
"ENABLE_DEPRECATED_MULTI_NAMESPACE_SUPPORT",
"USE_INGRESS_TLS",
"TLS_CERTIFICATE_ISSUER",
"USE_IN_MEMORY_EMPTYDIRS",
"DEPLOYMENT_MAX_SURGE",
"DEPLOYMENT_MAX_UNAVAILABLE",
"READY_CHECK_TIMEOUT_MULTIPLIER",
"DISABLE_DEPRECATED_MANAGED_ENV_VARS",
"USAGE_REPORTING_CLUSTER_NAME",
"USAGE_REPORTING_OPERATOR",
"USAGE_REPORTING_ENDPOINT",
"USAGE_REPORTING_TENANT",
"USAGE_REPORTING_TEAM",
"API_SERVER",
"API_TOKEN",
"API_CERT",
"CLIENT_CERT",
"CLIENT_KEY",
"INGRESS_SUFFIXES",
"HOST_REWRITE_RULES",
"FIAAS_GLOBAL_ENV",
"FIAAS_SECRET_INIT_CONTAINERS",
}
environ_keys = set(os.environ.keys())
possible_config_env_variables = sorted(configuration_env_variable_keys & environ_keys)
if len(possible_config_env_variables) > 0:
log.warn("found configuration environment variables %s. The ability to configure fiaas-deploy-daemon via environment variables " +
"has been removed. If you are trying to use these environment variables to configure fiaas-deploy-daemon, " +
"that configuration will not take effect. Please switch to configuring via a config file/ConfigMap or command-line " +
"flags. See https://github.com/fiaas/fiaas-deploy-daemon/issues/12 for more information.",
', '.join(possible_config_env_variables))
log.warn(
"found configuration environment variables %s. The ability to configure fiaas-deploy-daemon via environment variables "
+ "has been removed. If you are trying to use these environment variables to configure fiaas-deploy-daemon, "
+ "that configuration will not take effect. Please switch to configuring via a config file/ConfigMap or command-line "
+ "flags. See https://github.com/fiaas/fiaas-deploy-daemon/issues/12 for more information.",
", ".join(possible_config_env_variables),
)


def expose_fdd_version(config):
i = Info('fiaas_fdd_version', 'The tag of the running fiaas-deploy-daemon docker image.')
i.info({'fiaas_fdd_version': config.version})
i = Info("fiaas_fdd_version", "The tag of the running fiaas-deploy-daemon docker image.")
i.info({"fiaas_fdd_version": config.version})


def main():
Expand Down
1 change: 1 addition & 0 deletions fiaas_deploy_daemon/base_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8

import logging

# Copyright 2017-2019 The FIAAS Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
7 changes: 2 additions & 5 deletions fiaas_deploy_daemon/bootstrap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ def configure(self, bind):
def provide_session(self, config):
session = requests.Session()
if config.proxy:
session.proxies = {scheme: config.proxy for scheme in (
"http",
"https"
)}
session.proxies = {scheme: config.proxy for scheme in ("http", "https")}
return session


Expand Down Expand Up @@ -88,5 +85,5 @@ def main():
sys.exit(1)


if __name__ == '__main__':
if __name__ == "__main__":
main()
56 changes: 34 additions & 22 deletions fiaas_deploy_daemon/bootstrap/bootstrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ def __init__(self):
def store_status(self, status, app_name, namespace):
with self._statuses_lock:
self._statuses[(app_name, namespace)] = status
LOG.info("Received {status} for {name} in namespace {namespace}".format(status=status, name=app_name,
namespace=namespace))
LOG.info(
"Received {status} for {name} in namespace {namespace}".format(
status=status, name=app_name, namespace=namespace
)
)

def values(self):
with self._statuses_lock:
Expand All @@ -67,19 +70,22 @@ def __init__(self, config, deploy_queue, spec_factory, lifecycle):
self._resource_class = FiaasApplication
from ..crd.status import connect_signals
else:
raise InvalidConfigurationException(
"Custom Resource Definition support must be enabled when bootstrapping")
raise InvalidConfigurationException("Custom Resource Definition support must be enabled when bootstrapping")
connect_signals()
signal(DEPLOY_STATUS_CHANGED).connect(self._store_status)

def run(self):
for application in self._resource_class.find(name=None, namespace=self._namespace,
labels={"fiaas/bootstrap": "true"}):
for application in self._resource_class.find(
name=None, namespace=self._namespace, labels={"fiaas/bootstrap": "true"}
):
try:
self._deploy(application)
except BaseException:
LOG.exception("Caught exception when deploying {name} in namespace {namespace}".format(
name=application.metadata.name, namespace=application.metadata.namespace))
LOG.exception(
"Caught exception when deploying {name} in namespace {namespace}".format(
name=application.metadata.name, namespace=application.metadata.namespace
)
)
raise

return self._wait_for_readiness(wait_time_seconds=5, timeout_seconds=120)
Expand All @@ -88,20 +94,25 @@ def _deploy(self, application):
LOG.debug("Deploying %s", application.spec.application)
try:
deployment_id = application.metadata.labels["fiaas/deployment_id"]
set_extras(app_name=application.spec.application,
namespace=application.metadata.namespace,
deployment_id=deployment_id)
set_extras(
app_name=application.spec.application,
namespace=application.metadata.namespace,
deployment_id=deployment_id,
)
except (AttributeError, KeyError, TypeError):
raise ValueError("The Application {} is missing the 'fiaas/deployment_id' label".format(
application.spec.application))
raise ValueError(
"The Application {} is missing the 'fiaas/deployment_id' label".format(application.spec.application)
)

lifecycle_subject = self._lifecycle.initiate(uid=application.metadata.uid,
app_name=application.spec.application,
namespace=application.metadata.namespace,
deployment_id=deployment_id,
repository=None,
labels=application.spec.additional_labels.status,
annotations=application.spec.additional_annotations.status)
lifecycle_subject = self._lifecycle.initiate(
uid=application.metadata.uid,
app_name=application.spec.application,
namespace=application.metadata.namespace,
deployment_id=deployment_id,
repository=None,
labels=application.spec.additional_labels.status,
annotations=application.spec.additional_annotations.status,
)

try:
app_spec = self._spec_factory(
Expand All @@ -118,8 +129,9 @@ def _deploy(self, application):
)
self._store_status(None, DEPLOY_SCHEDULED, lifecycle_subject)
self._deploy_queue.put(DeployerEvent("UPDATE", app_spec, lifecycle_subject))
LOG.debug("Queued deployment for %s in namespace %s", application.spec.application,
application.metadata.namespace)
LOG.debug(
"Queued deployment for %s in namespace %s", application.spec.application, application.metadata.namespace
)
except (YAMLError, InvalidConfiguration):
self._lifecycle.failed(lifecycle_subject)
raise
Expand Down
Loading