Drop unreleased features (record & replay) (#1406)
1. The records are stored in redis which is not migratable to another cluster for the testing purposes. 2. Some of the requests fields are not recorded. 3. People should consider using https://github.com/buger/goreplay which is an existing mature and well-tested solution for testing purposes.
This commit is contained in:
@@ -53,14 +53,13 @@ type HTTPTriggerSet struct {
|
||||
functions []fv1.Function
|
||||
funcStore k8sCache.Store
|
||||
funcController k8sCache.Controller
|
||||
recorderSet *RecorderSet
|
||||
updateRouterRequestChannel chan struct{}
|
||||
tsRoundTripperParams *tsRoundTripperParams
|
||||
isDebugEnv bool
|
||||
svcAddrUpdateThrottler *throttler.Throttler
|
||||
}
|
||||
|
||||
func makeHTTPTriggerSet(logger *zap.Logger, fmap *functionServiceMap, frmap *functionRecorderMap, trmap *triggerRecorderMap, fissionClient *crd.FissionClient,
|
||||
func makeHTTPTriggerSet(logger *zap.Logger, fmap *functionServiceMap, fissionClient *crd.FissionClient,
|
||||
kubeClient *kubernetes.Clientset, executor *executorClient.Client, crdClient *rest.RESTClient, params *tsRoundTripperParams, isDebugEnv bool, actionThrottler *throttler.Throttler) (*HTTPTriggerSet, k8sCache.Store, k8sCache.Store) {
|
||||
|
||||
httpTriggerSet := &HTTPTriggerSet{
|
||||
@@ -76,9 +75,9 @@ func makeHTTPTriggerSet(logger *zap.Logger, fmap *functionServiceMap, frmap *fun
|
||||
isDebugEnv: isDebugEnv,
|
||||
svcAddrUpdateThrottler: actionThrottler,
|
||||
}
|
||||
var tStore, fnStore, rStore k8sCache.Store
|
||||
var tStore, fnStore k8sCache.Store
|
||||
var tController, fnController k8sCache.Controller
|
||||
var recorderSet *RecorderSet
|
||||
|
||||
if httpTriggerSet.crdClient != nil {
|
||||
tStore, tController = httpTriggerSet.initTriggerController()
|
||||
httpTriggerSet.triggerStore = tStore
|
||||
@@ -87,8 +86,6 @@ func makeHTTPTriggerSet(logger *zap.Logger, fmap *functionServiceMap, frmap *fun
|
||||
httpTriggerSet.funcStore = fnStore
|
||||
httpTriggerSet.funcController = fnController
|
||||
}
|
||||
recorderSet = MakeRecorderSet(logger, httpTriggerSet, crdClient, rStore, frmap, trmap)
|
||||
httpTriggerSet.recorderSet = recorderSet
|
||||
return httpTriggerSet, tStore, fnStore
|
||||
}
|
||||
|
||||
@@ -106,11 +103,6 @@ func (ts *HTTPTriggerSet) subscribeRouter(ctx context.Context, mr *mutableRouter
|
||||
go ts.syncTriggers()
|
||||
go ts.runWatcher(ctx, ts.funcController)
|
||||
go ts.runWatcher(ctx, ts.triggerController)
|
||||
if ts.recorderSet.recController != nil {
|
||||
go ts.runWatcher(ctx, ts.recorderSet.recController)
|
||||
} else {
|
||||
ts.logger.Fatal("failed to run recorder controller")
|
||||
}
|
||||
}
|
||||
|
||||
func defaultHomeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -140,12 +132,6 @@ func (ts *HTTPTriggerSet) getRouter(fnTimeoutMap map[types.UID]int) *mux.Router
|
||||
continue
|
||||
}
|
||||
|
||||
var recorderName string
|
||||
recorder, err := ts.recorderSet.triggerRecorderMap.lookup(trigger.Metadata.Name)
|
||||
if err == nil && recorder != nil {
|
||||
recorderName = recorder.Spec.Name
|
||||
}
|
||||
|
||||
if rr.resolveResultType != resolveResultSingleFunction && rr.resolveResultType != resolveResultMultipleFunctions {
|
||||
// not implemented yet
|
||||
ts.logger.Panic("resolve result type not implemented", zap.Any("type", rr.resolveResultType))
|
||||
@@ -154,14 +140,11 @@ func (ts *HTTPTriggerSet) getRouter(fnTimeoutMap map[types.UID]int) *mux.Router
|
||||
fh := &functionHandler{
|
||||
logger: ts.logger.Named(trigger.Metadata.Name),
|
||||
fmap: ts.functionServiceMap,
|
||||
frmap: ts.recorderSet.functionRecorderMap,
|
||||
trmap: ts.recorderSet.triggerRecorderMap,
|
||||
executor: ts.executor,
|
||||
httpTrigger: &trigger,
|
||||
functionMetadataMap: rr.functionMetadataMap,
|
||||
fnWeightDistributionList: rr.functionWtDistributionList,
|
||||
tsRoundTripperParams: ts.tsRoundTripperParams,
|
||||
recorderName: recorderName,
|
||||
isDebugEnv: ts.isDebugEnv,
|
||||
svcAddrUpdateThrottler: ts.svcAddrUpdateThrottler,
|
||||
functionTimeoutMap: fnTimeoutMap,
|
||||
@@ -205,21 +188,12 @@ func (ts *HTTPTriggerSet) getRouter(fnTimeoutMap map[types.UID]int) *mux.Router
|
||||
for _, function := range ts.functions {
|
||||
m := function.Metadata
|
||||
|
||||
var recorderName string
|
||||
recorder, err := ts.recorderSet.functionRecorderMap.lookup(m.Name)
|
||||
if err == nil && recorder != nil {
|
||||
recorderName = recorder.Spec.Name
|
||||
}
|
||||
|
||||
fh := &functionHandler{
|
||||
logger: ts.logger.Named(m.Name),
|
||||
fmap: ts.functionServiceMap,
|
||||
frmap: ts.recorderSet.functionRecorderMap,
|
||||
trmap: ts.recorderSet.triggerRecorderMap,
|
||||
function: &m,
|
||||
executor: ts.executor,
|
||||
tsRoundTripperParams: ts.tsRoundTripperParams,
|
||||
recorderName: recorderName,
|
||||
isDebugEnv: ts.isDebugEnv,
|
||||
svcAddrUpdateThrottler: ts.svcAddrUpdateThrottler,
|
||||
functionTimeoutMap: fnTimeoutMap,
|
||||
@@ -246,20 +220,11 @@ func (ts *HTTPTriggerSet) initTriggerController() (k8sCache.Store, k8sCache.Cont
|
||||
trigger := obj.(*fv1.HTTPTrigger)
|
||||
go createIngress(ts.logger, trigger, ts.kubeClient)
|
||||
ts.syncTriggers()
|
||||
// Check if this trigger's function needs to be recorded
|
||||
fnRef := trigger.Spec.FunctionReference.Name
|
||||
recorder, err := ts.recorderSet.functionRecorderMap.lookup(fnRef)
|
||||
if err == nil {
|
||||
if len(recorder.Spec.Triggers) == 0 {
|
||||
ts.recorderSet.triggerRecorderMap.assign(trigger.Metadata.Name, recorder)
|
||||
}
|
||||
}
|
||||
},
|
||||
DeleteFunc: func(obj interface{}) {
|
||||
ts.syncTriggers()
|
||||
trigger := obj.(*fv1.HTTPTrigger)
|
||||
go deleteIngress(ts.logger, trigger, ts.kubeClient)
|
||||
go ts.recorderSet.DeleteTriggerFromRecorderMap(trigger)
|
||||
},
|
||||
UpdateFunc: func(oldObj interface{}, newObj interface{}) {
|
||||
oldTrigger := oldObj.(*fv1.HTTPTrigger)
|
||||
@@ -285,9 +250,7 @@ func (ts *HTTPTriggerSet) initFunctionController() (k8sCache.Store, k8sCache.Con
|
||||
ts.syncTriggers()
|
||||
},
|
||||
DeleteFunc: func(obj interface{}) {
|
||||
function := obj.(*fv1.Function)
|
||||
ts.syncTriggers()
|
||||
go ts.recorderSet.DeleteFunctionFromRecorderMap(function)
|
||||
},
|
||||
UpdateFunc: func(oldObj interface{}, newObj interface{}) {
|
||||
oldFn := oldObj.(*fv1.Function)
|
||||
@@ -317,29 +280,6 @@ func (ts *HTTPTriggerSet) initFunctionController() (k8sCache.Store, k8sCache.Con
|
||||
return store, controller
|
||||
}
|
||||
|
||||
func (ts *HTTPTriggerSet) initRecorderController() (k8sCache.Store, k8sCache.Controller) {
|
||||
resyncPeriod := 30 * time.Second
|
||||
listWatch := k8sCache.NewListWatchFromClient(ts.crdClient, "recorders", metav1.NamespaceAll, fields.Everything())
|
||||
store, controller := k8sCache.NewInformer(listWatch, &fv1.Recorder{}, resyncPeriod,
|
||||
k8sCache.ResourceEventHandlerFuncs{
|
||||
AddFunc: func(obj interface{}) {
|
||||
recorder := obj.(*fv1.Recorder)
|
||||
ts.recorderSet.newRecorder(recorder)
|
||||
},
|
||||
DeleteFunc: func(obj interface{}) {
|
||||
recorder := obj.(*fv1.Recorder)
|
||||
ts.recorderSet.disableRecorder(recorder)
|
||||
},
|
||||
UpdateFunc: func(oldObj, newObj interface{}) {
|
||||
oldRecorder := oldObj.(*fv1.Recorder)
|
||||
newRecorder := newObj.(*fv1.Recorder)
|
||||
ts.recorderSet.updateRecorder(oldRecorder, newRecorder)
|
||||
},
|
||||
},
|
||||
)
|
||||
return store, controller
|
||||
}
|
||||
|
||||
func (ts *HTTPTriggerSet) runWatcher(ctx context.Context, controller k8sCache.Controller) {
|
||||
go func() {
|
||||
controller.Run(ctx.Done())
|
||||
|
||||
Reference in New Issue
Block a user