feat: wire up unit status with presence #19158
Open
+825
−211
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the last of the PRs to wire up unit status (agent and workload) with the presence data. This is quite easy now that we have the presence information in the database, the tricky part is ensuring that we correctly handle the status for things like allocating. If the unit is allocating, it won't yet have recorded the presence, in that case, we have to fake the display status when calling
juju status
. This won't impact the underlying data, just the display nature.This pull request includes several changes to improve the handling of unit and application statuses in the codebase. The most important changes involve adding new methods to retrieve both unit and agent display statuses, modifying existing status retrieval methods to handle cases where status information might be missing, and updating the corresponding tests and mock implementations.
New Methods and Enhancements:
apiserver/facades/client/client/service.go
: AddedGetUnitAndAgentDisplayStatus
method to retrieve both unit and agent display statuses.apiserver/facades/client/client/status.go
: UpdatedprocessUnitAndAgentStatus
to use the newGetUnitAndAgentDisplayStatus
method.Status Handling Improvements:
domain/application/service/application.go
: ModifiedGetApplicationStatus
andGetApplicationDisplayStatus
to handle cases whereapplicationStatus
is nil and to use the newUnitStatusInfo
structure. [1] [2]domain/application/service/migration.go
: UpdatedGetApplicationStatus
andGetUnitAgentStatus
to handle missing status information and to use theUnitStatusInfo
structure. [1] [2]Test Updates:
domain/application/service/application_test.go
: Updated tests to useUnitStatusInfo
instead ofStatusInfo
. [1] [2] [3]domain/application/service/migration_test.go
: Updated tests to useUnitStatusInfo
and handle new status cases. [1] [2]Mock Implementations:
domain/application/service/package_mock_test.go
: Updated mock methods to useUnitStatusInfo
instead ofStatusInfo
. [1] [2] [3] [4] [5]These changes collectively enhance the robustness of status handling in the application, ensuring that missing status information is appropriately managed and that the new
UnitStatusInfo
structure is consistently used across the codebase.QA steps
It should switch between the statuses correctly.
$ juju bootstrap lxd test $ watch juju status -m controller
Deploying an application to a model, should correctly display allocating and not agent lost.
In another terminal (as it can be fast!):
Bonus points
Whilst still calling
watch juju status
:Status should now switch correctly to lost for the agent and unknown for the application and workload:
It should come back - you can flip-flop between the two states.
Links
Jira card: JUJU-7652