Skip to content

Commit 856d594

Browse files
authored
Fix incorrect creationDate for networks. (#926)
- Fixes #925. - When the API service enumerates creation dates, the configuration value from the network helper is used instead of the persistent config value, so the creation date winds up being the current time. The short term fix is for the API server to return NetworkState values that combine the API server's persistent network config with the network status returned from the helper. - The longer term refinement could be to define a uniform model for resources where each resource type has Metadata (id/Identifiable, creationDate, labels), and type-specific configuration and state/status. ## Type of Change - [x] Bug fix - [ ] New feature - [ ] Breaking change - [ ] Documentation update ## Motivation and Context See above. ## Testing - [x] Tested locally - [ ] Added/updated tests - [ ] Added/updated docs
1 parent 6f55360 commit 856d594

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Sources/Services/ContainerAPIService/Networks/NetworksService.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,16 @@ public actor NetworksService {
7878

7979
let client = NetworkClient(id: configuration.id)
8080
let networkState = try await client.state()
81-
networkStates[configuration.id] = networkState
81+
82+
// FIXME: Temporary workaround for persisted configuration being overwritten
83+
// by what comes back from the network helper, which messes up creationDate.
84+
switch networkState {
85+
case .created(_):
86+
networkStates[configuration.id] = NetworkState.created(configuration)
87+
case .running(_, let status):
88+
networkStates[configuration.id] = NetworkState.running(configuration, status)
89+
}
90+
8291
guard case .running = networkState else {
8392
log.error(
8493
"network failed to start",

0 commit comments

Comments
 (0)