Use local paths when possible, some AI cleanup

This commit is contained in:
Tanishq Dubey 2025-05-16 21:20:39 -04:00
parent 4f6365d453
commit 2f6d3c9bb2
No known key found for this signature in database
GPG Key ID: CFC1931B84DFC3F9
7 changed files with 21 additions and 25 deletions

View File

@ -44,7 +44,7 @@ const (
clusterUIDKey = "/kat/config/cluster_uid"
clusterConfigKey = "/kat/config/cluster_config" // Stores the JSON of pb.ClusterConfigurationSpec
defaultNodeName = "kat-node"
leaderCertCN = "leader.kat.cluster.local" // Common Name for leader certificate
leaderCertCN = "leader.kat.cluster.local" // Common Name for leader certificate
)
func init() {
@ -174,7 +174,7 @@ func runInit(cmd *cobra.Command, args []string) {
log.Printf("Failed to generate leader key and CSR: %v", err)
} else {
// Read the CSR file
csrData, err := os.ReadFile(leaderCSRPath)
_, err := os.ReadFile(leaderCSRPath)
if err != nil {
log.Printf("Failed to read leader CSR file: %v", err)
} else {

View File

@ -3,8 +3,8 @@ kind: ClusterConfiguration
metadata:
name: my-kat-cluster
spec:
clusterCIDR: "10.100.0.0/16"
serviceCIDR: "10.200.0.0/16"
cluster_CIDR: "10.100.0.0/16"
service_CIDR: "10.200.0.0/16"
nodeSubnetBits: 7 # Results in /23 node subnets (e.g., 10.100.0.0/23, 10.100.2.0/23)
clusterDomain: "kat.example.local" # Overriding default
apiPort: 9115

View File

@ -201,8 +201,8 @@ func TestValidateClusterConfiguration_InvalidValues(t *testing.T) {
ApiPort: 10251,
EtcdPeerPort: 2380,
EtcdClientPort: 2379,
VolumeBasePath: "/var/lib/kat/volumes",
BackupPath: "/var/lib/kat/backups",
VolumeBasePath: "~/.kat/volumes",
BackupPath: "~/.kat/backups",
BackupIntervalMinutes: 30,
AgentTickSeconds: 15,
NodeLossTimeoutSeconds: 60,

View File

@ -11,13 +11,13 @@ const (
DefaultApiPort = 9115
DefaultEtcdPeerPort = 2380
DefaultEtcdClientPort = 2379
DefaultVolumeBasePath = "/var/lib/kat/volumes"
DefaultBackupPath = "/var/lib/kat/backups"
DefaultVolumeBasePath = "~/.kat/volumes"
DefaultBackupPath = "~/.kat/backups"
DefaultBackupIntervalMins = 30
DefaultAgentTickSeconds = 15
DefaultNodeLossTimeoutSec = 60 // DefaultNodeLossTimeoutSeconds = DefaultAgentTickSeconds * 4 (example logic)
DefaultNodeSubnetBits = 7 // yields /23 from /16, or /31 from /24 etc. (5 bits for /29, 7 for /25)
// RFC says 7 for /23 from /16. This means 2^(32-16-7) = 2^9 = 512 IPs per node subnet.
// If nodeSubnetBits means bits for the node portion *within* the host part of clusterCIDR:
// e.g. /16 -> 16 host bits. If nodeSubnetBits = 7, then node subnet is / (16+7) = /23.
// RFC says 7 for /23 from /16. This means 2^(32-16-7) = 2^9 = 512 IPs per node subnet.
// If nodeSubnetBits means bits for the node portion *within* the host part of clusterCIDR:
// e.g. /16 -> 16 host bits. If nodeSubnetBits = 7, then node subnet is / (16+7) = /23.
)

View File

@ -1,15 +1,11 @@
package pki
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"fmt"
"net"
"os"
"time"
)
// ParseCSRFromBytes parses a PEM-encoded CSR from bytes

View File

@ -87,7 +87,7 @@ func TestSignCertificateRequest(t *testing.T) {
// Sign CSR
certPath := filepath.Join(tempDir, "node.crt")
err = SignCertificateRequest(caKeyPath, caCertPath, csrData, certPath, 30) // 30 days validity
err = SignCertificateRequest(caKeyPath, caCertPath, string(csrData), certPath, 30) // 30 days validity
if err != nil {
t.Fatalf("SignCertificateRequest failed: %v", err)
}

View File

@ -51,8 +51,8 @@ spec:
apiPort: 9115
etcdPeerPort: 2380
etcdClientPort: 2379
volumeBasePath: "/var/lib/kat/volumes"
backupPath: "/var/lib/kat/backups"
volumeBasePath: "~/.kat/volumes"
backupPath: "~/.kat/backups"
backupIntervalMinutes: 30
agentTickSeconds: 15
nodeLossTimeoutSeconds: 60