Skip to content

Commit

Permalink
add some additional logging and error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Vakhtang Donadze committed Jun 12, 2023
1 parent 16d05ef commit 6fd7981
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#

release_version = 2.3.5
release_version = 2.3.6

springboot_version = 3.0.2
kotlin_version = 1.6.21
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/exactpro/th2/inframgr/JobController.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class JobController {
@PutMapping("/jobs/{schemaName}/{jobName}")
public void putSecrets(@PathVariable(name = "schemaName") String schemaName,
@PathVariable(name = "jobName") String jobName) {
logger.debug("received request for job creation, job name: {}", jobName);
if (!K8sCustomResource.isSchemaNameValid(schemaName)) {
throw new NotAcceptableException(BAD_RESOURCE_NAME, "Invalid schema name");
}
Expand All @@ -74,7 +75,9 @@ public void putSecrets(@PathVariable(name = "schemaName") String schemaName,
gitter.unlock();
}
kube.deleteCustomResource(resource);
logger.info("Delete resource : {}", resourceLabel);
kube.createCustomResource(resource);
logger.info("Created job with name : {}", resourceLabel);
} catch (IOException e) {
throw new ServiceException(HttpStatus.INTERNAL_SERVER_ERROR, CONFIG_ERROR, e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,21 @@ private static void updateTrackedResources(String schema,

@PostConstruct
public void start() throws IOException {
Kubernetes kube = new Kubernetes(Config.getInstance().getKubernetes(), null);
RegistryCredentialLookup secretMapper = new RegistryCredentialLookup(kube);
RegistryConnection registryConnection = new RegistryConnection(secretMapper.getCredentials());
RegistryWatcher registryWatcher = new RegistryWatcher(
REGISTRY_CHECK_INITIAL_DELAY_SECONDS,
REGISTRY_CHECK_PERIOD_SECONDS,
registryConnection
);
registryWatcher.startWatchingRegistry();
logger.info("DynamicResourceProcessor has been started");
try {
Kubernetes kube = new Kubernetes(Config.getInstance().getKubernetes(), null);
RegistryCredentialLookup secretMapper = new RegistryCredentialLookup(kube);
RegistryConnection registryConnection = new RegistryConnection(secretMapper.getCredentials());
RegistryWatcher registryWatcher = new RegistryWatcher(
REGISTRY_CHECK_INITIAL_DELAY_SECONDS,
REGISTRY_CHECK_PERIOD_SECONDS,
registryConnection
);
registryWatcher.startWatchingRegistry();
logger.info("DynamicResourceProcessor has been started");
} catch (Exception e) {
logger.error("Exception while starting DynamicResourceProcessor. " +
"resources with dynamic versions will not be monitored", e);
throw e;
}
}
}

0 comments on commit 6fd7981

Please sign in to comment.