Skip to content

Commit 3e68b1b

Browse files
benankbenank
andauthored
Revert off by one fix and update version to 1.6.26 (#94)
* Revert off by one fix * Update version Co-authored-by: benank <[email protected]>
1 parent e875112 commit 3e68b1b

File tree

12 files changed

+26
-22
lines changed

12 files changed

+26
-22
lines changed

src/core/src/bootstrap/Constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __iter__(self):
3030
UNKNOWN = "Unknown"
3131

3232
# Extension version (todo: move to a different file)
33-
EXT_VERSION = "1.6.25"
33+
EXT_VERSION = "1.6.26"
3434

3535
# Runtime environments
3636
TEST = 'Test'
@@ -156,7 +156,7 @@ class AutoAssessmentStates(EnumBackport):
156156

157157
UNKNOWN_PACKAGE_SIZE = "Unknown"
158158
PACKAGE_STATUS_REFRESH_RATE_IN_SECONDS = 10
159-
MAX_FILE_OPERATION_RETRY_COUNT = 10
159+
MAX_FILE_OPERATION_RETRY_COUNT = 5
160160
MAX_ASSESSMENT_RETRY_COUNT = 5
161161
MAX_INSTALLATION_RETRY_COUNT = 3
162162
MAX_IMDS_CONNECTION_RETRY_COUNT = 5

src/core/src/bootstrap/EnvLayer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def open(self, file_path, mode):
281281
try:
282282
return open(real_path, mode)
283283
except Exception as error:
284-
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT - 1:
284+
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT:
285285
time.sleep(i + 1)
286286
else:
287287
raise Exception("Unable to open {0} (retries exhausted). Error: {1}.".format(str(real_path), repr(error)))
@@ -310,7 +310,7 @@ def read_with_retry(self, file_path_or_handle):
310310
self.__write_record(operation, code=0, output=value, delay=0)
311311
return value
312312
except Exception as error:
313-
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT - 1:
313+
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT:
314314
time.sleep(i + 1)
315315
else:
316316
raise Exception("Unable to read from {0} (retries exhausted). Error: {1}.".format(str(file_path_or_handle), repr(error)))
@@ -327,7 +327,7 @@ def write_with_retry(self, file_path_or_handle, data, mode='a+'):
327327
file_handle.write(str(data))
328328
break
329329
except Exception as error:
330-
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT - 1:
330+
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT:
331331
time.sleep(i + 1)
332332
else:
333333
raise Exception("Unable to write to {0} (retries exhausted). Error: {1}.".format(str(file_handle.name), repr(error)))
@@ -346,7 +346,7 @@ def write_with_retry_using_temp_file(file_path, data, mode='w'):
346346
shutil.move(tempname, file_path)
347347
break
348348
except Exception as error:
349-
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT - 1:
349+
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT:
350350
time.sleep(i + 1)
351351
else:
352352
raise Exception("Unable to write to {0} (retries exhausted). Error: {1}.".format(str(file_path), repr(error)))

src/core/src/core_logic/PatchAssessor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def start_assessment(self):
6262
self.status_handler.set_assessment_substatus_json(status=Constants.STATUS_SUCCESS)
6363
break
6464
except Exception as error:
65-
if i < Constants.MAX_ASSESSMENT_RETRY_COUNT - 1:
65+
if i < Constants.MAX_ASSESSMENT_RETRY_COUNT:
6666
error_msg = 'Retryable error retrieving available patches: ' + repr(error)
6767
self.composite_logger.log_warning(error_msg)
6868
self.status_handler.add_error_to_status(error_msg, Constants.PatchOperationErrorCodes.DEFAULT_ERROR)

src/core/src/service_interfaces/LifecycleManager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def read_extension_sequence(self):
5656
with self.env_layer.file_system.open(self.ext_state_file_path, mode="r") as file_handle:
5757
return json.load(file_handle)['extensionSequence']
5858
except Exception as error:
59-
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT - 1:
59+
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT:
6060
self.composite_logger.log_warning("Exception on extension sequence read. [Exception={0}] [RetryCount={1}]".format(repr(error), str(i)))
6161
time.sleep(i+1)
6262
else:
@@ -115,7 +115,7 @@ def read_core_sequence(self):
115115

116116
return core_sequence
117117
except Exception as error:
118-
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT - 1:
118+
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT:
119119
self.composite_logger.log_warning("Exception on core sequence read. [Exception={0}] [RetryCount={1}]".format(repr(error), str(i)))
120120
time.sleep(i + 1)
121121
else:
@@ -145,7 +145,7 @@ def update_core_sequence(self, completed=False):
145145
with self.env_layer.file_system.open(self.core_state_file_path, 'w+') as file_handle:
146146
file_handle.write(core_state_payload)
147147
except Exception as error:
148-
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT - 1:
148+
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT:
149149
self.composite_logger.log_warning("Exception on core sequence update. [Exception={0}] [RetryCount={1}]".format(repr(error), str(i)))
150150
time.sleep(i + 1)
151151
else:

src/core/src/service_interfaces/StatusHandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def __load_status_file_components(self, initial_load=False):
501501
with self.env_layer.file_system.open(self.status_file_path, 'r') as file_handle:
502502
status_file_data_raw = json.load(file_handle)[0] # structure is array of 1
503503
except Exception as error:
504-
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT - 1:
504+
if i < Constants.MAX_FILE_OPERATION_RETRY_COUNT:
505505
time.sleep(i + 1)
506506
else:
507507
self.composite_logger.log_error("Unable to read status file (retries exhausted). Error: {0}.".format(repr(error)))

src/core/tests/Test_LifecycleManagerArc.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def test_read_extension_sequence_fail(self):
5454
# file open throws exception
5555
self.lifecycle_manager.ext_state_file_path = old_ext_state_file_path
5656
self.runtime.env_layer.file_system.open = self.mock_file_open_throw_exception
57-
self.assertRaises(Exception, self.lifecycle_manager.read_extension_sequence)
57+
ext_state_json = self.lifecycle_manager.read_extension_sequence()
58+
self.assertEquals(ext_state_json, None)
5859

5960
def test_read_extension_sequence_success(self):
6061
ext_state_json = self.lifecycle_manager.read_extension_sequence()
@@ -64,7 +65,8 @@ def test_read_extension_sequence_success(self):
6465
def test_read_core_sequence_fail(self):
6566
# file open throws exception
6667
self.runtime.env_layer.file_system.open = self.mock_file_open_throw_exception
67-
self.assertRaises(Exception, self.lifecycle_manager.read_core_sequence)
68+
core_sequence_json = self.lifecycle_manager.read_core_sequence()
69+
self.assertEquals(core_sequence_json, None)
6870

6971
def test_read_core_sequence_success(self):
7072
old_core_state_file_path = self.lifecycle_manager.core_state_file_path

src/core/tests/Test_LifecycleManagerAzure.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def test_read_extension_sequence_fail(self):
5151
# file open throws exception
5252
self.lifecycle_manager.ext_state_file_path = old_ext_state_file_path
5353
self.runtime.env_layer.file_system.open = self.mock_file_open_throw_exception
54-
self.assertRaises(Exception, self.lifecycle_manager.read_extension_sequence)
54+
ext_state_json = self.lifecycle_manager.read_extension_sequence()
55+
self.assertEquals(ext_state_json, None)
5556

5657
def test_read_extension_sequence_success(self):
5758
ext_state_json = self.lifecycle_manager.read_extension_sequence()
@@ -61,7 +62,8 @@ def test_read_extension_sequence_success(self):
6162
def test_read_core_sequence_fail(self):
6263
# file open throws exception
6364
self.runtime.env_layer.file_system.open = self.mock_file_open_throw_exception
64-
self.assertRaises(Exception, self.lifecycle_manager.read_core_sequence)
65+
core_sequence_json = self.lifecycle_manager.read_core_sequence()
66+
self.assertEquals(core_sequence_json, None)
6567

6668
def test_read_core_sequence_success(self):
6769
old_core_state_file_path = self.lifecycle_manager.core_state_file_path

src/core/tests/Test_PatchAssessor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_get_all_security_updates_fail(self):
4646
def test_assessment_fail_with_status_update(self):
4747
self.runtime.package_manager.refresh_repo = self.mock_refresh_repo
4848
self.runtime.set_legacy_test_type('UnalignedPath')
49-
self.assertRaises(Exception, self.runtime.patch_assessor.start_assessment)
49+
self.runtime.patch_assessor.start_assessment()
5050
with open(self.runtime.execution_config.status_file_path, 'r') as file_handle:
5151
file_contents = json.loads(file_handle.read())
5252
self.assertTrue('Unexpected return code (100) from package manager on command: LANG=en_US.UTF8 sudo apt-get -s dist-upgrade' in str(file_contents))

src/extension/src/ActionHandler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def copy_config_files(self, src, dst, raise_if_not_copied=False):
190190
shutil.copy(file_to_copy, dst)
191191
break
192192
except Exception as error:
193-
if i < Constants.MAX_IO_RETRIES - 1:
193+
if i < Constants.MAX_IO_RETRIES:
194194
time.sleep(i + 1)
195195
else:
196196
error_msg = "Failed to copy file after {0} tries. [Source={1}] [Destination={2}] [Exception={3}]".format(Constants.MAX_IO_RETRIES, str(file_to_copy), str(dst), repr(error))

src/extension/src/Constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __iter__(self):
2828
yield item
2929

3030
# Extension version (todo: move to a different file)
31-
EXT_VERSION = "1.6.25"
31+
EXT_VERSION = "1.6.26"
3232

3333
# Runtime environments
3434
TEST = 'Test'
@@ -85,7 +85,7 @@ class TelemetryEventLevel(EnumBackport):
8585
UTC_DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
8686

8787
# Re-try limit for file operations
88-
MAX_IO_RETRIES = 10
88+
MAX_IO_RETRIES = 5
8989

9090
# Re-try limit for verifying core process has started successfully
9191
MAX_PROCESS_STATUS_CHECK_RETRIES = 5

0 commit comments

Comments
 (0)