Skip to content

Commit ccebbc8

Browse files
authored
feat!: change 'id' type to string and rename 'name' to 'displayName' in Deployment (#35)
1 parent d1fae4d commit ccebbc8

File tree

97 files changed

+737
-592
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+737
-592
lines changed

docs/rest-collection/dm_insomnia_collection.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,8 @@ collection:
392392
{
393393
"$type": "mcp",
394394
"imageDefinitionId": "{{ _['image-definition-id'] }}",
395-
"name": "fetch",
395+
"name": "fetch-1",
396+
"displayName": "Fetch",
396397
"description": "Fetch MCP",
397398
"metadata": {
398399
"envs": [
@@ -451,7 +452,8 @@ collection:
451452
{
452453
"$type": "mcp",
453454
"imageDefinitionId": "{{ _['image-definition-id'] }}",
454-
"name": "fetch",
455+
"name": "fetch-1",
456+
"displayName": "Fetch 1",
455457
"description": "Fetch MCP",
456458
"metadata": {
457459
"envs": [
@@ -647,8 +649,9 @@ collection:
647649
mimeType: application/json
648650
text: |-
649651
{
650-
"sourceDeploymentId": "{{ _['deployment-id'] }}",
651-
"newDeploymentName": "deployment-1-clone"
652+
"sourceDeploymentName": "{{ _['deployment-id'] }}",
653+
"newDeploymentName": "deployment-1-clone",
654+
"newDeploymentDisplayName": "Deployment clone"
652655
}
653656
headers:
654657
- name: Content-Type

docs/rest-collection/dm_postman_collection.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@
474474
],
475475
"body": {
476476
"mode": "raw",
477-
"raw": "{\n \"$type\": \"mcp\",\n \"imageDefinitionId\": \"{{image-definition-id}}\",\n \"name\": \"fetch\",\n \"description\": \"Fetch MCP\",\n \"metadata\": {\n \"envs\": [\n {\n \"name\": \"EXAMPLE_ENV\",\n \"value\": {\n \"$type\": \"simple\",\n \"value\": \"test value\"\n },\n \"mountType\": \"secure_content\",\n \"description\": \"Example env description\"\n }\n ]\n },\n \"transport\": \"http_streaming\",\n \"containerPort\": 8080,\n \"initialScale\": 1,\n \"minScale\": 0,\n \"maxScale\": 2,\n \"resources\": {\n \"limits\": {\n \"cpu\": \"0.1\",\n \"memory\": \"104857600\"\n },\n \"requests\": {\n \"cpu\": \"0.05\",\n \"memory\": \"52428800\"\n }\n },\n \"author\": \"local-user\"\n}",
477+
"raw": "{\n \"$type\": \"mcp\",\n \"imageDefinitionId\": \"{{image-definition-id}}\",\n \"name\": \"fetch-1\",\n \"displayName\": \"Fetch\",\n \"description\": \"Fetch MCP\",\n \"metadata\": {\n \"envs\": [\n {\n \"name\": \"EXAMPLE_ENV\",\n \"value\": {\n \"$type\": \"simple\",\n \"value\": \"test value\"\n },\n \"mountType\": \"secure_content\",\n \"description\": \"Example env description\"\n }\n ]\n },\n \"transport\": \"http_streaming\",\n \"containerPort\": 8080,\n \"initialScale\": 1,\n \"minScale\": 0,\n \"maxScale\": 2,\n \"resources\": {\n \"limits\": {\n \"cpu\": \"0.1\",\n \"memory\": \"104857600\"\n },\n \"requests\": {\n \"cpu\": \"0.05\",\n \"memory\": \"52428800\"\n }\n },\n \"author\": \"local-user\"\n}",
478478
"options": {
479479
"raw": {
480480
"language": "json"
@@ -512,7 +512,7 @@
512512
],
513513
"body": {
514514
"mode": "raw",
515-
"raw": "{\n \"$type\": \"mcp\",\n \"imageDefinitionId\": \"{{image-definition-id}}\",\n \"name\": \"fetch\",\n \"description\": \"Fetch MCP\",\n \"metadata\": {\n \"envs\": [\n {\n \"name\": \"EXAMPLE_ENV\",\n \"value\": {\n \"$type\": \"simple\",\n \"value\": \"test value\"\n },\n \"mountType\": \"secure_content\",\n \"description\": \"Example env description\"\n }\n ]\n },\n \"transport\": \"http_streaming\",\n \"containerPort\": 8080,\n \"initialScale\": 1,\n \"minScale\": 0,\n \"maxScale\": 2,\n \"resources\": {\n \"limits\": {\n \"cpu\": \"0.1\",\n \"memory\": \"104857600\"\n },\n \"requests\": {\n \"cpu\": \"0.05\",\n \"memory\": \"52428800\"\n }\n },\n \"author\": \"local-user\",\n \"allowedDomains\": [\n \"epam.com\"\n ]\n}",
515+
"raw": "{\n \"$type\": \"mcp\",\n \"imageDefinitionId\": \"{{image-definition-id}}\",\n \"name\": \"fetch-1\",\n \"displayName\": \"Fetch 1\",\n \"description\": \"Fetch MCP\",\n \"metadata\": {\n \"envs\": [\n {\n \"name\": \"EXAMPLE_ENV\",\n \"value\": {\n \"$type\": \"simple\",\n \"value\": \"test value\"\n },\n \"mountType\": \"secure_content\",\n \"description\": \"Example env description\"\n }\n ]\n },\n \"transport\": \"http_streaming\",\n \"containerPort\": 8080,\n \"initialScale\": 1,\n \"minScale\": 0,\n \"maxScale\": 2,\n \"resources\": {\n \"limits\": {\n \"cpu\": \"0.1\",\n \"memory\": \"104857600\"\n },\n \"requests\": {\n \"cpu\": \"0.05\",\n \"memory\": \"52428800\"\n }\n },\n \"author\": \"local-user\",\n \"allowedDomains\": [\n \"epam.com\"\n ]\n}",
516516
"options": {
517517
"raw": {
518518
"language": "json"
@@ -742,7 +742,7 @@
742742
],
743743
"body": {
744744
"mode": "raw",
745-
"raw": "{\n\t\"sourceDeploymentId\": \"{{deployment-id}}\",\n\t\"newDeploymentName\": \"deployment-1-clone\"\n}",
745+
"raw": "{\n\t\"sourceDeploymentName\": \"{{deployment-id}}\",\n\t\"newDeploymentName\": \"deployment-1-clone\",\n\t\"newDeploymentDisplayName\": \"Deployment clone\"\n}",
746746
"options": {
747747
"raw": {
748748
"language": "json"

src/main/java/com/epam/aidial/deployment/manager/cleanup/component/AbstractCleanupStrategy.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import lombok.extern.slf4j.Slf4j;
77
import org.springframework.transaction.annotation.Transactional;
88

9-
import java.util.UUID;
10-
119
@Slf4j
1210
@RequiredArgsConstructor
1311
abstract class AbstractCleanupStrategy implements CleanupStrategy {
@@ -16,7 +14,7 @@ abstract class AbstractCleanupStrategy implements CleanupStrategy {
1614
protected final DisposableResourceCleaner resourceCleaner;
1715

1816
@Transactional
19-
protected void cleanupResources(UUID groupId) {
17+
protected void cleanupResources(String groupId) {
2018
resourceManager.markResourcesForCleanupByGroupId(groupId);
2119
resourceCleaner.cleanAllCleanableByGroupId(groupId);
2220
}

src/main/java/com/epam/aidial/deployment/manager/cleanup/component/CleanupStrategy.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22

33
import com.epam.aidial.deployment.manager.model.ComponentType;
44

5-
import java.util.UUID;
6-
75
/**
86
* Strategy interface for cleaning up different types of components.
97
*/
108
public interface CleanupStrategy {
119

12-
default void prepareForDeletion(UUID id) {
10+
default void prepareForDeletion(String id) {
1311
// Default implementation does nothing
1412
}
1513

16-
void delete(UUID id);
14+
void delete(String id);
1715

1816
ComponentType getComponentType();
1917
}

src/main/java/com/epam/aidial/deployment/manager/cleanup/component/DeploymentCleanupStrategy.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import org.springframework.stereotype.Service;
1111
import org.springframework.transaction.annotation.Transactional;
1212

13-
import java.util.UUID;
14-
1513
@Slf4j
1614
@Service
1715
@LogExecution
@@ -33,15 +31,15 @@ public ComponentType getComponentType() {
3331

3432
@Override
3533
@Transactional
36-
public void prepareForDeletion(UUID id) {
34+
public void prepareForDeletion(String id) {
3735
deploymentRepository.conditionalUpdate(id,
3836
deployment -> deployment.getStatus().isActive(),
3937
deployment -> deployment.setStatus(DeploymentStatus.STOPPING));
4038
}
4139

4240
@Override
4341
@Transactional
44-
public void delete(UUID id) {
42+
public void delete(String id) {
4543
cleanupResources(id);
4644
deploymentRepository.deleteById(id);
4745
log.info("Deployment '{}' deleted successfully", id);

src/main/java/com/epam/aidial/deployment/manager/cleanup/component/ImageDefinitionCleanupStrategy.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,20 @@ public ComponentType getComponentType() {
4242

4343
@Override
4444
@Transactional
45-
public void delete(UUID id) {
46-
imageDefinitionRepository.getImageDefinitionForUpdateById(id);
45+
public void delete(String id) {
46+
UUID uuid = UUID.fromString(id);
47+
48+
imageDefinitionRepository.getImageDefinitionForUpdateById(uuid);
4749

4850
cleanupResources(id);
4951

5052
// Clean up deployments that reference this image definition
51-
deploymentRepository.getAllByImageDefinitionId(id).stream()
53+
deploymentRepository.getAllByImageDefinitionId(uuid).stream()
5254
.map(Deployment::getId)
5355
.forEach(deploymentId
5456
-> componentCleanupService.deleteAsync(ComponentRemoval.of(deploymentId, ComponentType.DEPLOYMENT)));
5557

56-
imageDefinitionRepository.deleteImageDefinitionById(id);
57-
log.info("Image definition '{}' deleted successfully", id);
58+
imageDefinitionRepository.deleteImageDefinitionById(uuid);
59+
log.info("Image definition '{}' deleted successfully", uuid);
5860
}
5961
}

src/main/java/com/epam/aidial/deployment/manager/cleanup/resource/DisposableResourceCleaner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ private void cleanAllByLifecycle(Function<Integer, List<DisposableResource>> res
6262
log.info("Cleaned up all {} disposable resources", lifecycleStateForLog);
6363
}
6464

65-
public void cleanAllCleanableByGroupId(UUID groupId) {
65+
public void cleanAllCleanableByGroupId(String groupId) {
6666
var resources = disposableResourceManager.getAllCleanableByGroupId(groupId);
6767
cleanDisposableResources(resources);
6868
log.info("Cleaned up all cleanable disposable resources by group ID '{}'", groupId);
6969
}
7070

7171
public void cleanTemporaryByGroupId(UUID groupId) {
72-
var resources = disposableResourceManager.getAllTemporaryByGroupId(groupId);
72+
var resources = disposableResourceManager.getAllTemporaryByGroupId(String.valueOf(groupId));
7373
cleanDisposableResources(resources);
7474
log.info("Cleaned up all temporary disposable resources by group ID '{}'", groupId);
7575
}

src/main/java/com/epam/aidial/deployment/manager/cleanup/resource/DisposableResourceManager.java

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class DisposableResourceManager {
3434
private final DisposableResourceRepository resourceRepository;
3535

3636
@Transactional(readOnly = true)
37-
public List<DisposableResource> getAllByGroupId(UUID groupId) {
37+
public List<DisposableResource> getAllByGroupId(String groupId) {
3838
return resourceRepository.getAllByGroupId(groupId);
3939
}
4040

@@ -49,40 +49,40 @@ public List<DisposableResource> getAllTemporary(int take) {
4949
}
5050

5151
@Transactional(readOnly = true)
52-
public List<DisposableResource> getAllCleanableByGroupId(UUID groupId) {
52+
public List<DisposableResource> getAllCleanableByGroupId(String groupId) {
5353
return resourceRepository.getAllByGroupIdAndLifecycleStates(groupId, CLEANABLE_STATES);
5454
}
5555

5656
@Transactional(readOnly = true)
57-
public List<DisposableResource> getAllTemporaryByGroupId(UUID groupId) {
57+
public List<DisposableResource> getAllTemporaryByGroupId(String groupId) {
5858
return resourceRepository.getAllByGroupIdAndLifecycleStates(groupId, Set.of(ResourceLifecycleState.TEMPORARY));
5959
}
6060

6161
@Transactional(propagation = Propagation.REQUIRES_NEW)
62-
public void markResourcesForCleanupByGroupId(UUID groupId) {
62+
public void markResourcesForCleanupByGroupId(String groupId) {
6363
var disposableResources = getAllByGroupId(groupId);
6464
disposableResources.forEach(rs -> rs.setLifecycleState(ResourceLifecycleState.TO_CLEANUP));
6565
resourceRepository.saveAll(disposableResources);
6666
log.debug("Marked for clean-up all disposable resources related to group ID: {}", groupId);
6767
}
6868

6969
@Transactional(propagation = Propagation.REQUIRES_NEW)
70-
public List<DisposableResource> markKnativeServiceResourceForCleanup(UUID id, String namespace) {
70+
public List<DisposableResource> markKnativeServiceResourceForCleanup(String id, String namespace) {
7171
return markServiceResourceForCleanup(id, namespace, K8sResourceKind.KNATIVE_SERVICE);
7272
}
7373

7474
@Transactional(propagation = Propagation.REQUIRES_NEW)
75-
public List<DisposableResource> markNimServiceResourceForCleanup(UUID id, String namespace) {
75+
public List<DisposableResource> markNimServiceResourceForCleanup(String id, String namespace) {
7676
return markServiceResourceForCleanup(id, namespace, K8sResourceKind.NIM_SERVICE);
7777
}
7878

7979
@Transactional(propagation = Propagation.REQUIRES_NEW)
80-
public List<DisposableResource> markInferenceServiceResourceForCleanup(UUID id, String namespace) {
80+
public List<DisposableResource> markInferenceServiceResourceForCleanup(String id, String namespace) {
8181
return markServiceResourceForCleanup(id, namespace, K8sResourceKind.INFERENCE_SERVICE);
8282
}
8383

8484
@Transactional(propagation = Propagation.REQUIRES_NEW)
85-
public List<DisposableResource> markCiliumNetworkPolicyResourceForCleanup(UUID groupId, String namespace, String name) {
85+
public List<DisposableResource> markCiliumNetworkPolicyResourceForCleanup(String groupId, String namespace, String name) {
8686
var reference = K8sResourceReference.builder()
8787
.kind(K8sResourceKind.CILIUM_NETWORK_POLICY)
8888
.namespace(namespace)
@@ -93,15 +93,15 @@ public List<DisposableResource> markCiliumNetworkPolicyResourceForCleanup(UUID g
9393

9494
@Transactional(propagation = Propagation.MANDATORY)
9595
public void changeResourceLifecycleByGroupIdInSameTransaction(
96-
UUID groupId,
96+
String groupId,
9797
ResourceReference resourceReference,
9898
ResourceLifecycleState state
9999
) {
100100
changeResourceLifecycleInternal(groupId, resourceReference, state);
101101
}
102102

103103
private List<DisposableResource> changeResourceLifecycleInternal(
104-
UUID groupId,
104+
String groupId,
105105
ResourceReference resourceReference,
106106
ResourceLifecycleState state
107107
) {
@@ -120,6 +120,14 @@ public void saveK8sResources(List<? extends HasMetadata> k8sResources,
120120
K8sResourceKind resourceKind,
121121
UUID groupId,
122122
String namespace) {
123+
saveK8sResources(k8sResources, resourceKind, String.valueOf(groupId), namespace);
124+
}
125+
126+
@Transactional(propagation = Propagation.REQUIRES_NEW)
127+
public void saveK8sResources(List<? extends HasMetadata> k8sResources,
128+
K8sResourceKind resourceKind,
129+
String groupId,
130+
String namespace) {
123131
var now = Instant.now();
124132
var resources = k8sResources.stream()
125133
.map(rs -> DisposableResource.builder()
@@ -137,24 +145,24 @@ public void saveK8sResources(List<? extends HasMetadata> k8sResources,
137145
}
138146

139147
@Transactional(propagation = Propagation.REQUIRES_NEW)
140-
public void saveKnativeServiceResource(UUID id, String namespace) {
141-
saveServiceResource(id, namespace, K8sResourceKind.KNATIVE_SERVICE, ResourceLifecycleState.STABLE);
148+
public void saveKnativeServiceResource(String id, String namespace) {
149+
saveServiceResource(id, namespace, K8sResourceKind.KNATIVE_SERVICE);
142150
}
143151

144152
@Transactional(propagation = Propagation.REQUIRES_NEW)
145-
public void saveNimServiceResource(UUID id, String namespace) {
146-
saveServiceResource(id, namespace, K8sResourceKind.NIM_SERVICE, ResourceLifecycleState.STABLE);
153+
public void saveNimServiceResource(String id, String namespace) {
154+
saveServiceResource(id, namespace, K8sResourceKind.NIM_SERVICE);
147155
}
148156

149157
@Transactional(propagation = Propagation.REQUIRES_NEW)
150-
public void saveInferenceServiceResource(UUID id, String namespace) {
151-
saveServiceResource(id, namespace, K8sResourceKind.INFERENCE_SERVICE, ResourceLifecycleState.STABLE);
158+
public void saveInferenceServiceResource(String id, String namespace) {
159+
saveServiceResource(id, namespace, K8sResourceKind.INFERENCE_SERVICE);
152160
}
153161

154162
@Transactional(propagation = Propagation.REQUIRES_NEW)
155163
public void saveContainerRegistryResource(String imageName, UUID groupId, ResourceLifecycleState lifecycleState) {
156164
var imageResource = DisposableResource.builder()
157-
.groupId(groupId)
165+
.groupId(String.valueOf(groupId))
158166
.reference(ContainerRegistryResourceReference.builder()
159167
.name(imageName)
160168
.build())
@@ -174,33 +182,33 @@ public void delete(DisposableResource resource) {
174182
resourceRepository.delete(resource);
175183
}
176184

177-
private List<DisposableResource> markServiceResourceForCleanup(UUID id, String namespace, K8sResourceKind kind) {
185+
private List<DisposableResource> markServiceResourceForCleanup(String id, String namespace, K8sResourceKind kind) {
178186
var reference = buildServiceReference(id, namespace, kind);
179187
return changeResourceLifecycleInternal(id, reference, ResourceLifecycleState.TO_CLEANUP);
180188
}
181189

182-
private void saveServiceResource(UUID id, String namespace, K8sResourceKind kind, ResourceLifecycleState lifecycleState) {
190+
private void saveServiceResource(String id, String namespace, K8sResourceKind kind) {
183191
var serviceResource = DisposableResource.builder()
184192
.groupId(id)
185193
.reference(buildServiceReference(id, namespace, kind))
186-
.lifecycleState(lifecycleState)
194+
.lifecycleState(ResourceLifecycleState.STABLE)
187195
.createdAt(Instant.now())
188196
.build();
189197
resourceRepository.save(serviceResource);
190198
}
191199

192-
private K8sResourceReference buildServiceReference(UUID id, String namespace, K8sResourceKind kind) {
200+
private K8sResourceReference buildServiceReference(String id, String namespace, K8sResourceKind kind) {
193201
return K8sResourceReference.builder()
194202
.kind(kind)
195203
.namespace(namespace)
196204
.name(generateServiceName(id, kind))
197205
.build();
198206
}
199207

200-
private String generateServiceName(UUID id, K8sResourceKind kind) {
208+
private String generateServiceName(String id, K8sResourceKind kind) {
201209
return switch (kind) {
202-
case INFERENCE_SERVICE -> K8sNamingUtils.generateName(id.toString());
203-
case KNATIVE_SERVICE, NIM_SERVICE -> K8sNamingUtils.generateMcpPrefixedName(id.toString());
210+
case INFERENCE_SERVICE -> K8sNamingUtils.generateName(id);
211+
case KNATIVE_SERVICE, NIM_SERVICE -> K8sNamingUtils.generateMcpPrefixedName(id);
204212
default -> throw new IllegalArgumentException("Unsupported service kind: " + kind);
205213
};
206214
}

src/main/java/com/epam/aidial/deployment/manager/cleanup/resource/model/DisposableResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
public class DisposableResource {
1616

1717
private UUID id;
18-
private UUID groupId;
18+
private String groupId;
1919
private ResourceReference reference;
2020
private ResourceLifecycleState lifecycleState;
2121
private Instant createdAt;

src/main/java/com/epam/aidial/deployment/manager/dao/entity/ComponentId.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
import lombok.Data;
99
import lombok.NoArgsConstructor;
1010

11-
import java.util.UUID;
12-
1311
@Embeddable
1412
@Data
1513
@NoArgsConstructor
1614
@AllArgsConstructor
1715
public class ComponentId {
18-
private UUID id;
16+
private String id;
1917
@Enumerated(value = EnumType.STRING)
2018
private ComponentType type;
2119
}

0 commit comments

Comments
 (0)