mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
fix(edgejobs): decouple the Edge Jobs from the reverse tunnel service BE-10866 (#11)
This commit is contained in:
parent
7a35b5b0e4
commit
61c5269353
14 changed files with 179 additions and 243 deletions
|
@ -1,8 +1,12 @@
|
|||
package edge
|
||||
|
||||
import (
|
||||
"slices"
|
||||
|
||||
portainer "github.com/portainer/portainer/api"
|
||||
"github.com/portainer/portainer/api/dataservices"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
// EndpointRelatedEdgeStacks returns a list of Edge stacks related to this Environment(Endpoint)
|
||||
|
@ -39,3 +43,33 @@ func EffectiveCheckinInterval(tx dataservices.DataStoreTx, endpoint *portainer.E
|
|||
|
||||
return portainer.DefaultEdgeAgentCheckinIntervalInSeconds
|
||||
}
|
||||
|
||||
// EndpointInEdgeGroup returns true and the edge group name if the endpoint is in the edge group
|
||||
func EndpointInEdgeGroup(
|
||||
tx dataservices.DataStoreTx,
|
||||
endpointID portainer.EndpointID,
|
||||
edgeGroupID portainer.EdgeGroupID,
|
||||
) (bool, string, error) {
|
||||
endpointIDs, err := GetEndpointsFromEdgeGroups(
|
||||
[]portainer.EdgeGroupID{edgeGroupID}, tx,
|
||||
)
|
||||
if err != nil {
|
||||
return false, "", err
|
||||
}
|
||||
|
||||
if slices.Contains(endpointIDs, endpointID) {
|
||||
edgeGroup, err := tx.EdgeGroup().Read(edgeGroupID)
|
||||
if err != nil {
|
||||
log.Warn().
|
||||
Err(err).
|
||||
Int("edgeGroupID", int(edgeGroupID)).
|
||||
Msg("Unable to retrieve edge group")
|
||||
|
||||
return false, "", err
|
||||
}
|
||||
|
||||
return true, edgeGroup.Name, nil
|
||||
}
|
||||
|
||||
return false, "", nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue