feat(edgestack): improve the structure to make JSON operations faster BE-11668 (#475)

release/2.28.0
andres-portainer 2025-03-15 10:10:17 -03:00 committed by GitHub
parent 2c05496962
commit e1f9b69cd5
3 changed files with 18 additions and 10 deletions

View File

@ -94,6 +94,10 @@ func (m *Migrator) updateEdgeStackStatusForDB100() error {
continue continue
} }
if environmentStatus.Details == nil {
continue
}
statusArray := []portainer.EdgeStackDeploymentStatus{} statusArray := []portainer.EdgeStackDeploymentStatus{}
if environmentStatus.Details.Pending { if environmentStatus.Details.Pending {
statusArray = append(statusArray, portainer.EdgeStackDeploymentStatus{ statusArray = append(statusArray, portainer.EdgeStackDeploymentStatus{

View File

@ -75,6 +75,10 @@ func (m *Migrator) updateEdgeStackStatusForDB80() error {
for _, edgeStack := range edgeStacks { for _, edgeStack := range edgeStacks {
for endpointId, status := range edgeStack.Status { for endpointId, status := range edgeStack.Status {
if status.Details == nil {
status.Details = &portainer.EdgeStackStatusDetails{}
}
switch status.Type { switch status.Type {
case portainer.EdgeStackStatusPending: case portainer.EdgeStackStatusPending:
status.Details.Pending = true status.Details.Pending = true
@ -93,10 +97,10 @@ func (m *Migrator) updateEdgeStackStatusForDB80() error {
edgeStack.Status[endpointId] = status edgeStack.Status[endpointId] = status
} }
err = m.edgeStackService.UpdateEdgeStack(edgeStack.ID, &edgeStack) if err := m.edgeStackService.UpdateEdgeStack(edgeStack.ID, &edgeStack); err != nil {
if err != nil {
return err return err
} }
} }
return nil return nil
} }

View File

@ -309,7 +309,7 @@ type (
// FileVersion is the version of the stack file, used to detect changes // FileVersion is the version of the stack file, used to detect changes
FileVersion int `json:"FileVersion"` FileVersion int `json:"FileVersion"`
// ConfigHash is the commit hash of the git repository used for deploying the stack // ConfigHash is the commit hash of the git repository used for deploying the stack
ConfigHash string `json:"ConfigHash"` ConfigHash string `json:"ConfigHash,omitempty"`
} }
// EdgeStack represents an edge stack // EdgeStack represents an edge stack
@ -353,23 +353,23 @@ type (
// EE only feature // EE only feature
DeploymentInfo StackDeploymentInfo DeploymentInfo StackDeploymentInfo
// ReadyRePullImage is a flag to indicate whether the auto update is trigger to re-pull image // ReadyRePullImage is a flag to indicate whether the auto update is trigger to re-pull image
ReadyRePullImage bool ReadyRePullImage bool `json:"ReadyRePullImage,omitempty"`
// Deprecated // Deprecated
Details EdgeStackStatusDetails Details *EdgeStackStatusDetails `json:"Details,omitempty"`
// Deprecated // Deprecated
Error string Error string `json:"Error,omitempty"`
// Deprecated // Deprecated
Type EdgeStackStatusType `json:"Type"` Type EdgeStackStatusType `json:"Type,omitempty"`
} }
// EdgeStackDeploymentStatus represents an edge stack deployment status // EdgeStackDeploymentStatus represents an edge stack deployment status
EdgeStackDeploymentStatus struct { EdgeStackDeploymentStatus struct {
Time int64 Time int64
Type EdgeStackStatusType Type EdgeStackStatusType
Error string Error string `json:"Error,omitempty"`
// EE only feature // EE only feature
RollbackTo *int RollbackTo *int `json:"RollbackTo,omitempty"`
Version int `json:"Version,omitempty"` Version int `json:"Version,omitempty"`
} }