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:
parent
a973b88463
commit
213e1d7b0f
3 changed files with 22 additions and 10 deletions
11
helpers.go
11
helpers.go
|
@ -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
19
main.go
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue