mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-08 18:21:18 +08:00
[NET-404] Run in limited mode when ee checks fail (#2474)
* Add limited http handlers functionality to rest handler * Export ee.errValidation (ee.ErrValidation) * Export a fatal error handled by the hook manager * Export a new status variable for unlicensed server * Mark server as unlicensed when ee checks fail * Handle license validation failures with a (re)boot in a limited state * Revert "Export a fatal error handled by the hook manager" This reverts commit 069c21974a8d36e889c73ad78023448d787d62a5. * Revert "Export ee.errValidation (ee.ErrValidation)" This reverts commit 59dbab8c79773ca5d879f28cbaf53f3dd4297b9b. * Revert "Add limited http handlers functionality to rest handler" This reverts commit e2f1f28facaca54713db76a588839cd2733cf673. * Revert "Handle license validation failures with a (re)boot in a limited state" This reverts commit 58cfbbaf522a1345aac1fa67964ebff0a6d60cd8. * Revert "Mark server as unlicensed when ee checks fail" This reverts commit 77c6dbdd3c9cfa6e7d6becedef6251e8617ae367. * Handle license validation failures with a middleware * Forbid responses if unlicensed ee and not in status api * Remove unused func
This commit is contained in:

committed by
GitHub

parent
a021e2659e
commit
922e7dbf2c
@@ -3,10 +3,11 @@ package logic
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gravitl/netmaker/logger"
|
||||
"golang.org/x/exp/slog"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/gravitl/netmaker/logger"
|
||||
"github.com/gravitl/netmaker/models"
|
||||
)
|
||||
|
||||
@@ -52,7 +53,7 @@ func StartHookManager(ctx context.Context, wg *sync.WaitGroup) {
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
logger.Log(0, "## Stopping Hook Manager")
|
||||
slog.Error("## Stopping Hook Manager")
|
||||
return
|
||||
case newhook := <-HookManagerCh:
|
||||
wg.Add(1)
|
||||
@@ -70,7 +71,9 @@ func addHookWithInterval(ctx context.Context, wg *sync.WaitGroup, hook func() er
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-ticker.C:
|
||||
hook()
|
||||
if err := hook(); err != nil {
|
||||
slog.Error(err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +88,7 @@ var timeHooks = []interface{}{
|
||||
}
|
||||
|
||||
func loggerDump() error {
|
||||
// TODO use slog?
|
||||
logger.DumpFile(fmt.Sprintf("data/netmaker.log.%s", time.Now().Format(logger.TimeFormatDay)))
|
||||
return nil
|
||||
}
|
||||
@@ -93,7 +97,7 @@ func loggerDump() error {
|
||||
func runHooks() {
|
||||
for _, hook := range timeHooks {
|
||||
if err := hook.(func() error)(); err != nil {
|
||||
logger.Log(1, "error occurred when running timer function:", err.Error())
|
||||
slog.Error("error occurred when running timer function", "error", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user