Compare commits

..

4 Commits

Author SHA1 Message Date
Igor Gov
371e513249 Remove config dependency from basenine init (#846)
* Remove config dependency from basenine init
2022-02-23 10:06:19 +02:00
Igor Gov
97cce32e3f Fix: service map component aware of agent config (#845)
* Fix: Service map component aware of mizu config
2022-02-23 09:35:05 +02:00
Igor Gov
d2e91b4ffa Fix: tapper tries to load agent config map (#844) 2022-02-23 09:20:19 +02:00
Alex Haiut
d5a42a66de apply install typo fix to develop (already in master) (#840)
Co-authored-by: gadotroee <55343099+gadotroee@users.noreply.github.com>
2022-02-22 16:02:33 +02:00
6 changed files with 20 additions and 33 deletions

View File

@@ -58,9 +58,7 @@ func main() {
logLevel := determineLogLevel() logLevel := determineLogLevel()
logger.InitLoggerStd(logLevel) logger.InitLoggerStd(logLevel)
flag.Parse() flag.Parse()
if err := config.LoadConfig(); err != nil {
logger.Log.Fatalf("Error loading config file %v", err)
}
app.LoadExtensions() app.LoadExtensions()
if !*tapperMode && !*apiServerMode && !*standaloneMode && !*harsReaderMode { if !*tapperMode && !*apiServerMode && !*standaloneMode && !*harsReaderMode {
@@ -139,7 +137,10 @@ func hostApi(socketHarOutputChannel chan<- *tapApi.OutputChannelItem) *gin.Engin
} }
func runInApiServerMode(namespace string) *gin.Engine { func runInApiServerMode(namespace string) *gin.Engine {
app.ConfigureBasenineServer(shared.BasenineHost, shared.BaseninePort) if err := config.LoadConfig(); err != nil {
logger.Log.Fatalf("Error loading config file %v", err)
}
app.ConfigureBasenineServer(shared.BasenineHost, shared.BaseninePort, config.Config.MaxDBSizeBytes, config.Config.LogLevel)
startTime = time.Now().UnixNano() / int64(time.Millisecond) startTime = time.Now().UnixNano() / int64(time.Millisecond)
api.StartResolving(namespace) api.StartResolving(namespace)
@@ -215,7 +216,7 @@ func enableExpFeatureIfNeeded() {
oas.GetOasGeneratorInstance().Start() oas.GetOasGeneratorInstance().Start()
} }
if config.Config.ServiceMap { if config.Config.ServiceMap {
servicemap.GetInstance().SetConfig(config.Config) servicemap.GetInstance().Enable()
} }
elastic.GetInstance().Configure(config.Config.Elastic) elastic.GetInstance().Configure(config.Config.Elastic)
} }

View File

@@ -9,7 +9,6 @@ import (
"github.com/op/go-logging" "github.com/op/go-logging"
basenine "github.com/up9inc/basenine/client/go" basenine "github.com/up9inc/basenine/client/go"
"github.com/up9inc/mizu/agent/pkg/api" "github.com/up9inc/mizu/agent/pkg/api"
"github.com/up9inc/mizu/agent/pkg/config"
"github.com/up9inc/mizu/agent/pkg/controllers" "github.com/up9inc/mizu/agent/pkg/controllers"
"github.com/up9inc/mizu/shared/logger" "github.com/up9inc/mizu/shared/logger"
tapApi "github.com/up9inc/mizu/tap/api" tapApi "github.com/up9inc/mizu/tap/api"
@@ -63,20 +62,18 @@ func LoadExtensions() {
controllers.InitExtensionsMap(ExtensionsMap) controllers.InitExtensionsMap(ExtensionsMap)
} }
func ConfigureBasenineServer(host string, port string) { func ConfigureBasenineServer(host string, port string, dbSize int64, logLevel logging.Level) {
if !wait.New( if !wait.New(
wait.WithProto("tcp"), wait.WithProto("tcp"),
wait.WithWait(200*time.Millisecond), wait.WithWait(200*time.Millisecond),
wait.WithBreak(50*time.Millisecond), wait.WithBreak(50*time.Millisecond),
wait.WithDeadline(5*time.Second), wait.WithDeadline(5*time.Second),
wait.WithDebug(config.Config.LogLevel == logging.DEBUG), wait.WithDebug(logLevel == logging.DEBUG),
).Do([]string{fmt.Sprintf("%s:%s", host, port)}) { ).Do([]string{fmt.Sprintf("%s:%s", host, port)}) {
logger.Log.Panicf("Basenine is not available!") logger.Log.Panicf("Basenine is not available!")
} }
// Limit the database size to default 200MB if err := basenine.Limit(host, port, dbSize); err != nil {
err := basenine.Limit(host, port, config.Config.MaxDBSizeBytes)
if err != nil {
logger.Log.Panicf("Error while limiting database size: %v", err) logger.Log.Panicf("Error while limiting database size: %v", err)
} }
@@ -84,8 +81,7 @@ func ConfigureBasenineServer(host string, port string) {
for _, extension := range Extensions { for _, extension := range Extensions {
macros := extension.Dissector.Macros() macros := extension.Dissector.Macros()
for macro, expanded := range macros { for macro, expanded := range macros {
err = basenine.Macro(host, port, macro, expanded) if err := basenine.Macro(host, port, macro, expanded); err != nil {
if err != nil {
logger.Log.Panicf("Error while adding a macro: %v", err) logger.Log.Panicf("Error while adding a macro: %v", err)
} }
} }

View File

@@ -11,7 +11,6 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/up9inc/mizu/shared"
tapApi "github.com/up9inc/mizu/tap/api" tapApi "github.com/up9inc/mizu/tap/api"
) )
@@ -59,9 +58,7 @@ type ServiceMapControllerSuite struct {
func (s *ServiceMapControllerSuite) SetupTest() { func (s *ServiceMapControllerSuite) SetupTest() {
s.c = NewServiceMapController() s.c = NewServiceMapController()
s.c.service.SetConfig(&shared.MizuAgentConfig{ s.c.service.Enable()
ServiceMap: true,
})
s.c.service.NewTCPEntry(TCPEntryA, TCPEntryB, ProtocolHttp) s.c.service.NewTCPEntry(TCPEntryA, TCPEntryB, ProtocolHttp)
s.w = httptest.NewRecorder() s.w = httptest.NewRecorder()

View File

@@ -3,7 +3,6 @@ package servicemap
import ( import (
"sync" "sync"
"github.com/up9inc/mizu/shared"
"github.com/up9inc/mizu/shared/logger" "github.com/up9inc/mizu/shared/logger"
tapApi "github.com/up9inc/mizu/tap/api" tapApi "github.com/up9inc/mizu/tap/api"
) )
@@ -26,13 +25,13 @@ func GetInstance() ServiceMap {
} }
type serviceMap struct { type serviceMap struct {
config *shared.MizuAgentConfig enabled bool
graph *graph graph *graph
entriesProcessed int entriesProcessed int
} }
type ServiceMap interface { type ServiceMap interface {
SetConfig(config *shared.MizuAgentConfig) Enable()
IsEnabled() bool IsEnabled() bool
NewTCPEntry(source *tapApi.TCP, destination *tapApi.TCP, protocol *tapApi.Protocol) NewTCPEntry(source *tapApi.TCP, destination *tapApi.TCP, protocol *tapApi.Protocol)
GetStatus() ServiceMapStatus GetStatus() ServiceMapStatus
@@ -46,7 +45,7 @@ type ServiceMap interface {
func newServiceMap() *serviceMap { func newServiceMap() *serviceMap {
return &serviceMap{ return &serviceMap{
config: nil, enabled: false,
entriesProcessed: 0, entriesProcessed: 0,
graph: newDirectedGraph(), graph: newDirectedGraph(),
} }
@@ -156,15 +155,12 @@ func (s *serviceMap) addEdge(u, v *entryData, p *tapApi.Protocol) {
s.entriesProcessed++ s.entriesProcessed++
} }
func (s *serviceMap) SetConfig(config *shared.MizuAgentConfig) { func (s *serviceMap) Enable() {
s.config = config s.enabled = true
} }
func (s *serviceMap) IsEnabled() bool { func (s *serviceMap) IsEnabled() bool {
if s.config != nil && s.config.ServiceMap { return s.enabled
return true
}
return false
} }
func (s *serviceMap) NewTCPEntry(src *tapApi.TCP, dst *tapApi.TCP, p *tapApi.Protocol) { func (s *serviceMap) NewTCPEntry(src *tapApi.TCP, dst *tapApi.TCP, p *tapApi.Protocol) {

View File

@@ -6,7 +6,6 @@ import (
"testing" "testing"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/up9inc/mizu/shared"
tapApi "github.com/up9inc/mizu/tap/api" tapApi "github.com/up9inc/mizu/tap/api"
) )
@@ -96,9 +95,7 @@ func (s *ServiceMapDisabledSuite) SetupTest() {
func (s *ServiceMapEnabledSuite) SetupTest() { func (s *ServiceMapEnabledSuite) SetupTest() {
s.instance = GetInstance() s.instance = GetInstance()
s.instance.SetConfig(&shared.MizuAgentConfig{ s.instance.Enable()
ServiceMap: true,
})
} }
func (s *ServiceMapDisabledSuite) TestServiceMapInstance() { func (s *ServiceMapDisabledSuite) TestServiceMapInstance() {

View File

@@ -14,10 +14,10 @@ var installCmd = &cobra.Command{
logger.Log.Infof("This command has been deprecated, please use helm as described below.\n\n") logger.Log.Infof("This command has been deprecated, please use helm as described below.\n\n")
logger.Log.Infof("To install stable build of Mizu on your cluster using helm, run the following command:") logger.Log.Infof("To install stable build of Mizu on your cluster using helm, run the following command:")
logger.Log.Infof(" helm install mizu https://static.up9.com/mizu/helm --namespace=mizu --create-namespace\n\n") logger.Log.Infof(" helm install mizu mizu --repo https://static.up9.com/mizu/helm --namespace=mizu --create-namespace\n\n")
logger.Log.Infof("To install development build of Mizu on your cluster using helm, run the following command:") logger.Log.Infof("To install development build of Mizu on your cluster using helm, run the following command:")
logger.Log.Infof(" helm install mizu https://static.up9.com/mizu/helm-develop --namespace=mizu --create-namespace") logger.Log.Infof(" helm install mizu mizu --repo https://static.up9.com/mizu/helm-develop --namespace=mizu --create-namespace\n")
return nil return nil
}, },