Skip to content

Commit 62ec4a4

Browse files
fix: rolling update is not triggered on args/command modification #85 (#145)
1 parent 87eac39 commit 62ec4a4

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/main/java/com/epam/aidial/deployment/manager/service/deployment/DeploymentService.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.epam.aidial.deployment.manager.model.SimpleEnvVar;
2020
import com.epam.aidial.deployment.manager.model.deployment.CreateDeployment;
2121
import com.epam.aidial.deployment.manager.model.deployment.Deployment;
22+
import com.epam.aidial.deployment.manager.model.deployment.InferenceDeployment;
2223
import com.epam.aidial.deployment.manager.model.deployment.NimDeployment;
2324
import com.epam.aidial.deployment.manager.service.ImageDefinitionService;
2425
import com.epam.aidial.deployment.manager.service.security.SecurityClaimsExtractor;
@@ -348,19 +349,27 @@ private static boolean isBase64Encoded(String value) {
348349
}
349350

350351
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)
356365
return envsAreChanged
366+
|| specializedUpdate
357367
|| !Objects.equals(existing.getImageDefinitionId(), updated.getImageDefinitionId())
358368
|| !Objects.equals(existing.getContainerPort(), updated.getContainerPort())
359369
|| !Objects.equals(existing.getInitialScale(), updated.getInitialScale())
360370
|| !Objects.equals(existing.getMinScale(), updated.getMinScale())
361371
|| !Objects.equals(existing.getMaxScale(), updated.getMaxScale())
362-
|| !Objects.equals(existing.getResources(), updated.getResources())
363-
|| isGrpcUpdated;
372+
|| !Objects.equals(existing.getResources(), updated.getResources());
364373
}
365374

366375
private static boolean isApplicableForCiliumNetworkPolicyUpdate(Deployment existing, Deployment updated) {

0 commit comments

Comments
 (0)