From 45cc4b778860f1be34612ca4420d5ee148da00ca Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 23 Apr 2021 11:09:35 -0400 Subject: [PATCH] Add documentation syncfiles examples Also, check to make sure a syncfiles has actual work to do before triggering a greenthread and the client to start polling. --- confluent_osdeploy/el7/profiles/default/syncfiles | 13 +++++++++++++ confluent_osdeploy/el8/profiles/default/syncfiles | 13 +++++++++++++ confluent_server/confluent/syncfiles.py | 8 +++++--- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 confluent_osdeploy/el7/profiles/default/syncfiles create mode 100644 confluent_osdeploy/el8/profiles/default/syncfiles diff --git a/confluent_osdeploy/el7/profiles/default/syncfiles b/confluent_osdeploy/el7/profiles/default/syncfiles new file mode 100644 index 00000000..d8283e3e --- /dev/null +++ b/confluent_osdeploy/el7/profiles/default/syncfiles @@ -0,0 +1,13 @@ +# This file lists files to synchronize or merge to the deployed systems from the deployment server +# To specify taking /some/path/hosts on the deploymennt server and duplicating it to /etc/hosts: +# /some/path/hosts -> /etc/hosts + +# If wanting to simply use the same path for source and destinaiton, the -> may be skipped: +# /etc/hosts + +# Entries under MERGE will attempt to be intelligently merged. This supports /etc/group and /etc/passwd +# Any supporting entries in /etc/shadow or /etc/gshadow are added automatically, with password disabled +# It also will not inject 'system' ids (under 1,000 usually) as those tend to be local and rpm managed. +MERGE: +# /etc/passwd +# /etc/group diff --git a/confluent_osdeploy/el8/profiles/default/syncfiles b/confluent_osdeploy/el8/profiles/default/syncfiles new file mode 100644 index 00000000..d8283e3e --- /dev/null +++ b/confluent_osdeploy/el8/profiles/default/syncfiles @@ -0,0 +1,13 @@ +# This file lists files to synchronize or merge to the deployed systems from the deployment server +# To specify taking /some/path/hosts on the deploymennt server and duplicating it to /etc/hosts: +# /some/path/hosts -> /etc/hosts + +# If wanting to simply use the same path for source and destinaiton, the -> may be skipped: +# /etc/hosts + +# Entries under MERGE will attempt to be intelligently merged. This supports /etc/group and /etc/passwd +# Any supporting entries in /etc/shadow or /etc/gshadow are added automatically, with password disabled +# It also will not inject 'system' ids (under 1,000 usually) as those tend to be local and rpm managed. +MERGE: +# /etc/passwd +# /etc/group diff --git a/confluent_server/confluent/syncfiles.py b/confluent_server/confluent/syncfiles.py index 6532ae52..977c4de1 100644 --- a/confluent_server/confluent/syncfiles.py +++ b/confluent_server/confluent/syncfiles.py @@ -69,11 +69,10 @@ class SyncList(object): currmap[k] = v -def sync_list_to_node(synclist, node, suffixes): +def sync_list_to_node(sl, node, suffixes): targdir = tempfile.mkdtemp('.syncto{}'.format(node)) output = '' try: - sl = SyncList(synclist) for ent in sl.replacemap: stage_ent(sl.replacemap, ent, targdir) if 'append' in suffixes: @@ -144,8 +143,11 @@ def start_syncfiles(nodename, cfg, suffixes): synclist = '/var/lib/confluent/public/os/{}/syncfiles'.format(profile) if not os.path.exists(synclist): return '200 OK' # not running + sl = SyncList(synclist) + if not (sl.appendmap or sl.mergemap or sl.replacemap): + return '200 OK' # the synclist has no actual entries syncrunners[nodename] = eventlet.spawn( - sync_list_to_node, synclist, nodename, suffixes) + sync_list_to_node, sl, nodename, suffixes) return '202 Queued' # backgrounded def get_syncresult(nodename):