Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix : mTLS bug fix #355

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions agent/container/pkg/clients/nats_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,29 @@ func NewNATSContext(conf *config.Config) (*NATSContext, error) {
//conn, err := nats.Connect(conf.NatsAddress, nats.Name("Github metrics"), nats.Token(conf.NatsToken))
var conn *nats.Conn
var err error
var mtlsConfig mtlsnats.MtlsConfig
//var mtlsConfig mtlsnats.MtlsConfig

if mtlsConfig.IsEnabled {
tlsConfig, err := mtlsnats.GetTlsConfig()
tlsConfig, err := mtlsnats.GetTlsConfig()
if err != nil {
log.Println("error while getting tls config ", err)
time.Sleep(time.Minute * 30)
} else {
conn, err = nats.Connect(conf.NatsAddress,
nats.Name("Github metrics"),
//nats.Token(conf.NatsToken),
nats.Secure(tlsConfig),
)
if err != nil {
log.Println("error while getting tls config ", err)
time.Sleep(time.Minute * 30)
} else {
conn, err = nats.Connect(conf.NatsAddress,
nats.Name("Github metrics"),
nats.Token(conf.NatsToken),
nats.Secure(tlsConfig),
)
if err != nil {
log.Println("error while connecting with mtls ", err)
}
log.Fatal("error while connecting with mtls ", err)
}

}

if conn == nil {
conn, err = nats.Connect(conf.NatsAddress, nats.Name("Github metrics"), nats.Token(conf.NatsToken))
if err != nil {
return nil, fmt.Errorf("error while connecting with token: %w", err)
}
}
// if conn == nil {
// conn, err = nats.Connect(conf.NatsAddress, nats.Name("Github metrics"), nats.Token(conf.NatsToken))
// if err != nil {
// return nil, fmt.Errorf("error while connecting with token: %w", err)
// }
// }

ctx := &NATSContext{
conf: conf,
Expand Down
39 changes: 18 additions & 21 deletions agent/git/pkg/clients/nats_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,29 @@ func NewNATSContext(conf *config.Config) (*NATSContext, error) {

var conn *nats.Conn
var err error
var mtlsConfig mtlsnats.MtlsConfig
//var mtlsConfig mtlsnats.MtlsConfig

if mtlsConfig.IsEnabled {
tlsConfig, err := mtlsnats.GetTlsConfig()
tlsConfig, err := mtlsnats.GetTlsConfig()
if err != nil {
log.Println("error while getting tls config ", err)
time.Sleep(time.Minute * 30)
} else {
conn, err = nats.Connect(conf.NatsAddress,
nats.Name("Github metrics"),
//nats.Token(conf.NatsToken),
nats.Secure(tlsConfig),
)
if err != nil {
log.Println("error while getting tls config ", err)
time.Sleep(time.Minute * 30)
} else {
conn, err = nats.Connect(conf.NatsAddress,
nats.Name("Github metrics"),
nats.Token(conf.NatsToken),
nats.Secure(tlsConfig),
)
if err != nil {
log.Println("error while connecting with mtls ", err)
}
log.Fatal("error while connecting with mtls ", err)
}

}

if conn == nil {
conn, err = nats.Connect(conf.NatsAddress, nats.Name("Github metrics"), nats.Token(conf.NatsToken))
if err != nil {
return nil, fmt.Errorf("error while connecting with token: %w", err)
}
}
// if conn == nil {
// conn, err = nats.Connect(conf.NatsAddress, nats.Name("Github metrics"), nats.Token(conf.NatsToken))
// if err != nil {
// return nil, fmt.Errorf("error while connecting with token: %w", err)
// }
// }

ctx := &NATSContext{
conf: conf,
Expand Down
38 changes: 18 additions & 20 deletions agent/kubviz/k8smetrics_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,32 +77,30 @@ func main() {
clientset *kubernetes.Clientset
)

var mtlsConfig mtlsnats.MtlsConfig
//var mtlsConfig mtlsnats.MtlsConfig
var nc *nats.Conn

if mtlsConfig.IsEnabled {
tlsConfig, err := mtlsnats.GetTlsConfig()
//if mtlsConfig.IsEnabled {
tlsConfig, err := mtlsnats.GetTlsConfig()
if err != nil {
log.Println("error while getting tls config ", err)
time.Sleep(time.Minute * 30)
} else {
nc, err = nats.Connect(
natsurl,
nats.Name("K8s Metrics"),
//nats.Token(token),
nats.Secure(tlsConfig),
)
if err != nil {
log.Println("error while getting tls config ", err)
time.Sleep(time.Minute * 30)
} else {
nc, err = nats.Connect(
natsurl,
nats.Name("K8s Metrics"),
nats.Token(token),
nats.Secure(tlsConfig),
)
if err != nil {
log.Println("error while connecting with mtls ", err)
}
log.Fatal("error while connecting with mtls ", err)
}

}

if nc == nil {
nc, err = nats.Connect(natsurl, nats.Name("K8s Metrics"), nats.Token(token))
events.CheckErr(err)
}
// if nc == nil {
// nc, err = nats.Connect(natsurl, nats.Name("K8s Metrics"), nats.Token(token))
// events.CheckErr(err)
// }
js, err := nc.JetStream()
events.CheckErr(err)
err = events.CreateStream(js)
Expand Down
38 changes: 18 additions & 20 deletions client/pkg/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,29 @@ func NewNATSContext(conf *config.Config, dbClient clickhouse.DBInterface) (*NATS

var conn *nats.Conn
var err error
var mtlsConfig mtlsnats.MtlsConfig
//var mtlsConfig mtlsnats.MtlsConfig

if mtlsConfig.IsEnabled {
tlsConfig, err := mtlsnats.GetTlsConfig()
tlsConfig, err := mtlsnats.GetTlsConfig()
if err != nil {
log.Println("error while getting tls config ", err)
time.Sleep(time.Minute * 30)
} else {
conn, err = nats.Connect(conf.NatsAddress,
nats.Name("Github metrics"),
//nats.Token(conf.NatsToken),
nats.Secure(tlsConfig),
)
if err != nil {
log.Println("error while getting tls config ", err)
time.Sleep(time.Minute * 30)
} else {
conn, err = nats.Connect(conf.NatsAddress,
nats.Name("Github metrics"),
nats.Token(conf.NatsToken),
nats.Secure(tlsConfig),
)
if err != nil {
log.Println("error while connecting with mtls ", err)
}
log.Fatal("error while connecting with mtls ", err)
}
}

if conn == nil {
conn, err = nats.Connect(conf.NatsAddress, nats.Name("Github metrics"), nats.Token(conf.NatsToken))
if err != nil {
return nil, fmt.Errorf("error while connecting with token: %w", err)
}
}
// if conn == nil {
// conn, err = nats.Connect(conf.NatsAddress, nats.Name("Github metrics"), nats.Token(conf.NatsToken))
// if err != nil {
// return nil, fmt.Errorf("error while connecting with token: %w", err)
// }
// }

ctx := &NATSContext{
conf: conf,
Expand Down
Loading