Skip to content

Commit

Permalink
[AGENT-11701] Fix handling of deleted build config (DataDog#18122)
Browse files Browse the repository at this point in the history
* Fix handling of deleted build config

* Add debug log

* Run lint

* Add changelog

* Update teamcity/changelog.d/18122.fixed

Co-authored-by: Kyle Neale <[email protected]>

---------

Co-authored-by: Kyle Neale <[email protected]>
  • Loading branch information
dkirov-dd and Kyle-Neale authored Aug 5, 2024
1 parent de756fe commit ce97ca1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions teamcity/changelog.d/18122.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix handling of deleted build config
14 changes: 11 additions & 3 deletions teamcity/datadog_checks/teamcity/teamcity_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Licensed under a 3-clause BSD style license (see LICENSE)
from copy import deepcopy

from requests.exceptions import HTTPError
from six import PY2

from datadog_checks.base import AgentCheck, ConfigurationError, is_affirmative
Expand Down Expand Up @@ -244,13 +245,20 @@ def _collect_new_builds(self, project_id):
self.log.debug(
'No builds for project %d and build config %d, checking again', project_id, self.current_build_config
)
ressource = "last_build"
resource = "last_build"
options = {"project_id": project_id}
else:
self.log.debug('Checking for new builds...')
ressource = "new_builds"
resource = "new_builds"
options = {"since_build": last_build_id}
return get_response(self, ressource, build_conf=self.current_build_config, **options)
try:
new_builds = get_response(self, resource, build_conf=self.current_build_config, **options)
except HTTPError:
# In the case where a build config has been deleted, no new builds should be returned and it will be removed
# from the list of all build configs in the next re-initialization
self.log.debug('Failed to retrieve new builds for build config %s', self.current_build_config)
new_builds = {}
return new_builds

def _get_build_config_type(self, build_config):
if self.is_deployment:
Expand Down

0 comments on commit ce97ca1

Please sign in to comment.