Skip to content

Commit caa0abd

Browse files
committed
Fix created_at and last_processed_at init values
1 parent f9a9338 commit caa0abd

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/dstack/_internal/server/services/fleets.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@
8686
)
8787
from dstack._internal.server.services.resources import set_resources_defaults
8888
from dstack._internal.utils import random_names
89-
from dstack._internal.utils.common import EntityID, EntityName, EntityNameOrID
89+
from dstack._internal.utils.common import (
90+
EntityID,
91+
EntityName,
92+
EntityNameOrID,
93+
get_current_datetime,
94+
)
9095
from dstack._internal.utils.logging import get_logger
9196
from dstack._internal.utils.ssh import pkey_from_str
9297

@@ -999,13 +1004,16 @@ async def _create_fleet(
9991004
else:
10001005
spec.configuration.name = await generate_fleet_name(session=session, project=project)
10011006

1007+
now = get_current_datetime()
10021008
fleet_model = FleetModel(
10031009
id=uuid.uuid4(),
10041010
name=spec.configuration.name,
10051011
project=project,
10061012
status=FleetStatus.ACTIVE,
10071013
spec=spec.json(),
10081014
instances=[],
1015+
created_at=now,
1016+
last_processed_at=now,
10091017
)
10101018
session.add(fleet_model)
10111019
events.emit(
@@ -1057,9 +1065,10 @@ async def _create_fleet(
10571065
targets=[events.Target.from_model(instance_model)],
10581066
)
10591067
fleet_model.instances.append(instance_model)
1060-
pipeline_hinter.hint_fetch(FleetModel.__name__)
1061-
pipeline_hinter.hint_fetch(InstanceModel.__name__)
10621068
await session.commit()
1069+
if spec.configuration.ssh_config is None:
1070+
pipeline_hinter.hint_fetch(FleetModel.__name__)
1071+
pipeline_hinter.hint_fetch(InstanceModel.__name__)
10631072
return fleet_model_to_fleet(fleet_model)
10641073

10651074

src/dstack/_internal/server/services/instances.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,12 +679,14 @@ def create_instance_model(
679679
reservation=reservation,
680680
tags=tags,
681681
)
682+
now = common_utils.get_current_datetime()
682683
instance = InstanceModel(
683684
id=instance_id,
684685
name=instance_name,
685686
instance_num=instance_num,
686687
project=project,
687-
created_at=common_utils.get_current_datetime(),
688+
created_at=now,
689+
last_processed_at=now,
688690
status=InstanceStatus.PENDING,
689691
unreachable=False,
690692
profile=profile.json(),

0 commit comments

Comments
 (0)