1
0
Fork 0
mirror of synced 2024-07-21 03:50:37 -04:00

Fix Replication

Fixes issue when set to `slave` mode, also fix creation of subdirectories
from the assets received and fix probe port when waiting to slave process
to finish.
This commit is contained in:
Pmoranga 2023-04-19 19:00:46 -03:00
parent a973b88463
commit 213e1d7b0f
3 changed files with 22 additions and 10 deletions

View file

@ -288,6 +288,17 @@ func extractFromArchive(archive, path string) error {
log.Fatalf("extractFromArchive: Mkdir() failed: %s", err.Error())
}
case tar.TypeReg:
s := strings.Split(header.Name, "/")
dir := ""
for len(s) > 1 {
dir, s = dir+"/"+s[0], s[1:]
if _, err := os.Stat(path + dir); os.IsNotExist(err) {
if err := os.Mkdir(path+dir, 0755); err != nil {
log.Fatalf("extractFromArchive: Mkdir() subdir failed: %s", err.Error())
}
}
}
outFile, err := os.Create(path + "/" + header.Name)
if err != nil {
log.Fatalf("extractFromArchive: Create() failed: %s", err.Error())

19
main.go
View file

@ -9,11 +9,7 @@ import (
"encoding/pem"
"errors"
"fmt"
"github.com/google/uuid"
"io/ioutil"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"net"
"net/http"
"os"
@ -25,6 +21,11 @@ import (
"time"
"unicode/utf8"
"github.com/google/uuid"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"github.com/gobuffalo/packr/v2"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
@ -509,6 +510,11 @@ func main() {
ovpnAdmin.mgmtInterfaces[parts[0]] = parts[len(parts)-1]
}
if ovpnAdmin.role == "slave" {
ovpnAdmin.syncDataFromMaster()
go ovpnAdmin.syncWithMaster()
}
ovpnAdmin.mgmtSetTimeFormat()
ovpnAdmin.registerMetrics()
@ -536,11 +542,6 @@ func main() {
ovpnAdmin.modules = append(ovpnAdmin.modules, "ccd")
}
if ovpnAdmin.role == "slave" {
ovpnAdmin.syncDataFromMaster()
go ovpnAdmin.syncWithMaster()
}
ovpnAdmin.templates = packr.New("template", "./templates")
staticBox := packr.New("static", "./frontend/static")

View file

@ -15,7 +15,7 @@ if [ -e "$SERVER_CERT" ]; then
else
if [ ${OVPN_ROLE:-"master"} = "slave" ]; then
echo "Waiting for initial sync data from master"
while [ $(wget -q localhost/api/sync/last/try -O - | wc -m) -lt 1 ]
while [ $(wget -q localhost:${OVPN_LISTEN_PORT:-8080}/api/sync/last/try -O - | wc -m) -lt 1 ]
do
sleep 5
done