mirror of https://github.com/portainer/portainer
feat(edge-compute): add specific edge endpoint checkin interval (#3855)
* feat(endpoint): send custom checkin interval * feat(endpoint): update edge checkin interval * feat(endpoint): save checkin interval * feat(endpoints): create endpoint with checkin interval * feat(endpoints): change tooltip * fix(edge-compute): fix typos Co-authored-by: Anthony Lapenna <anthony.lapenna@portainer.io> * fix(endpoints): show default interval * fix(endpoint): rename checkin property Co-authored-by: Anthony Lapenna <anthony.lapenna@portainer.io>pull/3442/merge
parent
766ced7cb1
commit
9f4631bb6d
|
@ -30,6 +30,7 @@ type endpointCreatePayload struct {
|
|||
TLSCertFile []byte
|
||||
TLSKeyFile []byte
|
||||
TagIDs []portainer.TagID
|
||||
EdgeCheckinInterval int
|
||||
}
|
||||
|
||||
func (payload *endpointCreatePayload) Validate(r *http.Request) error {
|
||||
|
@ -102,6 +103,9 @@ func (payload *endpointCreatePayload) Validate(r *http.Request) error {
|
|||
publicURL, _ := request.RetrieveMultiPartFormValue(r, "PublicURL", true)
|
||||
payload.PublicURL = publicURL
|
||||
|
||||
checkinInterval, _ := request.RetrieveNumericMultiPartFormValue(r, "CheckinInterval", true)
|
||||
payload.EdgeCheckinInterval = checkinInterval
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -193,13 +197,14 @@ func (handler *Handler) createEdgeAgentEndpoint(payload *endpointCreatePayload)
|
|||
TLSConfig: portainer.TLSConfiguration{
|
||||
TLS: false,
|
||||
},
|
||||
AuthorizedUsers: []portainer.UserID{},
|
||||
AuthorizedTeams: []portainer.TeamID{},
|
||||
Extensions: []portainer.EndpointExtension{},
|
||||
TagIDs: payload.TagIDs,
|
||||
Status: portainer.EndpointStatusUp,
|
||||
Snapshots: []portainer.Snapshot{},
|
||||
EdgeKey: edgeKey,
|
||||
AuthorizedUsers: []portainer.UserID{},
|
||||
AuthorizedTeams: []portainer.TeamID{},
|
||||
Extensions: []portainer.EndpointExtension{},
|
||||
TagIDs: payload.TagIDs,
|
||||
Status: portainer.EndpointStatusUp,
|
||||
Snapshots: []portainer.Snapshot{},
|
||||
EdgeKey: edgeKey,
|
||||
EdgeCheckinInterval: payload.EdgeCheckinInterval,
|
||||
}
|
||||
|
||||
err = handler.saveEndpointAndUpdateAuthorizations(endpoint)
|
||||
|
|
|
@ -60,11 +60,16 @@ func (handler *Handler) endpointStatusInspect(w http.ResponseWriter, r *http.Req
|
|||
|
||||
tunnel := handler.ReverseTunnelService.GetTunnelDetails(endpoint.ID)
|
||||
|
||||
checkinInterval := settings.EdgeAgentCheckinInterval
|
||||
if endpoint.EdgeCheckinInterval != 0 {
|
||||
checkinInterval = endpoint.EdgeCheckinInterval
|
||||
}
|
||||
|
||||
statusResponse := endpointStatusInspectResponse{
|
||||
Status: tunnel.Status,
|
||||
Port: tunnel.Port,
|
||||
Schedules: tunnel.Schedules,
|
||||
CheckinInterval: settings.EdgeAgentCheckinInterval,
|
||||
CheckinInterval: checkinInterval,
|
||||
Credentials: tunnel.Credentials,
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ type endpointUpdatePayload struct {
|
|||
TagIDs []portainer.TagID
|
||||
UserAccessPolicies portainer.UserAccessPolicies
|
||||
TeamAccessPolicies portainer.TeamAccessPolicies
|
||||
EdgeCheckinInterval *int
|
||||
}
|
||||
|
||||
func (payload *endpointUpdatePayload) Validate(r *http.Request) error {
|
||||
|
@ -61,6 +62,10 @@ func (handler *Handler) endpointUpdate(w http.ResponseWriter, r *http.Request) *
|
|||
endpoint.PublicURL = *payload.PublicURL
|
||||
}
|
||||
|
||||
if payload.EdgeCheckinInterval != nil {
|
||||
endpoint.EdgeCheckinInterval = *payload.EdgeCheckinInterval
|
||||
}
|
||||
|
||||
groupIDChanged := false
|
||||
if payload.GroupID != nil {
|
||||
groupID := portainer.EndpointGroupID(*payload.GroupID)
|
||||
|
|
|
@ -155,21 +155,23 @@ type (
|
|||
// Endpoint represents a Docker endpoint with all the info required
|
||||
// to connect to it
|
||||
Endpoint struct {
|
||||
ID EndpointID `json:"Id"`
|
||||
Name string `json:"Name"`
|
||||
Type EndpointType `json:"Type"`
|
||||
URL string `json:"URL"`
|
||||
GroupID EndpointGroupID `json:"GroupId"`
|
||||
PublicURL string `json:"PublicURL"`
|
||||
TLSConfig TLSConfiguration `json:"TLSConfig"`
|
||||
Extensions []EndpointExtension `json:"Extensions"`
|
||||
TagIDs []TagID `json:"TagIds"`
|
||||
Status EndpointStatus `json:"Status"`
|
||||
Snapshots []Snapshot `json:"Snapshots"`
|
||||
UserAccessPolicies UserAccessPolicies `json:"UserAccessPolicies"`
|
||||
TeamAccessPolicies TeamAccessPolicies `json:"TeamAccessPolicies"`
|
||||
EdgeID string `json:"EdgeID,omitempty"`
|
||||
EdgeKey string `json:"EdgeKey"`
|
||||
ID EndpointID `json:"Id"`
|
||||
Name string `json:"Name"`
|
||||
Type EndpointType `json:"Type"`
|
||||
URL string `json:"URL"`
|
||||
GroupID EndpointGroupID `json:"GroupId"`
|
||||
PublicURL string `json:"PublicURL"`
|
||||
TLSConfig TLSConfiguration `json:"TLSConfig"`
|
||||
Extensions []EndpointExtension `json:"Extensions"`
|
||||
TagIDs []TagID `json:"TagIds"`
|
||||
Status EndpointStatus `json:"Status"`
|
||||
Snapshots []Snapshot `json:"Snapshots"`
|
||||
UserAccessPolicies UserAccessPolicies `json:"UserAccessPolicies"`
|
||||
TeamAccessPolicies TeamAccessPolicies `json:"TeamAccessPolicies"`
|
||||
EdgeID string `json:"EdgeID,omitempty"`
|
||||
EdgeKey string `json:"EdgeKey"`
|
||||
EdgeCheckinInterval int `json:"EdgeCheckinInterval"`
|
||||
|
||||
// Deprecated fields
|
||||
// Deprecated in DBVersion == 4
|
||||
TLS bool `json:"TLS,omitempty"`
|
||||
|
|
|
@ -65,7 +65,21 @@ angular.module('portainer.app').factory('EndpointService', [
|
|||
return deferred.promise;
|
||||
};
|
||||
|
||||
service.createRemoteEndpoint = function (name, type, URL, PublicURL, groupID, tagIds, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile) {
|
||||
service.createRemoteEndpoint = function (
|
||||
name,
|
||||
type,
|
||||
URL,
|
||||
PublicURL,
|
||||
groupID,
|
||||
tagIds,
|
||||
TLS,
|
||||
TLSSkipVerify,
|
||||
TLSSkipClientVerify,
|
||||
TLSCAFile,
|
||||
TLSCertFile,
|
||||
TLSKeyFile,
|
||||
checkinInterval
|
||||
) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var endpointURL = URL;
|
||||
|
@ -73,7 +87,21 @@ angular.module('portainer.app').factory('EndpointService', [
|
|||
endpointURL = 'tcp://' + URL;
|
||||
}
|
||||
|
||||
FileUploadService.createEndpoint(name, type, endpointURL, PublicURL, groupID, tagIds, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile)
|
||||
FileUploadService.createEndpoint(
|
||||
name,
|
||||
type,
|
||||
endpointURL,
|
||||
PublicURL,
|
||||
groupID,
|
||||
tagIds,
|
||||
TLS,
|
||||
TLSSkipVerify,
|
||||
TLSSkipClientVerify,
|
||||
TLSCAFile,
|
||||
TLSCertFile,
|
||||
TLSKeyFile,
|
||||
checkinInterval
|
||||
)
|
||||
.then(function success(response) {
|
||||
deferred.resolve(response.data);
|
||||
})
|
||||
|
|
|
@ -91,12 +91,11 @@ angular.module('portainer.app').factory('FileUploadService', [
|
|||
data: {
|
||||
file: file,
|
||||
Name: stackName,
|
||||
EdgeGroups: Upload.json(edgeGroups)
|
||||
EdgeGroups: Upload.json(edgeGroups),
|
||||
},
|
||||
ignoreLoadingBar: true
|
||||
ignoreLoadingBar: true,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
service.configureRegistry = function (registryId, registryManagementConfigurationModel) {
|
||||
return Upload.upload({
|
||||
|
@ -116,7 +115,7 @@ angular.module('portainer.app').factory('FileUploadService', [
|
|||
});
|
||||
};
|
||||
|
||||
service.createEndpoint = function (name, type, URL, PublicURL, groupID, tagIds, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile) {
|
||||
service.createEndpoint = function (name, type, URL, PublicURL, groupID, tagIds, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile, checkinInterval) {
|
||||
return Upload.upload({
|
||||
url: 'api/endpoints',
|
||||
data: {
|
||||
|
@ -132,6 +131,7 @@ angular.module('portainer.app').factory('FileUploadService', [
|
|||
TLSCACertFile: TLSCAFile,
|
||||
TLSCertFile: TLSCertFile,
|
||||
TLSKeyFile: TLSKeyFile,
|
||||
CheckinInterval: checkinInterval,
|
||||
},
|
||||
ignoreLoadingBar: true,
|
||||
});
|
||||
|
|
|
@ -12,6 +12,7 @@ angular
|
|||
EndpointService,
|
||||
GroupService,
|
||||
TagService,
|
||||
SettingsService,
|
||||
Notifications,
|
||||
Authentication
|
||||
) {
|
||||
|
@ -19,6 +20,24 @@ angular
|
|||
EnvironmentType: 'agent',
|
||||
actionInProgress: false,
|
||||
allowCreateTag: Authentication.isAdmin(),
|
||||
availableEdgeAgentCheckinOptions: [
|
||||
{ key: 'Use default interval', value: 0 },
|
||||
{
|
||||
key: '5 seconds',
|
||||
value: 5,
|
||||
},
|
||||
{
|
||||
key: '10 seconds',
|
||||
value: 10,
|
||||
},
|
||||
{
|
||||
key: '30 seconds',
|
||||
value: 30,
|
||||
},
|
||||
{ key: '5 minutes', value: 300 },
|
||||
{ key: '1 hour', value: 3600 },
|
||||
{ key: '1 day', value: 86400 },
|
||||
],
|
||||
};
|
||||
|
||||
$scope.formValues = {
|
||||
|
@ -28,6 +47,7 @@ angular
|
|||
GroupId: 1,
|
||||
SecurityFormData: new EndpointSecurityFormData(),
|
||||
TagIds: [],
|
||||
CheckinInterval: $scope.state.availableEdgeAgentCheckinOptions[0].value,
|
||||
};
|
||||
|
||||
$scope.copyAgentCommand = function () {
|
||||
|
@ -79,7 +99,7 @@ angular
|
|||
var tagIds = $scope.formValues.TagIds;
|
||||
var URL = $scope.formValues.URL;
|
||||
|
||||
addEndpoint(name, 4, URL, '', groupId, tagIds, false, false, false, null, null, null);
|
||||
addEndpoint(name, 4, URL, '', groupId, tagIds, false, false, false, null, null, null, $scope.formValues.CheckinInterval);
|
||||
};
|
||||
|
||||
$scope.onCreateTag = function onCreateTag(tagName) {
|
||||
|
@ -96,9 +116,23 @@ angular
|
|||
}
|
||||
}
|
||||
|
||||
function addEndpoint(name, type, URL, PublicURL, groupId, tagIds, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile) {
|
||||
function addEndpoint(name, type, URL, PublicURL, groupId, tagIds, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile, CheckinInterval) {
|
||||
$scope.state.actionInProgress = true;
|
||||
EndpointService.createRemoteEndpoint(name, type, URL, PublicURL, groupId, tagIds, TLS, TLSSkipVerify, TLSSkipClientVerify, TLSCAFile, TLSCertFile, TLSKeyFile)
|
||||
EndpointService.createRemoteEndpoint(
|
||||
name,
|
||||
type,
|
||||
URL,
|
||||
PublicURL,
|
||||
groupId,
|
||||
tagIds,
|
||||
TLS,
|
||||
TLSSkipVerify,
|
||||
TLSSkipClientVerify,
|
||||
TLSCAFile,
|
||||
TLSCertFile,
|
||||
TLSKeyFile,
|
||||
CheckinInterval
|
||||
)
|
||||
.then(function success(data) {
|
||||
Notifications.success('Endpoint created', name);
|
||||
if (type === 4) {
|
||||
|
@ -119,10 +153,14 @@ angular
|
|||
$q.all({
|
||||
groups: GroupService.groups(),
|
||||
tags: TagService.tags(),
|
||||
settings: SettingsService.settings(),
|
||||
})
|
||||
.then(function success(data) {
|
||||
$scope.groups = data.groups;
|
||||
$scope.availableTags = data.tags;
|
||||
|
||||
const settings = data.settings;
|
||||
$scope.state.availableEdgeAgentCheckinOptions[0].key += ` (${settings.EdgeAgentCheckinInterval} seconds)`;
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to load groups');
|
||||
|
|
|
@ -145,8 +145,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<!-- !endpoint-url-input -->
|
||||
<!-- portainer-instance-input -->
|
||||
<div ng-if="state.EnvironmentType === 'edge_agent'">
|
||||
<!-- portainer-instance-input -->
|
||||
<div class="form-group">
|
||||
<label for="endpoint_url" class="col-sm-3 col-lg-2 control-label text-left">
|
||||
Portainer server URL
|
||||
|
@ -163,8 +163,25 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- !portainer-instance-input -->
|
||||
<div class="form-group">
|
||||
<label for="edge_checkin" class="col-sm-2 control-label text-left">
|
||||
Poll frequency
|
||||
<portainer-tooltip
|
||||
position="bottom"
|
||||
message="Interval used by this Edge agent to check in with the Portainer instance. Affects Edge endpoint management and Edge compute features."
|
||||
></portainer-tooltip>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<select
|
||||
id="edge_checkin"
|
||||
class="form-control"
|
||||
ng-model="formValues.CheckinInterval"
|
||||
ng-options="+(opt.value) as opt.key for opt in state.availableEdgeAgentCheckinOptions"
|
||||
></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- !portainer-instance-input -->
|
||||
<!-- endpoint-public-url-input -->
|
||||
<div ng-if="state.EnvironmentType === 'docker' || state.EnvironmentType === 'agent'">
|
||||
<div class="form-group">
|
||||
|
|
|
@ -36,10 +36,10 @@
|
|||
<div style="margin-top: 10px;">
|
||||
<uib-tabset active="state.deploymentTab">
|
||||
<uib-tab index="0" heading="Standalone">
|
||||
<code style="display: block; white-space: pre-wrap; padding: 16px 90px;">{{dockerCommands.standalone}}</code>
|
||||
<code style="display: block; white-space: pre-wrap; padding: 16px 90px;">{{ dockerCommands.standalone }}</code>
|
||||
</uib-tab>
|
||||
<uib-tab index="1" heading="Swarm">
|
||||
<code style="display: block; white-space: pre-wrap; padding: 16px 90px;">{{dockerCommands.swarm}}</code>
|
||||
<code style="display: block; white-space: pre-wrap; padding: 16px 90px;">{{ dockerCommands.swarm }}</code>
|
||||
</uib-tab>
|
||||
</uib-tabset>
|
||||
<div style="margin-top: 10px;">
|
||||
|
@ -118,6 +118,23 @@
|
|||
<input type="text" class="form-control" id="endpoint_public_url" ng-model="endpoint.PublicURL" placeholder="e.g. 10.0.0.10 or mydocker.mydomain.com" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edge_checkin" class="col-sm-2 control-label text-left">
|
||||
Poll frequency
|
||||
<portainer-tooltip
|
||||
position="bottom"
|
||||
message="Interval used by this Edge agent to check in with the Portainer instance. Affects Edge endpoint management and Edge compute features."
|
||||
></portainer-tooltip>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<select
|
||||
id="edge_checkin"
|
||||
class="form-control"
|
||||
ng-model="endpoint.EdgeCheckinInterval"
|
||||
ng-options="+(opt.value) as opt.key for opt in state.availableEdgeAgentCheckinOptions"
|
||||
></select>
|
||||
</div>
|
||||
</div>
|
||||
<!-- !endpoint-public-url-input -->
|
||||
<div class="col-sm-12 form-section-title">
|
||||
Metadata
|
||||
|
|
|
@ -17,13 +17,32 @@ angular
|
|||
TagService,
|
||||
EndpointProvider,
|
||||
Notifications,
|
||||
Authentication
|
||||
Authentication,
|
||||
SettingsService
|
||||
) {
|
||||
$scope.state = {
|
||||
uploadInProgress: false,
|
||||
actionInProgress: false,
|
||||
deploymentTab: 0,
|
||||
allowCreate: Authentication.isAdmin(),
|
||||
availableEdgeAgentCheckinOptions: [
|
||||
{ key: 'Use default interval', value: 0 },
|
||||
{
|
||||
key: '5 seconds',
|
||||
value: 5,
|
||||
},
|
||||
{
|
||||
key: '10 seconds',
|
||||
value: 10,
|
||||
},
|
||||
{
|
||||
key: '30 seconds',
|
||||
value: 30,
|
||||
},
|
||||
{ key: '5 minutes', value: 300 },
|
||||
{ key: '1 hour', value: 3600 },
|
||||
{ key: '1 day', value: 86400 },
|
||||
],
|
||||
};
|
||||
|
||||
$scope.formValues = {
|
||||
|
@ -83,6 +102,7 @@ angular
|
|||
PublicURL: endpoint.PublicURL,
|
||||
GroupID: endpoint.GroupId,
|
||||
TagIds: endpoint.TagIds,
|
||||
EdgeCheckinInterval: endpoint.EdgeCheckinInterval,
|
||||
TLS: TLS,
|
||||
TLSSkipVerify: TLSSkipVerify,
|
||||
TLSSkipClientVerify: TLSSkipClientVerify,
|
||||
|
@ -133,6 +153,7 @@ angular
|
|||
endpoint: EndpointService.endpoint($transition$.params().id),
|
||||
groups: GroupService.groups(),
|
||||
tags: TagService.tags(),
|
||||
settings: SettingsService.settings(),
|
||||
})
|
||||
.then(function success(data) {
|
||||
var endpoint = data.endpoint;
|
||||
|
@ -149,6 +170,9 @@ angular
|
|||
standalone: buildStandaloneCommand($scope.randomEdgeID, endpoint.EdgeKey),
|
||||
swarm: buildSwarmCommand($scope.randomEdgeID, endpoint.EdgeKey),
|
||||
};
|
||||
|
||||
const settings = data.settings;
|
||||
$scope.state.availableEdgeAgentCheckinOptions[0].key += ` (${settings.EdgeAgentCheckinInterval} seconds)`;
|
||||
}
|
||||
$scope.endpoint = endpoint;
|
||||
$scope.groups = data.groups;
|
||||
|
|
|
@ -118,8 +118,11 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edge_checkin" class="col-sm-2 control-label text-left">
|
||||
Edge agent poll frequency
|
||||
<portainer-tooltip position="bottom" message="Specify the interval used by each Edge agent to checkin with the Portainer instance"></portainer-tooltip>
|
||||
Edge agent default poll frequency
|
||||
<portainer-tooltip
|
||||
position="bottom"
|
||||
message="Interval used by default by each Edge agent to check in with the Portainer instance. Affects Edge endpoint management and Edge compute features."
|
||||
></portainer-tooltip>
|
||||
</label>
|
||||
<div class="col-sm-10">
|
||||
<select
|
||||
|
|
Loading…
Reference in New Issue