Conversation
1f427f0 to
ee7cb12
Compare
1d8bc2e to
e3e18d8
Compare
58a20c0 to
f028eb1
Compare
|
Done:
TODO (Based on things that we're aware of till date):
Future scope
|
|
@vrushaliwaykole agents can be assigned to an Environment through ConfigRepo. This is something to keep in mind and verify. |
api/api-agents-v5/src/main/java/com/thoughtworks/go/apiv5/agents/AgentsControllerV5.java
Outdated
Show resolved
Hide resolved
config/config-api/src/main/java/com/thoughtworks/go/config/AgentConfig.java
Outdated
Show resolved
Hide resolved
| public String getIpAddress() { | ||
| return this.ipAddress; | ||
| public boolean isElastic() { | ||
| return isNotBlank(elasticAgentId) && isNotBlank(elasticPluginId); |
There was a problem hiding this comment.
It would be nice to have polymorphic objects like ElasticAgent extends Agent. I know it might cascade into a lot of changes everywhere else, so feel free to ignore this for now.
server/src/main/java/com/thoughtworks/go/config/GoConfigMigrator.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/thoughtworks/go/config/update/AgentsEntityConfigUpdateCommand.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/thoughtworks/go/config/update/AgentsEntityConfigUpdateCommand.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/thoughtworks/go/listener/DatabaseEntityChangeListener.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/thoughtworks/go/server/controller/AgentRegistrationController.java
Outdated
Show resolved
Hide resolved
|
|
||
| private String dburl(Boolean mvccEnabled) { | ||
| return "jdbc:h2:" + systemEnvironment.getDbPath() + "/" + configuration.getName() | ||
| return "jdbc:h2:" + systemEnvironment.getDbPath().getAbsolutePath() + "/" + configuration.getName() |
There was a problem hiding this comment.
Was getAbsolutePath() deliberately added?
There was a problem hiding this comment.
Yes. The DB is now being updated during the config migration and it required absolute path for the same.
server/src/main/java/com/thoughtworks/go/server/service/AgentConfigService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/com/thoughtworks/go/server/persistence/AgentDao.java
Outdated
Show resolved
Hide resolved
feb0548 to
657813c
Compare
|
Current scenario: Issue: Solution:
suggestions appreciated. /cc @akshaydewan @ketan @msaurabh1978 @maheshp |
- ensured that in case of updating a pending agent, if for some reason, the DB save fails save fails, the cache should not get updated. - in Env Config Service - there is only one sync method which will update the local envs copy with the input and also sync it with the agents in DB
…ect and throws appropriate exceptions for various error situations. AgentsControllerV6.update() is modified to understand those exception and create appropriate response. Environment config classes have quite a few critical business logic but there were no sufficient tests so added those missing tests for basic environment config even though these were not modified as part of moving agents work
…tion, UnprocessableEntityException to be handled by centralized exception handlers, that are registered using RoutesHelper.init()
… service layer. Service layer in case of delete throws appropriate exceptions for various scenarios AgentsController does not handle and rethrows HttpException which are eventually handled by centralized exception handler AgentsController handles all exceptions other than HttpException and create appropriate response
…ironment Config methods Even though these methods are not modified, they are in some way related to agents
…alize(), which loads all agents from DB to be cached in memory. When there is an error in initialization of Agent Service, application can't function properly. Hence throwing an exception with appropriate error message which is logged in the application start up code. Hence not logging the exception in AgentDao.
…ring after commit callback to a generic util which takes a lambda as input to register it as after commit hook. and rectified exception handling in agent service initialization
…gentsAssociationOfEnvironment() to not be aware of result object. They now throw appropriate exception for various possible error situations and which are caugh/handled in controller and appropriate message is sent back in the response. This is still WIP as AgentService.updateAgentsAssociationOfEnvironment() is used by rails controller which needs to be rectified to incorporate mentioned changes.
Reverted all the changes made to maintain the same in the EnvConfig service cache Updated the AgentEnv Representer class to utlize envs stored in the agent object to determine the unknown configs and render them accordingly Updated the tests as well.
- removed the `values` method on `AgentInstances` as the object itself can be utilized as is. For creating a stream, used `stream(spliterator, noParalle)` method Updated the relevant tests - removed logging on `GoConfigMigrator.migrate` exception catch block as it is already handled by the handler - On Env Config Update API v3 - for rename entity exception, used case-insensitive equals
…ult object to the agent service. instead surrounded the service call with begin-rescue and rendered the appropriate error
…er - which can be invoked from anywhere on demand and is disabled/dormant by default
- patchEnv method of Env Config Service will no longer accept any list of agents to add/remove. - Updated the PatchEnvCommand to remove all logic of agent association/validation - Updated the EnvAgentConfig.validateUuidPresent method to add config error if the list of uuids received is null. This is required in case a config repo with agent-env association is added to a GoCD server with no agents. - Removed all config annotations from EnvAgentConfig(s)
…ion code to test-shared.
…nt was not found in the DB. This is done to ensure that if an agent is not assigned a cookie until the same has been successfully registered/enabled in the GoCD server.
…adding agent-env association via either config change or agent service listeners
… in the DB Added logs to specify what all agents are being migrated Updated the tests to verify for both insert and update agent scenario
…gents API v6 in the agent object
- elastic agent created for a job (pipeline) associated with an env was failing. This is fixed. - delete agent request from elastic-agent plugins will now be executed without any validations. We assume that the plugin knows best abt the agents.
Resolved some merge conflicts
…ed during agent registration flow
As part of moving agents from config to the database (#911), below is the exhausting list of changes required along with their current (up-to-date) status,
agentstable to hold agent information that was earlier part of config XMLresourcescolumn to hold association with resourcesenvironmentscolumn to hold association with environmentselasticAgentIdandelasticPluginIdcolumnsdisabledcolumn as a flag for disabled agentsdeletedcolumn as a flag for deleted agents.saveOrUpdateoperations for agents. We referUUIDas a unique identifier throughout the application. Hibernate performs DB operations using the primary key which isidfield in theAgentstable. As we don't persist database id in in-memory objects. In order to perform database operations, we have to findidforUUIDand set that on record tosaveOrUpdate<agents/>tag from top level and also from<environments/>tag.AgentXmlToDBMigrationmigrator which will transfer all the records from config XML to database as part of XSLcookieassignment -cookiefield is mandatory in the DB which changes agent registration flow. In the case of auto registration,cookiegets assigned at the time of registration and In the case of manual registration,cookieis assigned when a user enables agent(s) manually.deletedboolean column inagentstableAgentConfigServiceandAgentDAOrelated changesAgentDAOclass responsible for performing DB operations onagentstableAgentConfigServiceclass and bring all that functionality intoAgentServiceclassAgentServicethe only class responsible for talking toAgentDAOand for maintaining a cache of agents in the form ofAgentInstancesAgentServicebe the single point of contact for performing any operations on agents. It will decide smartly when to go to DB throughAgentDAOand when to return agent(s) detail from the cacheAgentServicewill listen for changes to agents in DB and refresh the agent's cache (AgentInstances) whenever appropriateAgentServicewill support mechanism to register listeners so that agents changes in DB can be further propagated to interested parties with more relevant detailsGoConfigServicetoAgentServiceto respond to any agent related queries and operationsAgentConfigclass toAgentclass so that there are only two classes that represent Agent. TheAgentclass represents a database row in theAgentstable andAgentInstancecontains runtime information of an agent.Make changes to switch from going to
*CruiseConfig*,*GoConfig*classes to read/write agents data to and from config XML to go toAgentServiceto read/write data to and from DBFix existing test failtures
Document Environment API v3
Add new tests covering all of the above changes
Verifications - verify that,
Agents API v6behaves same across master and PR branch except for the anticipated changesEnvironment API v3behaves same across master and PR branch except for the anticipated changesAgentsControllerV5AgentsControllerV4EnvironmentsControllerV3AgentServiceAgentDaoGoConfigService(agent methods were removed. No tests to add for this)AgentsAgentAgentInstancesAgentInstanceResourceConfig(s)EnvironmentConfigServiceEnvironmentsConfigEnvironmentConfigsubclassesEnvironmentAgentConfigAgent(s)UpdateValidatorCommaSeparatedStringGoConfigFileHelper(Test helper class - no tests needed for this)resources_controller.rbenvironments_controller.rbAdd Postgres migrations for the addon