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
}
if environmentStatus.Details == nil {
continue
}
statusArray := []portainer.EdgeStackDeploymentStatus{}
if environmentStatus.Details.Pending {
statusArray = append(statusArray, portainer.EdgeStackDeploymentStatus{

View File

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

View File

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