mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
feat(edgestackstatus): optimize the Edge Stack structures BE-11740 (#756)
This commit is contained in:
parent
eaf0deb2f6
commit
75f165d1ff
33 changed files with 452 additions and 391 deletions
|
@ -49,7 +49,6 @@ func (service *Service) BuildEdgeStack(
|
|||
DeploymentType: deploymentType,
|
||||
CreationDate: time.Now().Unix(),
|
||||
EdgeGroups: edgeGroups,
|
||||
Status: make(map[portainer.EndpointID]portainer.EdgeStackStatus, 0),
|
||||
Version: 1,
|
||||
UseManifestNamespaces: useManifestNamespaces,
|
||||
}, nil
|
||||
|
@ -104,6 +103,14 @@ func (service *Service) PersistEdgeStack(
|
|||
return nil, err
|
||||
}
|
||||
|
||||
for _, endpointID := range relatedEndpointIds {
|
||||
status := &portainer.EdgeStackStatusForEnv{EndpointID: endpointID}
|
||||
|
||||
if err := tx.EdgeStackStatus().Create(stack.ID, endpointID, status); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if err := tx.EndpointRelation().AddEndpointRelationsForEdgeStack(relatedEndpointIds, stack.ID); err != nil {
|
||||
return nil, fmt.Errorf("unable to add endpoint relations: %w", err)
|
||||
}
|
||||
|
@ -158,5 +165,9 @@ func (service *Service) DeleteEdgeStack(tx dataservices.DataStoreTx, edgeStackID
|
|||
return errors.WithMessage(err, "Unable to remove the edge stack from the database")
|
||||
}
|
||||
|
||||
if err := tx.EdgeStackStatus().DeleteAll(edgeStackID); err != nil {
|
||||
return errors.WithMessage(err, "unable to remove edge stack statuses from the database")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue