-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://projects.engineering.redhat.com/browse/RHCLOUD-2575 * Save stale_timestamp and reporter Added stale_timestamp and reporter fields to the add_hosts operation. If one of the fields is present, the other one must be filled in too. The stale_timestamp gets updated if * it’s either not set at all * or if the reporter is the same and the new timestamp is longer * or if the reporter is different and the new timestamp is shorter * Save stale_timestamp and reporter Added stale_timestamp and reporter fields to the add_hosts operation. If one of the fields is present, the other one must be filled in too. The stale_timestamp gets updated if * it’s either not set at all * or if the reporter is the same and the new timestamp is longer * or if the reporter is different and the new timestamp is shorter * Unit test stale timestamp update Added unit tests for the Host._update_stale_timestamp method. It contains some rather complex logic, which is now covered by tests. * Fix unit test Fixed failing host deserialization unit tests. The tests didn’t consider new Host constructor field. Added a new test for their default values. * Add basic culling fields to response Added the stale_timestamp and reporter fields to the serialized Host – to the create and get host output. * Test new fields in response Added test checking that the new stale_timestamp and reporter fields are present in all responses: create, update, get all and get by ID. * Add computed timestamps to responses. Add stale_warning_timestamp and culled_timestamp to the API responses. These are computed from the stale_warning timestamp. Added explicit tests for the timestamps. * added stale_timestamp input, and stale_warning_timestamp, culled_timestamp output to MQ * Support filtering by staleness Added a new staleness parameter to get_host_list and get_host_by_id. It supports fresh, stale, stale_warning, culled and unknown states. * add reporter label to ingress metrics so that we can easily categorize the success/failure/error metrics by reporter * Added some tests for MQ and the new stale functionality * actually commiting the new test file this time * fixed failing test * master merge in * made comment match function * Make culling timestamps configurable Added application configuration values for the stale_warning and culled timestamps offsets. They are in days and are loaded from the environment. This required to add the application configuration to the application config contextual object and to pass it around for the serialization. * Test culling timestamps configuration Added tests for the new configuration values. They verifies that the stale warning and culled timestamps are computed correctly using the values in the configuration object. * Test culling configuration * Added default values and enviroment variables to the Config class test case. * Added a new test case verifying that our configuration object is stored in the Flask App configuration dictionary. * fixed the failing test for real this time. Promise * fixed issue where mq test fail when run alone * Don’t expose the culled state The culled state is now only internal. It is no longer possible to get the culled hosts by any means. Added a regression test verifying that this state is not supported. * Use OpenAPI default for staleness Use OpenAPI standard schema definition of default values for the new staleness fields. Removed the Python constant and default values. * finished the empty tests (the ones that can be) * add reference to a jira issue * Fix merge conflicts * Decouple config from serialization Extracted the culling timestamp computation logic to a separate module. As a result, the serialization code no longer depends on the whole Config object. * use generated stale_timestamp in sample payloads
- Loading branch information
Showing
17 changed files
with
1,091 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from collections import namedtuple | ||
from datetime import timedelta | ||
|
||
|
||
__all__ = ("StalenessOffset",) | ||
|
||
|
||
class StalenessOffset(namedtuple("StalenessOffset", ("stale_warning_offset_days", "culled_offset_days"))): | ||
@classmethod | ||
def from_config(cls, config): | ||
return cls(config.culling_stale_warning_offset_days, config.culling_culled_offset_days) | ||
|
||
@staticmethod | ||
def _add_days(timestamp, days): | ||
return timestamp + timedelta(days=days) | ||
|
||
def stale_timestamp(self, stale_timestamp): | ||
return self._add_days(stale_timestamp, 0) | ||
|
||
def stale_warning_timestamp(self, stale_timestamp): | ||
return self._add_days(stale_timestamp, self.stale_warning_offset_days) | ||
|
||
def culled_timestamp(self, stale_timestamp): | ||
return self._add_days(stale_timestamp, self.culled_offset_days) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.