more fixes before final part
This commit is contained in:
parent
8f90c1b16d
commit
92fb052594
2
Makefile
2
Makefile
@ -18,7 +18,7 @@ clean:
|
|||||||
# Run all tests
|
# Run all tests
|
||||||
test: generate
|
test: generate
|
||||||
@echo "Running all tests..."
|
@echo "Running all tests..."
|
||||||
@go test -v -count=1 ./... --coverprofile=coverage.out
|
@go test -v -count=1 ./... --coverprofile=coverage.out --short
|
||||||
|
|
||||||
# Run unit tests only (faster, no integration tests)
|
# Run unit tests only (faster, no integration tests)
|
||||||
test-unit:
|
test-unit:
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.dws.rip/dubey/kat/internal/agent"
|
||||||
"git.dws.rip/dubey/kat/internal/api"
|
"git.dws.rip/dubey/kat/internal/api"
|
||||||
"git.dws.rip/dubey/kat/internal/cli"
|
"git.dws.rip/dubey/kat/internal/cli"
|
||||||
"git.dws.rip/dubey/kat/internal/config"
|
"git.dws.rip/dubey/kat/internal/config"
|
||||||
|
@ -125,13 +125,13 @@ func (a *Agent) SetupMTLSClient() error {
|
|||||||
// Override the dial function to map any hostname to the leader's IP
|
// Override the dial function to map any hostname to the leader's IP
|
||||||
DialTLS: func(network, addr string) (net.Conn, error) {
|
DialTLS: func(network, addr string) (net.Conn, error) {
|
||||||
// Extract host and port from addr
|
// Extract host and port from addr
|
||||||
host, port, err := net.SplitHostPort(addr)
|
_, port, err := net.SplitHostPort(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract host and port from LeaderAPI
|
// Extract host and port from LeaderAPI
|
||||||
leaderHost, leaderPort, err := net.SplitHostPort(a.LeaderAPI)
|
leaderHost, _, err := net.SplitHostPort(a.LeaderAPI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -211,8 +211,13 @@ func (a *Agent) sendHeartbeat() error {
|
|||||||
return fmt.Errorf("failed to marshal node status: %w", err)
|
return fmt.Errorf("failed to marshal node status: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
leaderHost, leaderPort, err := net.SplitHostPort(a.LeaderAPI)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Construct URL - use leader.kat.cluster.local as hostname to match certificate
|
// Construct URL - use leader.kat.cluster.local as hostname to match certificate
|
||||||
url := fmt.Sprintf("https://leader.kat.cluster.local/v1alpha1/nodes/%s/status", a.NodeName)
|
url := fmt.Sprintf("https://%s:%s/v1alpha1/nodes/%s/status", leaderHost, leaderPort, a.NodeName)
|
||||||
|
|
||||||
// Create request
|
// Create request
|
||||||
req, err := http.NewRequest("POST", url, bytes.NewBuffer(statusJSON))
|
req, err := http.NewRequest("POST", url, bytes.NewBuffer(statusJSON))
|
||||||
@ -247,12 +252,12 @@ func (a *Agent) gatherNodeStatus() NodeStatus {
|
|||||||
runtime.ReadMemStats(&m)
|
runtime.ReadMemStats(&m)
|
||||||
|
|
||||||
// Convert to human-readable format (very simplified for now)
|
// Convert to human-readable format (very simplified for now)
|
||||||
cpuCapacity := fmt.Sprintf("%dm", runtime.NumCPU() * 1000)
|
cpuCapacity := fmt.Sprintf("%dm", runtime.NumCPU()*1000)
|
||||||
memCapacity := fmt.Sprintf("%dMi", m.Sys / (1024 * 1024))
|
memCapacity := fmt.Sprintf("%dMi", m.Sys/(1024*1024))
|
||||||
|
|
||||||
// For allocatable, we'll just use 90% of capacity for this phase
|
// For allocatable, we'll just use 90% of capacity for this phase
|
||||||
cpuAllocatable := fmt.Sprintf("%dm", runtime.NumCPU() * 900)
|
cpuAllocatable := fmt.Sprintf("%dm", runtime.NumCPU()*900)
|
||||||
memAllocatable := fmt.Sprintf("%dMi", (m.Sys / (1024 * 1024)) * 9 / 10)
|
memAllocatable := fmt.Sprintf("%dMi", (m.Sys/(1024*1024))*9/10)
|
||||||
|
|
||||||
return NodeStatus{
|
return NodeStatus{
|
||||||
NodeName: a.NodeName,
|
NodeName: a.NodeName,
|
||||||
|
@ -13,6 +13,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"crypto/x509/pkix"
|
||||||
|
|
||||||
"git.dws.rip/dubey/kat/internal/pki"
|
"git.dws.rip/dubey/kat/internal/pki"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,14 +2,12 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.dws.rip/dubey/kat/internal/store"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/mock"
|
"github.com/stretchr/testify/mock"
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user