Skip to content

Commit

Permalink
Remove duplicate deploy agent version (#1773)
Browse files Browse the repository at this point in the history
There were two ways of determining the deploy agent version:

1. From the __version__ variables
2. From the config file

Keep the __version__ variable and remove the config file version

Also, clean up the test which was not testing a real scenario since the
config is always passed in to the client
  • Loading branch information
osoriano authored Jan 14, 2025
1 parent f47f422 commit b6c78d2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
6 changes: 3 additions & 3 deletions deploy-agent/deployd/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import traceback
import json

from deployd import __version__
from deployd.client.base_client import BaseClient
from deployd.client.restfulclient import RestfulClient
from deployd.common.decorators import retry
Expand All @@ -43,7 +44,6 @@ def __init__(self, config=None, hostname=None, ip=None, hostgroup=None,
self._config = config
self._use_facter = use_facter
self._use_host_info = use_host_info
self._agent_version = self._config.get_deploy_agent_version()
self._autoscaling_group = None
self._availability_zone = None
self._stage_type = None
Expand Down Expand Up @@ -199,7 +199,7 @@ def _read_host_info(self) -> bool:
log.info("Host information is loaded. "
"Host name: {}, IP: {}, host id: {}, agent_version={}, autoscaling_group: {}, "
"availability_zone: {}, ec2_tags: {}, stage_type: {}, group: {}, account id: {}".format(self._hostname, self._ip, self._id,
self._agent_version, self._autoscaling_group, self._availability_zone, self._ec2_tags, self._stage_type, self._hostgroup, self._account_id))
__version__, self._autoscaling_group, self._availability_zone, self._ec2_tags, self._stage_type, self._hostgroup, self._account_id))

if not self._availability_zone:
log.error("Fail to read host info: availablity zone")
Expand All @@ -224,7 +224,7 @@ def send_reports(self, env_reports=None) -> Optional[PingResponse]:
report.errorMessage = report.errorMessage.encode('ascii', 'ignore').decode()
ping_request = PingRequest(hostId=self._id, hostName=self._hostname, hostIp=self._ip,
groups=self._hostgroup, reports=reports,
agentVersion=self._agent_version,
agentVersion=__version__,
autoscalingGroup=self._autoscaling_group,
availabilityZone=self._availability_zone,
ec2Tags=self._ec2_tags,
Expand Down
5 changes: 0 additions & 5 deletions deploy-agent/deployd/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

from typing import Any, List, Optional

from deployd import __version__

from deployd.common.exceptions import DeployConfigException
from deployd.common.types import DeployType
from deployd.common.utils import exit_abruptly
Expand Down Expand Up @@ -275,9 +273,6 @@ def get_facter_group_key(self) -> Optional[str]:
def get_verify_https_certificate(self) -> Optional[str]:
return self.get_var('verify_https_certificate', 'False')

def get_deploy_agent_version(self) -> str:
return self.get_var('deploy_agent_version', __version__)

def get_facter_az_key(self) -> Optional[str]:
return self.get_var('availability_zone_key', None)

Expand Down
4 changes: 0 additions & 4 deletions deploy-agent/tests/unit/deploy/client/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ class TestClient(TestCase):
def test_extends_base_client(self):
self.assertTrue(issubclass(Client, BaseClient))

def test_no_config_provided(self):
with self.assertRaises(AttributeError):
Client()

def test_read_host_info(self):
client = Client(config=Config())
client._ec2_tags = {}
Expand Down

0 comments on commit b6c78d2

Please sign in to comment.