@@ -64,8 +64,6 @@ def validate(phase: str):
6464 @staticmethod
6565 def post_install (conf : MappedConf ):
6666 """Performs post install operations."""
67-
68- Log .info ('PostInstall phase completed.' )
6967 return 0
7068
7169 @staticmethod
@@ -88,8 +86,6 @@ def prepare(conf: MappedConf):
8886 except Exception as e :
8987 raise SetupError (errno .EINVAL , f'Error ocurred while fetching node ip, { e } ' )
9088
91- Log .info ('Prepare phase completed.' )
92-
9389 return 0
9490
9591 @staticmethod
@@ -102,7 +98,7 @@ def config(conf: MappedConf):
10298 if not os .path .exists (config_file ):
10399 raise SetupError (errno .EINVAL , f'"{ config_file } " config file is not present.' )
104100
105- # Validate resouce limit values
101+ # Validate resource limit values
106102 Rgw ._validate_resource_limit_values (conf )
107103
108104 # Create ssl certificate
@@ -129,22 +125,19 @@ def config(conf: MappedConf):
129125 # Try HAX endpoint from data pod of same node first & if it doesnt work,
130126 # from other data pods in cluster
131127 Rgw ._update_hax_endpoint_and_create_admin (conf )
132- Log .info ('Config phase completed.' )
133-
134128
135129 return 0
136130
137131 @staticmethod
138132 def start (conf : MappedConf , index : str ):
139133 """Create rgw admin user and start rgw service."""
140134
141- Log .info (f'Configure logrotate for { const .COMPONENT_NAME } at path: { const .LOGROTATE_CONF } ' )
142135 Rgw ._logrotate_generic (conf )
143136
144137 # Before starting service,Verify backend store value=motr in rgw config file.
145138 Rgw ._verify_backend_store_value (conf )
146139
147- # Create motr trace & addb stob dirctory .
140+ # Create motr trace & addb stob directory .
148141 # Collect fid value of motr to create addb value.
149142 config_file = Rgw ._get_rgw_config_path (conf )
150143 confstore_url = const .CONFSTORE_FILE_HANDLER + config_file
@@ -172,21 +165,18 @@ def start(conf: MappedConf, index: str):
172165 def init (conf : MappedConf ):
173166 """Perform initialization."""
174167
175- Log .info ('Init phase completed.' )
176168 return 0
177169
178170 @staticmethod
179171 def test (conf : MappedConf , plan : str ):
180172 """Perform configuration testing."""
181173
182- Log .info ('Test phase completed.' )
183174 return 0
184175
185176 @staticmethod
186177 def reset (conf : MappedConf ):
187178 """Remove/Delete all the data/logs that was created by user/testing."""
188179
189- Log .info ('Reset phase completed.' )
190180 return 0
191181
192182 @staticmethod
@@ -195,7 +185,7 @@ def cleanup(conf: MappedConf, pre_factory: bool = False):
195185 config_path = Rgw ._get_rgw_config_path (conf )
196186 if os .path .exists (config_path ):
197187 os .remove (config_path )
198- Log . info ( 'Cleanup phase completed.' )
188+
199189 return 0
200190
201191 @staticmethod
@@ -273,7 +263,6 @@ def upgrade(conf: MappedConf, changeset_path: str):
273263 except Exception as e :
274264 raise SetupError (errno .EINVAL , f'Upgrade failed with error: { e } ' )
275265
276- Log .info ('Upgrade phase completed.' )
277266 return 0
278267
279268 @staticmethod
@@ -282,7 +271,7 @@ def _create_svc_config(conf: MappedConf):
282271 svc_name = Rgw ._get_svc_name (conf )
283272
284273 client_instance_count = Rgw ._get_num_client_instances (conf , svc_name )
285- Log .info ('fetching endpoint values from hctl fetch-fids cmd.' )
274+ Log .info ('Fetching endpoint values from hctl fetch-fids cmd.' )
286275 # For running rgw service and radosgw-admin tool,
287276 # we are using same endpoints fetched from hctl fetch-fids cmd as default endpoints,
288277 # given radosgw-admin tool & rgw service not expected to run simultaneously.
@@ -292,7 +281,7 @@ def _create_svc_config(conf: MappedConf):
292281 while instance <= client_instance_count :
293282 service_endpoints = Rgw ._parse_endpoint_values (
294283 conf , instance , client_instance_count , svc_name )
295- Rgw ._validate_endpoint_paramters (service_endpoints )
284+ Rgw ._validate_endpoint_parameters (service_endpoints )
296285
297286 Rgw ._update_rgw_config_with_endpoints (conf , service_endpoints , instance )
298287 instance = instance + 1
@@ -304,7 +293,6 @@ def _create_svc_config(conf: MappedConf):
304293 # Before user creation,Verify backend store value=motr in rgw config file.
305294 Rgw ._verify_backend_store_value (conf )
306295
307- Log .info (f'Configure logrotate for { const .COMPONENT_NAME } at path: { const .LOGROTATE_CONF } ' )
308296 Rgw ._logrotate_generic (conf )
309297
310298 @staticmethod
@@ -355,7 +343,7 @@ def _fetch_consul_endpoint_url(conf: MappedConf, endpoint_type: str):
355343 consul_endpoints ))
356344 if len (endpoints_value ) == 0 :
357345 raise SetupError (errno .EINVAL ,
358- f'{ endpoint_type } endpoint is not specified in the conf .'
346+ f'{ endpoint_type } endpoint is not specified in the GConf .'
359347 f' Listed endpoints: { consul_endpoints } ' )
360348 return endpoints_value
361349
@@ -435,6 +423,7 @@ def _create_rgw_user(conf: MappedConf):
435423 retry_count = 0
436424 rc = - 1
437425 while (retry_count < const .USER_CREATION_MAX_RETRY_COUNT ):
426+ Log .info (f'Creating admin user, command : { create_usr_cmd } .' )
438427 _ , err , rc , = SimpleProcess (create_usr_cmd ).run (timeout = const .ADMIN_CREATION_TIMEOUT )
439428 if rc == 0 :
440429 Log .info (f'RGW admin user { user_name } is created.' )
@@ -542,7 +531,7 @@ def _get_service_port(conf: MappedConf, protocol: str):
542531 return port
543532
544533 @staticmethod
545- def _validate_endpoint_paramters (endpoints : dict ):
534+ def _validate_endpoint_parameters (endpoints : dict ):
546535 """Validate endpoint values fetched from hctl fetch-fids cmd."""
547536
548537 for key , _ in const .RgwEndpoint .__members__ .items ():
@@ -560,7 +549,7 @@ def _validate_hctl_cmd_response(decoded_out: list, svc_name: str):
560549 try :
561550 next (endpoint for endpoint in decoded_out if endpoint ['name' ] == svc_name )
562551 except StopIteration :
563- raise SetupError (errno .EINVAL , 'Invalid %s endpoint values' , svc_name )
552+ raise SetupError (errno .EINVAL , 'Invalid %s endpoint values' % svc_name )
564553
565554 @staticmethod
566555 def _get_hare_config_path (conf : MappedConf ):
@@ -636,18 +625,19 @@ def _generate_ssl_cert(conf: MappedConf):
636625 @staticmethod
637626 def _update_hax_endpoint (conf : MappedConf , data_pod_hostname : str ):
638627 """Update hax endpoint values in rgw config file."""
639- Log .info ('Reading motr_ha_endpoint from data pod' )
640628
641629 if not data_pod_hostname :
642- raise SetupError (errno .EINVAL , 'Invalid data pod hostname: %s' , data_pod_hostname )
630+ raise SetupError (errno .EINVAL , 'Invalid data pod hostname: %s' % data_pod_hostname )
631+
632+ Log .info (f'Reading motr_ha_endpoint from { data_pod_hostname } ' )
643633
644634 hare_config_dir = Rgw ._get_hare_config_path (conf )
645635 fetch_fids_cmd = f'hctl fetch-fids -c { hare_config_dir } --node { data_pod_hostname } '
646636 decoded_out = Rgw ._run_fetch_fid_cmd (fetch_fids_cmd , data_pod_hostname )
647637 Rgw ._validate_hctl_cmd_response (decoded_out , 'hax' )
648638 motr_ha_endpoint = [endpoints ['ep' ] for endpoints in decoded_out \
649639 if 'hax' in endpoints .values ()][0 ]
650- Log .info (f'Fetched motr_ha_endpoint from data pod . Endpoint: { motr_ha_endpoint } ' )
640+ Log .info (f'Fetched motr_ha_endpoint from { data_pod_hostname } . Endpoint: { motr_ha_endpoint } ' )
651641
652642 config_path = Rgw ._get_rgw_config_path (conf )
653643 confstore_url = const .CONFSTORE_FILE_HANDLER + config_path
@@ -664,13 +654,10 @@ def _run_fetch_fid_cmd(fetch_fids_cmd: str, data_pod_hostname: str = None):
664654 out , err , rc = SimpleProcess (fetch_fids_cmd ).run ()
665655 if rc != 0 :
666656 if data_pod_hostname :
667- Log .error (f'Unable to read fid information for hostname: '
668- f'{ data_pod_hostname } . { err } ' )
669657 raise SetupError (rc , 'Unable to read fid information for hostname: '
670- '%s. %s' , data_pod_hostname , err )
658+ '%s. %s' % ( data_pod_hostname , err ) )
671659 else :
672- Log .error (f'Unable to read fid information. { err } ' )
673- raise SetupError (rc , 'Unable to read fid information. %s' , err )
660+ raise SetupError (rc , 'Unable to read fid information. %s' % err )
674661
675662 decoded_out = json .loads (out .decode (const .UTF_ENCODING ))
676663
@@ -680,7 +667,6 @@ def _run_fetch_fid_cmd(fetch_fids_cmd: str, data_pod_hostname: str = None):
680667 def _create_admin_on_current_node (conf : MappedConf , current_data_node : str ):
681668 try :
682669 Rgw ._update_hax_endpoint (conf , current_data_node )
683- Log .info ('Creating admin user.' )
684670 # Before creating user check if user is already created.
685671 user_status = Rgw ._create_rgw_user (conf )
686672 return user_status
@@ -706,7 +692,7 @@ def _update_hax_endpoint_and_create_admin(conf: MappedConf):
706692 # Check for rgw_lock in consul kv store.
707693 Log .info ('Checking for rgw lock in consul kv store.' )
708694 Rgw ._load_rgw_config (rgw_consul_idx , consul_url )
709- rgw_lock = Rgw ._get_lock (rgw_consul_idx )
695+ rgw_lock = Rgw ._get_lock (conf , rgw_consul_idx )
710696 if rgw_lock is True :
711697 # TODO: Find a way to get current data pod hostname on server node.
712698 # current_data_node = socket.gethostname().replace('server', 'data')
@@ -737,7 +723,6 @@ def _update_hax_endpoint_and_create_admin(conf: MappedConf):
737723 break
738724 else :
739725 if data_pod_hostname == data_pod_hostnames [- 1 ]:
740- Log .error (f'Admin user creation failed with error code - { status } ' )
741726 Rgw ._delete_consul_kv (rgw_consul_idx , const .CONSUL_LOCK_KEY )
742727 raise SetupError (status , 'Admin user creation failed on'
743728 f' "{ Rgw ._machine_id } " node, with all data pods - { data_pod_hostnames } ' )
@@ -747,17 +732,17 @@ def _update_hax_endpoint_and_create_admin(conf: MappedConf):
747732 def _get_data_nodes (conf : MappedConf ):
748733 """Return all data nodes hostname from GConf"""
749734 data_pod_hostnames = []
750- Log .debug ('collecting all data pod hostnames from GConf..' )
735+ Log .debug ('Collecting all data pod hostnames from GConf..' )
751736 node_identify_keys = Rgw ._search_cortx_conf (conf , const .NODE_IDENTIFIER , const .DATA_NODE_IDENTIFIER )
752737 node_machine_ids = list (map (lambda x : x .split ('>' )[1 ], node_identify_keys ))
753738 for machine_id in node_machine_ids :
754739 data_pod_hostnames .append (Rgw ._get_cortx_conf (conf , const .NODE_HOSTNAME % machine_id ))
755740
756- Log .debug (f'collected all data pod hostnames from GConf : { data_pod_hostnames } ' )
741+ Log .debug (f'Collected all data pod hostnames from GConf : { data_pod_hostnames } ' )
757742 return data_pod_hostnames
758743
759744 @staticmethod
760- def _get_lock (consul_idx : str ):
745+ def _get_lock (conf : MappedConf , consul_idx : str ):
761746 """Get lock from consul kv."""
762747 # if in case try-catch block code executed at the same time on all the nodes,
763748 # then all nodes will try to update rgw lock-key in consul, after updating key
@@ -771,20 +756,22 @@ def _get_lock(consul_idx: str):
771756 Log .info (f'{ const .CONSUL_LOCK_KEY } value - { rgw_lock_val } ' )
772757 if rgw_lock_val is None :
773758 Log .info (f'Setting consul kv store value for key :{ const .CONSUL_LOCK_KEY } '
774- f' and value as :{ Rgw ._machine_id } ' )
759+ f' and value :{ Rgw ._machine_id } ' )
775760 Rgw ._set_consul_kv (consul_idx , const .CONSUL_LOCK_KEY , Rgw ._machine_id )
776761 continue
777762 elif rgw_lock_val == Rgw ._machine_id :
778763 Log .info ('Required lock already possessed, proceeding with RGW '
779- f'admin user creation on node { rgw_lock_val } ' )
764+ 'admin user creation on node '
765+ f'{ Rgw ._get_cortx_conf (conf , const .NODE_HOSTNAME % rgw_lock_val )} ' )
780766 rgw_lock = True
781767 break
782768 elif rgw_lock_val != Rgw ._machine_id :
783769 if rgw_lock_val == const .ADMIN_USER_CREATED :
784770 Log .info ('User is already created.' )
785771 break
786- Log .info (f'RGW lock is acquired by "{ rgw_lock_val } " node.' )
787- Log .info (f'Waiting for user creation to complete on "{ rgw_lock_val } " node' )
772+ node_name = Rgw ._get_cortx_conf (conf , const .NODE_HOSTNAME % rgw_lock_val )
773+ Log .info (f'RGW lock is acquired by "{ node_name } " node.' )
774+ Log .info (f'Waiting for user creation to complete on { node_name } " node.' )
788775 time .sleep (3 )
789776 continue
790777
@@ -805,13 +792,13 @@ def _set_consul_kv(consul_idx: str, key: str, value: str):
805792 @staticmethod
806793 def _delete_consul_kv (consul_idx : str , key : str ):
807794 """Delete key value pair from consul kv store."""
808- Log .debug (f'Deleting rgw_lock key { key } .' )
809795 Conf .delete (consul_idx , key )
810- Log .info (f'{ key } key is deleted' )
796+ Log .info (f'rgw_lock key { key } is deleted' )
811797
812798 @staticmethod
813799 def _logrotate_generic (conf : MappedConf ):
814800 """ Configure logrotate utility for rgw logs."""
801+ Log .info (f'Configure logrotate for { const .COMPONENT_NAME } at path: { const .LOGROTATE_CONF } ' )
815802 log_file_path = Rgw ._get_log_dir_path (conf )
816803 # Configure the cron job on hourly frequency for RGW log files.
817804 try :
@@ -893,7 +880,7 @@ def _compare_resource_limit_value(input_val: str, expected_val: str, limit_type:
893880 converted_input_val = Rgw ._convert_resource_limit_value (input_val , limit_type )
894881
895882 if expected_val .isnumeric ():
896- # for CPU, value 1 = 1000m hence handling this numeric convertion .
883+ # for CPU, value 1 = 1000m hence handling this numeric conversion .
897884 if limit_type == 'cpu' :
898885 converted_expected_val = int (expected_val ) * const .CPU_VAL_MULTIPLICATION_FACTOR
899886 else :
@@ -917,7 +904,7 @@ def _convert_resource_limit_value(resource_limit_val: str, limit_type: str):
917904 elif limit_type == 'cpu' :
918905 temp = list (filter (resource_limit_val .endswith , const .SVC_RESOURCE_LIMIT_CPU_VAL_SUFFIXES ))
919906 else :
920- raise SetupError (errno .EINVAL , f'Invalid resource limit type { limit_type } speicified for rgw.' )
907+ raise SetupError (errno .EINVAL , f'Invalid resource limit type { limit_type } specified for rgw.' )
921908 if len (temp ) > 0 :
922909 # Ex: If mem resource_limit_val is 128MiB then num_resource_limit_val=128 or
923910 # If cpu resource_limit_val is 200m then num_resource_limit_val=200
@@ -938,7 +925,7 @@ def _convert_resource_limit_value(resource_limit_val: str, limit_type: str):
938925 'Please use valid format e.g. for mem limits : 1024, 1K, 1Ki, 1M, 1Mi, 1G, 1Gi etc and '
939926 'for CPU limits : 1, 0.5, 200m, 700m etc.' )
940927
941- # Calcuate final limit value.
928+ # Calculate final limit value.
942929 ret = int (num_resource_limit_val ) * map_val
943930 return ret
944931 else :
@@ -953,29 +940,29 @@ def _update_svc_config(conf: MappedConf, client_section: str, config_key_mapping
953940 svc_config_file = Rgw ._get_rgw_config_path (conf )
954941 confstore_url = const .CONFSTORE_FILE_HANDLER + svc_config_file
955942 Rgw ._load_rgw_config (Rgw ._conf_idx , confstore_url )
956- Log .info (f'updating parameters to { client_section } in { svc_config_file } ' )
943+ Log .info (f'Updating parameters to { client_section } in { svc_config_file } ' )
957944
958945 for config_key , confstore_key in config_key_mapping .items ():
959946 default_value = Conf .get (Rgw ._conf_idx , f'{ client_section } >{ config_key } ' )
960947 if confstore_key is None :
961- Log .info (f'config key:{ config_key } not found in rgw key mapping.'
962- f'hence using default value as { default_value } specified in config file .' )
948+ Log .info (f'Config key:{ config_key } not found in rgw key mapping.'
949+ f'hence using default value: { default_value } .' )
963950 continue
964951 else :
965952 # fetch actual value of parameter from confstore.
966953 # if config key/value is missing in confstore then use default value mentioned in config file.
967954 config_value = conf .get (confstore_key )
968955 if config_value is not None :
969- Log .info (f'Setting config key :{ config_key } with value:{ config_value } '
956+ Log .debug (f'Setting config key :{ config_key } with value:{ config_value } '
970957 f'at { client_section } section' )
971958 Conf .set (Rgw ._conf_idx , f'{ client_section } >{ config_key } ' , str (config_value ))
972959 else :
973- Log .info (f'GConfig entry is missing for config key : { config_key } . '
974- f'hence using default value as { default_value } specified in config file .' )
960+ Log .debug (f'Key: { config_key } is missing from GConf, '
961+ f'hence using the default value:" { default_value } " .' )
975962 continue
976963
977964 Conf .save (Rgw ._conf_idx )
978- Log .info (f'added paramters to { client_section } successfully..' )
965+ Log .info (f'Added parameters to { client_section } successfully..' )
979966
980967 @staticmethod
981968 def _update_svc_data_path_value (conf : MappedConf , client_section : str ):
@@ -985,19 +972,19 @@ def _update_svc_data_path_value(conf: MappedConf, client_section: str):
985972 svc_config_file = Rgw ._get_rgw_config_path (conf )
986973 confstore_url = const .CONFSTORE_FILE_HANDLER + svc_config_file
987974 Rgw ._load_rgw_config (Rgw ._conf_idx , confstore_url )
988- Log .info (f'updating data_path paramter to { client_section } in { svc_config_file } ' )
975+ Log .info (f'Updating data_path parameter to { client_section } in { svc_config_file } ' )
989976
990977 # Create data path's default value e.g. /var/lib/ceph/radosgw/<cluster-id>
991978 data_path_default_value = const .SVC_DATA_PATH_DEFAULT_VALUE + cluster_id
992979 confstore_data_path_value = conf .get (const .SVC_DATA_PATH_CONFSTORE_KEY )
993980 if confstore_data_path_value is not None :
994- Log .info (f'Setting config key :{ const .SVC_DATA_PATH_KEY } with value:{ confstore_data_path_value } '
981+ Log .debug (f'Setting config key :{ const .SVC_DATA_PATH_KEY } with value:{ confstore_data_path_value } '
995982 f'at { client_section } section' )
996983 Conf .set (Rgw ._conf_idx , f'{ client_section } >{ const .SVC_DATA_PATH_KEY } ' , str (confstore_data_path_value ))
997984 else :
998- Log .info (f'GConfig entry is missing for config key : { const . SVC_DATA_PATH_KEY } . '
999- f'hence using default value as { data_path_default_value } specified in config file .' )
985+ Log .debug (f'Key: { const . SVC_DATA_PATH_KEY } is missing from GConf, '
986+ f'hence using default the value:" { data_path_default_value } " .' )
1000987 Conf .set (Rgw ._conf_idx , f'{ client_section } >{ const .SVC_DATA_PATH_KEY } ' , str (data_path_default_value ))
1001988
1002989 Conf .save (Rgw ._conf_idx )
1003- Log .info (f'added config parameters to { client_section } successfully..' )
990+ Log .info (f'Added config parameters to { client_section } successfully..' )
0 commit comments