Skip to content
Merged
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
29 changes: 18 additions & 11 deletions docker_images/configurator/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pika.exceptions
import yaml
import etcd
import botocore
import boto3
from boto3.session import Config as BotoConfig
from sqlalchemy import create_engine
Expand All @@ -17,9 +18,9 @@


ETCD_KEYS_TO_DELETE = [
"/logstash_host",
"/optscale_meter_enabled",
"/opentelemetry",
("/logstash_host", False),
("/optscale_meter_enabled", False),
("/opentelemetry", True),
]
RETRY_ARGS = dict(stop_max_attempt_number=300, wait_fixed=500)
RABBIT_PRECONDIFITON_FAILED_CODE = 406
Expand Down Expand Up @@ -134,11 +135,14 @@ def pre_configure(self):
self.commit_config()
return
logger.info("Writing default etcd keys")
for key in ETCD_KEYS_TO_DELETE:
for (key, is_dir) in ETCD_KEYS_TO_DELETE:
try:
logger.debug("Deleting key %s from etc", key)
self.etcd_cl.delete(key)
except etcd.EtcdKeyNotFound:
if is_dir:
self.etcd_cl.delete(key, dir=True, recursive=True)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are we sure both dir and recursive must be passed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, at first added only dir=True and it failed.
etcd client library has not the best implementation, if we could switch to etcd3 life would be easier

else:
self.etcd_cl.delete(key)
except (etcd.EtcdKeyNotFound, etcd.EtcdNotFile):
pass
self.etcd_cl.write_branch("/", config, overwrite_lists=True)
logger.info("Configuring database server")
Expand Down Expand Up @@ -256,11 +260,14 @@ def configure_gemini(self):
}
]
}
self.s3_client.put_bucket_lifecycle_configuration(
Bucket=bucket_name,
LifecycleConfiguration=lifecycle_config,
)
logger.info('Gemini bucket lifecycle configuration updated')
try:
self.s3_client.put_bucket_lifecycle_configuration(
Bucket=bucket_name,
LifecycleConfiguration=lifecycle_config,
)
logger.info('Gemini bucket lifecycle configuration updated')
except botocore.exceptions.ClientError as e:
logger.warning('Failed to update Gemini bucket lifecycle configuration: %s', e)


if __name__ == "__main__":
Expand Down
Loading