|
19 | 19 | import com.epam.aidial.deployment.manager.model.SimpleEnvVar; |
20 | 20 | import com.epam.aidial.deployment.manager.model.deployment.CreateDeployment; |
21 | 21 | import com.epam.aidial.deployment.manager.model.deployment.Deployment; |
| 22 | +import com.epam.aidial.deployment.manager.model.deployment.InferenceDeployment; |
22 | 23 | import com.epam.aidial.deployment.manager.model.deployment.NimDeployment; |
23 | 24 | import com.epam.aidial.deployment.manager.service.ImageDefinitionService; |
24 | 25 | import com.epam.aidial.deployment.manager.service.security.SecurityClaimsExtractor; |
@@ -348,19 +349,27 @@ private static boolean isBase64Encoded(String value) { |
348 | 349 | } |
349 | 350 |
|
350 | 351 | private static boolean isApplicableForRollingUpdate(Deployment existing, Deployment updated, boolean envsAreChanged) { |
351 | | - boolean isGrpcUpdated = false; |
352 | | - if (existing instanceof NimDeployment existingNim |
353 | | - && updated instanceof NimDeployment updatedNim) { |
354 | | - isGrpcUpdated = !Objects.equals(existingNim.getContainerGrpcPort(), updatedNim.getContainerGrpcPort()); |
355 | | - } |
| 352 | + // 1. Check specialized deployment types using pattern matching |
| 353 | + boolean specializedUpdate = switch (existing) { |
| 354 | + case NimDeployment exNim when updated instanceof NimDeployment upNim -> |
| 355 | + !Objects.equals(exNim.getContainerGrpcPort(), upNim.getContainerGrpcPort()); |
| 356 | + |
| 357 | + case InferenceDeployment exInf when updated instanceof InferenceDeployment upInf -> |
| 358 | + !Objects.equals(exInf.getArgs(), upInf.getArgs()) |
| 359 | + || !Objects.equals(exInf.getCommand(), upInf.getCommand()); |
| 360 | + |
| 361 | + default -> false; |
| 362 | + }; |
| 363 | + |
| 364 | + // 2. Check general deployment fields (and env changes) |
356 | 365 | return envsAreChanged |
| 366 | + || specializedUpdate |
357 | 367 | || !Objects.equals(existing.getImageDefinitionId(), updated.getImageDefinitionId()) |
358 | 368 | || !Objects.equals(existing.getContainerPort(), updated.getContainerPort()) |
359 | 369 | || !Objects.equals(existing.getInitialScale(), updated.getInitialScale()) |
360 | 370 | || !Objects.equals(existing.getMinScale(), updated.getMinScale()) |
361 | 371 | || !Objects.equals(existing.getMaxScale(), updated.getMaxScale()) |
362 | | - || !Objects.equals(existing.getResources(), updated.getResources()) |
363 | | - || isGrpcUpdated; |
| 372 | + || !Objects.equals(existing.getResources(), updated.getResources()); |
364 | 373 | } |
365 | 374 |
|
366 | 375 | private static boolean isApplicableForCiliumNetworkPolicyUpdate(Deployment existing, Deployment updated) { |
|
0 commit comments