MCPcopy Create free account
hub / github.com/ceph/ceph / should_skip_object

Function should_skip_object

qa/workunits/dencoder/test_readable.py:151–210  ·  view source on GitHub ↗

Determine if an object should be skipped based on backward compatibility. Args: type (str): The type of the object to check. arversion (str): The archive version of the object. current_ver (str): The current version of the decoder. Returns: bool: True i

(type, arversion, current_ver)

Source from the content-addressed store, hash-verified

149
150
151def should_skip_object(type, arversion, current_ver):
152 """
153 Determine if an object should be skipped based on backward compatibility.
154
155 Args:
156 type (str): The type of the object to check.
157 arversion (str): The archive version of the object.
158 current_ver (str): The current version of the decoder.
159
160 Returns:
161 bool: True if the object should be skipped, False otherwise.
162 """
163
164 # Validate global structures
165 if not isinstance(backward_compat, dict) or not isinstance(fast_shouldnt_skip, list):
166 raise ValueError("Global variables 'backward_compat' must be a dict and 'fast_shouldnt_skip' must be a list.")
167
168 # Early return for cached types
169 if type in fast_shouldnt_skip:
170 debug_print(f"fast Type {type} is in the fast_shouldnt_skip list - don't skip.")
171 return False
172
173 # If the type doesn't exist in any backward_compat entry
174 if all(type not in v for v in backward_compat.values()):
175 debug_print(f"fast Type {type} does not exist in the backward compatibility structure - don't skip.")
176 fast_shouldnt_skip.append(type)
177 return False
178
179 # Parse current and archive versions
180 parsed_arversion = parse_version(arversion)
181 parsed_current_ver = parse_version(current_ver)
182
183 # Find the lowest version where the type exists
184 compatible_versions = [
185 parse_version(key) for key, types in backward_compat.items() if type in types
186 ]
187 if not compatible_versions:
188 debug_print(f"{type} has no compatible versions - don't skip.")
189 fast_shouldnt_skip.append(type)
190 return False
191
192 lowest_version = min(compatible_versions)
193 debug_print(f"{type} lowest compatible version: {lowest_version}")
194
195 # Check cascading compatibility
196 if parsed_current_ver < lowest_version:
197 # Current version is too old for this type
198 debug_print(f"{type} current version {parsed_current_ver} is less than {lowest_version} - skip.")
199 return True
200
201 # Filter archive versions within compatibility range
202 versions = [
203 key for key in backward_compat
204 if type in backward_compat[key]
205 and parse_version(key) >= parsed_arversion
206 and parse_version(key) <= parsed_current_ver
207 ]
208

Callers 1

test_object_wrapperFunction · 0.85

Calls 6

debug_printFunction · 0.85
allFunction · 0.85
parse_versionFunction · 0.85
valuesMethod · 0.45
appendMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected