Skip to content

Commit

Permalink
Merge pull request #1568 from openziti/add-max-idle-time
Browse files Browse the repository at this point in the history
add max idle time
  • Loading branch information
plorenz authored Dec 11, 2023
2 parents bd36be0 + 9ddd1b9 commit 08a8449
Show file tree
Hide file tree
Showing 35 changed files with 1,078 additions and 952 deletions.
183 changes: 97 additions & 86 deletions common/pb/cmd_pb/cmd.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions common/pb/cmd_pb/cmd.proto
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ message Service {
string name = 2;
string terminatorStrategy = 3;
map<string, TagValue> tags = 4;
int64 maxIdleTime = 5;
}

message Router {
Expand Down
798 changes: 411 additions & 387 deletions common/pb/ctrl_pb/ctrl.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions common/pb/ctrl_pb/ctrl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum ContentType {
DequiesceRouterRequestType = 1040;
ValidateTerminatorsV2RequestType = 1041;
ValidateTerminatorsV2ResponseType = 1042;
DecommissionRouterRequestType = 1043;

PeerStateChangeRequestType = 1050;

Expand Down Expand Up @@ -73,6 +74,7 @@ message CircuitRequest {

message CircuitConfirmation {
repeated string circuitIds = 1;
map<string, int64> idleTimes = 2;
}

enum TerminatorPrecedence {
Expand Down
250 changes: 130 additions & 120 deletions common/pb/edge_cmd_pb/edge_cmd.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions common/pb/edge_cmd_pb/edge_cmd.proto
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ message Service {
repeated string roleAttributes = 5;
repeated string configs = 6;
bool encryptionRequired = 7;
int64 maxIdleTime = 8;
}

// Service Edge Router Policies
Expand Down
2 changes: 1 addition & 1 deletion common/pb/edge_ctrl_pb/edge_ctrl.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/pb/edge_mgmt_pb/edge_mgmt.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

119 changes: 63 additions & 56 deletions common/pb/mgmt_pb/mgmt.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions common/pb/mgmt_pb/mgmt.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ enum ContentType {
RouterDebugDumpForwarderTablesRequestType = 10074;
RouterDebugDumpLinksRequestType = 10075;
RouterDebugUnrouteRequestType = 10076;
RouterQuiesce = 10077;
RouterDequiesce = 10078;
RouterQuiesceRequestType = 10077;
RouterDequiesceRequestType = 10078;
RouterDecommissionRequestType = 10079;

// Raft
RaftListMembersRequestType = 10080;
Expand Down
8 changes: 6 additions & 2 deletions controller/api_impl/circuit_api_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (factory *CircuitLinkFactoryIml) Links(entity LinkEntity) rest_model.Links
return links
}

func MapCircuitToRestModel(_ *network.Network, _ api.RequestContext, circuit *network.Circuit) (*rest_model.CircuitDetail, error) {
func MapCircuitToRestModel(n *network.Network, _ api.RequestContext, circuit *network.Circuit) (*rest_model.CircuitDetail, error) {
path := &rest_model.Path{}
for _, node := range circuit.Path.Nodes {
path.Nodes = append(path.Nodes, ToEntityRef(node.Name, node, RouterLinkFactory))
Expand All @@ -53,11 +53,15 @@ func MapCircuitToRestModel(_ *network.Network, _ api.RequestContext, circuit *ne
path.Links = append(path.Links, ToEntityRef(link.Id, link, LinkLinkFactory))
}

svc, err := n.Services.Read(circuit.ServiceId)
if err != nil {
return nil, err
}
ret := &rest_model.CircuitDetail{
BaseEntity: BaseEntityToRestModel(circuit, CircuitLinkFactory),
ClientID: circuit.ClientId,
Path: path,
Service: ToEntityRef(circuit.Service.Name, circuit.Service, ServiceLinkFactory),
Service: ToEntityRef(svc.Name, svc, ServiceLinkFactory),
Terminator: ToEntityRef(circuit.Terminator.GetId(), circuit.Terminator, TerminatorLinkFactory),
}

Expand Down
13 changes: 9 additions & 4 deletions controller/db/service_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@
package db

import (
"github.com/openziti/ziti/controller/xt"
"github.com/openziti/ziti/controller/xt_smartrouting"
"github.com/openziti/storage/ast"
"github.com/openziti/storage/boltz"
"github.com/openziti/ziti/controller/xt"
"github.com/openziti/ziti/controller/xt_smartrouting"
"go.etcd.io/bbolt"
"time"
)

const (
EntityTypeServices = "services"
FieldServiceTerminatorStrategy = "terminatorStrategy"
FieldServiceMaxIdleTime = "maxIdleTime"
)

type Service struct {
boltz.BaseExtEntity
Name string `json:"name"`
TerminatorStrategy string `json:"terminatorStrategy"`
Name string `json:"name"`
MaxIdleTime time.Duration `json:"maxIdleTime"`
TerminatorStrategy string `json:"terminatorStrategy"`
}

func (entity *Service) GetEntityType() string {
Expand Down Expand Up @@ -91,11 +94,13 @@ func (store *serviceStoreImpl) FillEntity(entity *Service, bucket *boltz.TypedBu
entity.LoadBaseValues(bucket)
entity.Name = bucket.GetStringOrError(FieldName)
entity.TerminatorStrategy = bucket.GetStringWithDefault(FieldServiceTerminatorStrategy, "")
entity.MaxIdleTime = time.Duration(bucket.GetInt64WithDefault(FieldServiceMaxIdleTime, 0))
}

func (store *serviceStoreImpl) PersistEntity(entity *Service, ctx *boltz.PersistContext) {
entity.SetBaseValues(ctx)
ctx.SetString(FieldName, entity.Name)
ctx.SetInt64(FieldServiceMaxIdleTime, int64(entity.MaxIdleTime))

if entity.TerminatorStrategy == "" {
entity.TerminatorStrategy = xt_smartrouting.Name
Expand Down
9 changes: 9 additions & 0 deletions controller/fields/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type UpdatedFields interface {
RemoveFields(fields ...string) UpdatedFields
ConcatNestedNames() UpdatedFields
FilterMaps(mapNames ...string) UpdatedFields
MapField(old, new string) UpdatedFields
}

var _ UpdatedFields = (UpdatedFieldsMap)(nil)
Expand Down Expand Up @@ -96,6 +97,14 @@ func (self UpdatedFieldsMap) FilterMaps(mapNames ...string) UpdatedFields {
return self
}

func (self UpdatedFieldsMap) MapField(old, new string) UpdatedFields {
if _, ok := self[old]; ok {
delete(self, old)
self[new] = struct{}{}
}
return self
}

func UpdatedFieldsToSlice(fields UpdatedFields) ([]string, error) {
if fields == nil {
return nil, nil
Expand Down
5 changes: 3 additions & 2 deletions controller/handler_ctrl/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import (
"github.com/michaelquigley/pfxlog"
"github.com/openziti/channel/v2"
"github.com/openziti/channel/v2/latency"
"github.com/openziti/foundation/v2/concurrenz"
"github.com/openziti/metrics"
"github.com/openziti/ziti/common/trace"
"github.com/openziti/ziti/controller/network"
"github.com/openziti/ziti/controller/xctrl"
metrics2 "github.com/openziti/ziti/router/metrics"
"github.com/openziti/foundation/v2/concurrenz"
"github.com/openziti/metrics"
)

type bindHandler struct {
Expand Down Expand Up @@ -70,6 +70,7 @@ func (self *bindHandler) BindChannel(binding channel.Binding) error {
binding.AddTypedReceiveHandler(newInspectHandler(self.network))
binding.AddTypedReceiveHandler(newQuiesceRouterHandler(self.router, self.network))
binding.AddTypedReceiveHandler(newDequiesceRouterHandler(self.router, self.network))
binding.AddTypedReceiveHandler(newDecommissionRouterHandler(self.router, self.network))
binding.AddTypedReceiveHandler(newPingHandler())
binding.AddPeekHandler(trace.NewChannelPeekHandler(self.network.GetAppId(), binding.GetChannel(), self.network.GetTraceController()))
binding.AddPeekHandler(metrics2.NewCtrlChannelPeekHandler(self.router.Id, self.network.GetMetricsRegistry()))
Expand Down
Loading

0 comments on commit 08a8449

Please sign in to comment.