chore(endpointutils): remove unnecessary field BE-10415 (#1136)

pull/12845/head
andres-portainer 2025-09-04 11:22:46 -03:00 committed by GitHub
parent c90a15dd0f
commit 110f88f22d
6 changed files with 19 additions and 9 deletions

View File

@ -83,7 +83,6 @@
"MigrateIngresses": true
},
"PublicURL": "",
"QueryDate": 0,
"SecuritySettings": {
"allowBindMountsForRegularUsers": true,
"allowContainerCapabilitiesForRegularUsers": true,

View File

@ -2,10 +2,12 @@ package endpointutils
import (
"testing"
"time"
portainer "github.com/portainer/portainer/api"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type isEndpointTypeTest struct {
@ -120,3 +122,18 @@ func Test_FilterByExcludeIDs(t *testing.T) {
})
}
}
func TestUpdateEdgeEndpointHeartbeat(t *testing.T) {
endpoint := &portainer.Endpoint{
Type: portainer.EdgeAgentOnDockerEnvironment,
LastCheckInDate: time.Now().Unix(),
EdgeCheckinInterval: 5,
}
UpdateEdgeEndpointHeartbeat(endpoint, &portainer.Settings{})
require.True(t, endpoint.Heartbeat)
endpoint.LastCheckInDate = time.Now().Add(-time.Minute).Unix()
UpdateEdgeEndpointHeartbeat(endpoint, &portainer.Settings{})
require.False(t, endpoint.Heartbeat)
}

View File

@ -215,9 +215,8 @@ func UpdateEdgeEndpointHeartbeat(endpoint *portainer.Endpoint, settings *portain
return
}
endpoint.QueryDate = time.Now().Unix()
checkInInterval := getEndpointCheckinInterval(endpoint, settings)
endpoint.Heartbeat = endpoint.QueryDate-endpoint.LastCheckInDate <= int64(checkInInterval*2+20)
endpoint.Heartbeat = time.Now().Unix()-endpoint.LastCheckInDate <= int64(checkInInterval*2+20)
}
func getEndpointCheckinInterval(endpoint *portainer.Endpoint, settings *portainer.Settings) int {

View File

@ -448,8 +448,6 @@ type (
AMTDeviceGUID string `json:"AMTDeviceGUID,omitempty" example:"4c4c4544-004b-3910-8037-b6c04f504633"`
// LastCheckInDate mark last check-in date on checkin
LastCheckInDate int64
// QueryDate of each query with the endpoints list
QueryDate int64
// Heartbeat indicates the heartbeat status of an edge environment
Heartbeat bool `json:"Heartbeat" example:"true"`

View File

@ -24,15 +24,13 @@ test('given edge id and last checkin is set, should show heartbeat', async () =>
async function renderComponent(
edgeId = '',
lastCheckInDate = 0,
checkInInterval = 0,
queryDate = 0
checkInInterval = 0
) {
const environment = createMockEnvironment();
environment.EdgeID = edgeId;
environment.LastCheckInDate = lastCheckInDate;
environment.EdgeCheckinInterval = checkInInterval;
environment.QueryDate = queryDate;
const Wrapped = withTestQueryProvider(EdgeIndicator);

View File

@ -153,7 +153,6 @@ export type Environment = {
EdgeID?: string;
EdgeKey: string;
EdgeCheckinInterval?: number;
QueryDate?: number;
Heartbeat?: boolean;
LastCheckInDate?: number;
Name: string;