Skip to content

Conversation

@stiv03
Copy link
Contributor

@stiv03 stiv03 commented Oct 15, 2025

No description provided.

@stiv03 stiv03 marked this pull request as ready for review October 23, 2025 06:58
private List<DeployedMtaService> getManagedServices(List<DeployedMtaService> services) {
if (services == null) {
return null;
if (services != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here it won't be null right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the current implementation services can actually be null here. For example, when we deploy with no managed services, deployedMta.getServices() returns null and gets passed down. I will move the check earlier in the chain.

List<DeployedMtaService> managed = getManagedServices(services);
if (!managed.isEmpty()) {
return managed.stream()
.map(s -> s.getGuid() != null ? s.getGuid()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when the guid is null?

private List<String> extractManagedServiceGuids(List<DeployedMtaService> services) {
if (services != null) {
List<DeployedMtaService> managed = getManagedServices(services);
if (!managed.isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inverse this if

return List.of();
}

return getServiceKeysByMetadataInternal(labelSelector, allServiceGuids);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why CustomControllerClientErrorHandler().handleErrorsOrReturnResult is removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow I missed it, I will add it back

Comment on lines 128 to 130
CloudServiceInstance instance = client.getServiceInstance(serviceName, false);
return instance != null ? instance.getGuid()
.toString() : null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why should handle the optional scenario here. This will not fail if the service instance does not exist, it shouldn't fail only when it is optional or active: false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed!

private List<String> getExistingServiceNamesFromDescriptor(ProcessContext context) {
DeploymentDescriptor descriptor = context.getVariable(Variables.DEPLOYMENT_DESCRIPTOR);

if (descriptor == null || descriptor.getResources() == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when the descriptor is null? resources? empty or null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Descriptor is null when undeploy


List<String> allServiceGuids = Stream.concat(managedGuids.stream(), existingServiceGuids.stream())
.filter(Objects::nonNull)
.distinct()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need these distincts everywhere?

}

private boolean isOptionalOrInactive(Resource resource) {
return Boolean.TRUE.equals(resource.isOptional()) || Boolean.FALSE.equals(resource.isActive());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you just do resource.isOptional() || !resource.isActive()

Comment on lines 138 to 140
if (isOptionalOrInactive(resource)) {
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we at least log that there was an exception or we must not print any information?

return managedServices.isEmpty() ? null : managedServices;
return services.stream()
.filter(this::serviceIsNotUserProvided)
.collect(Collectors.toList());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace with toList()

Comment on lines 146 to 148
private boolean isOptionalOrInactive(Resource resource) {
return resource.isOptional() || !resource.isActive();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to split this logic so it is clear if it is optional or inactive

.toString();
} catch (CloudOperationException e) {
if (isOptionalOrInactive(resource)) {
getStepLogger().debug(Messages.IGNORING_NOT_FOUND_OPTIONAL_OR_INACTIVE_SERVICE, resource.getName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add LOGGER.error here as well, because debug logs are usually not printed in Kibana


private void logIgnoredService(String message, String serviceName) {
getStepLogger().debug(message, serviceName);
LOGGER.error(message, serviceName);
Copy link
Contributor

@IvanBorislavovDimitrov IvanBorislavovDimitrov Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log the actual error as well, only in the error log

@Yavor16 Yavor16 merged commit bfd5d4c into cloudfoundry:master Oct 30, 2025
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants