Skip to content

Commit

Permalink
V.1.3.1 ready to publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Paul Argudo committed Jun 18, 2024
1 parent 667f028 commit 329fa01
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 54 deletions.
16 changes: 8 additions & 8 deletions bin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ You'll find here binaries for your convenience.

```
md5sum pgSimload*
955227f4d8ce90ad24ae0c3bcfaf4cde pgSimload
06e2593b109dce0dd4bb608c3a513696 pgSimload_mac
ef46a6bf429a1e83748b7fe504069ee7 pgSimload_static
d340bddca2cd3fce7b64faf3715adf9e pgSimload_win.exe
f545e77e2834c0a0adc5e8eae265e4aa pgSimload
cd50bdbadfde7dab8260f241f47f9b4e pgSimload_mac
202d8dc57168b7472fe7de25d1a37d27 pgSimload_static
82c7e8ea39dcfa323a27e7cba4843223 pgSimload_win.exe
```

# More information
Expand All @@ -29,13 +29,13 @@ If you're a Linux user, let me warn you that the binary has dependencies:

```
$ ldd bin/pgSimload
linux-vdso.so.1 (0x00007ffd1fdcf000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x0000747478000000)
/lib64/ld-linux-x86-64.so.2 (0x000074747840e000)
linux-vdso.so.1 (0x00007ffec87e4000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007917a0a00000)
/lib64/ld-linux-x86-64.so.2 (0x00007917a0da3000)
```

Those depedencies would be OK if as an example you're using an up-to-date
Ubuntu Mantic Minautor (aka Ubuntu 23.10) as per April 18th 2024.
Ubuntu 24.04 LTS Noble Numbat as per June 18th 2024.

But for any other machine without those versions of dependencies, please
download and use instead the binary compiled *statically* for your convenience,
Expand Down
Binary file modified bin/pgSimload
Binary file not shown.
Binary file modified bin/pgSimload_mac
Binary file not shown.
Binary file modified bin/pgSimload_static
Binary file not shown.
Binary file modified bin/pgSimload_win.exe
Binary file not shown.
22 changes: 22 additions & 0 deletions doc/04_release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Release notes


## Version 1.3.1 (June 18th 2024)

### Major changes

None, this is maintenance release.

### Minor changes

- Some captions revisited for better understanding by the user, and to be
consistent. Particularly true for the "SQL-Loop" mode where the start
process was different

- Corrected some startup tests when mandatory files are not passed in the
command line

- Corrected a bug when `kubectl` wasn't installed on default directories.
This was preventing users to have installs like `/usr/local/bin/kubectl`.
Now, `kubectl` can be anywhere in the `$PATH` of the user

- re-Build of binaries to update underlying dependencies

## Version 1.3.0 (April 24th 2024)

### Major changes
Expand Down
Binary file modified doc/pgSimload.doc.pdf
Binary file not shown.
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ go 1.18
require (
github.com/MakeNowJust/heredoc v1.0.0
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203
github.com/jackc/pgx/v5 v5.5.5
golang.org/x/crypto v0.22.0
github.com/jackc/pgx/v5 v5.6.0
golang.org/x/crypto v0.24.0
)

require (
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
golang.org/x/text v0.14.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
golang.org/x/text v0.16.0 // indirect
)

require golang.org/x/sys v0.19.0 // indirect
require golang.org/x/sys v0.21.0 // indirect
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203 h1:XBBHcIb256gUJ
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203/go.mod h1:E1jcSv8FaEny+OP/5k9UxZVw9YFWGj7eI4KR/iOBqCg=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 h1:L0QtFUgDarD7Fpv9jeVMgy/+Ec0mtnmYuImjTz6dtDA=
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw=
github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY=
github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw=
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
14 changes: 9 additions & 5 deletions kubewatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func KubeWatch_k8s(kube_config KubeConfig) {
start := time.Now()

//build the main kube command
command_args := "/usr/bin/kubectl get pods --no-headers"
command_args := "kubectl get pods --no-headers"
command_args += " -n '" + kube_config.Namespace+"'"
command_args += " -l '" + kube_config.Limiter_instance+"'"
command_args += " -o custom-columns=\""
Expand Down Expand Up @@ -151,7 +151,7 @@ func KubeWatch_k8s(kube_config KubeConfig) {

//(worker)node = record[3]

command_args := "/usr/bin/kubectl get node --no-headers " + record[3]
command_args := "kubectl get node --no-headers " + record[3]
command_args += " -o custom-columns=\""+kube_config.Pod_zone+","+kube_config.Pod_status+"\""
cmd := exec.Command("sh", "-c", command_args)

Expand Down Expand Up @@ -219,7 +219,7 @@ func KubeWatch_k8s(kube_config KubeConfig) {
record := records[i]
if (previouscluster != record[2]) {
output = output + "\n"
output = output + "Cluster : "+ record[2] + "\n"
output = output + "+ Cluster : "+ record[2] + "\n"
}

previouscluster = record[2]
Expand Down Expand Up @@ -266,6 +266,8 @@ func KubeWatch_k8s(kube_config KubeConfig) {

podname = record[0]

//line starts with 2 empty spaces
output += " "
output += PadRight(podname, " ", longest)
output += zone + button + role + "\n"
}
Expand Down Expand Up @@ -323,8 +325,10 @@ func KubeWatch() {
// read the config JSON of the Kube watcher mode
kube_config := ReadKubeConfig ()

//check if presence of required binary kubectl on the host
if _, err := os.Stat("/usr/bin/kubectl"); os.IsNotExist(err) {
// try to run kubectl once to insure it is installed
cmd := exec.Command("kubectl")
err := cmd.Run()
if err != nil {
message := "kubectl is not present on this system. Please install it prior running"
message = message + "\npgSimload in Kube-watcher mode against a k8s env\n"
exit1(message,err)
Expand Down
38 changes: 26 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var (
exec_time time.Duration
sleep_time time.Duration

Version = "pgSimLoad v.1.3.0 - April 24th 2024"
Version = "pgSimLoad v.1.3.1 - June 18th 2024"

License = heredoc.Doc(`
**The PostgreSQL License**
Expand Down Expand Up @@ -199,22 +199,36 @@ func CheckFlags () {
}
}

if !patroniconfigfilename.set {
if !kubeconfigfilename.set {
if !patroniconfigfilename.set && !kubeconfigfilename.set {

//not in Patroni-Watcher mode..
//nor Kube-Watcher mode...

//checking at least a config AND a script is present because that's
//SQL-Loop then... (default)

if !(scriptfilename.set || configfilename.set) {
message := "Please read documentation in doc/ since parameters have to be passed"
message += "\nAlternatively, run with -h to show all possible parameters"
if !configfilename.set {
message = message + "\n -config is not set !"
exit1(message,nil)
}

if !scriptfilename.set {
message = message + "\n -script is not set !"
exit1(message,nil)
}

if !scriptfilename.set {
if configfilename.set {
message := "You have set a config filename but no script filename (--script <SQL file>) !"
message += "\nPlease read documentation in doc/ and/or run with -h"
exit1(message,nil)
}
}

if !configfilename.set {
if scriptfilename.set {
message := "You have set a script filename but no config filename (--config <JSON file>) !"
message += "\nPlease read documentation in doc/ and/or run with -h"
exit1(message,nil)
}
}
}

}

func start_banner (mode string) {
Expand All @@ -229,7 +243,7 @@ func start_banner (mode string) {
fmt.Println("=========================================================================")
fmt.Print(string(colorGreen))

case "Patroni-Watcher","Kube-Watcher","SQL-loop":
case "Patroni-Watcher","Kube-Watcher","SQL-Loop":
fmt.Println("About to start in "+mode+" mode")
fmt.Print(string(colorReset))
fmt.Println("=========================================================================")
Expand Down
31 changes: 21 additions & 10 deletions patroni.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,11 @@ func PatroniWatch_ssh(patroni_config PatroniConfig, remote_command string, pgMan
// Clears the screen
fmt.Printf("\x1bc")

fmt.Println()
//useless new line... fmt.Println()
currentTime := time.Now()

fmt.Println("+ Patronictl output from host ", patroni_config.Remote_host, "at", currentTime.Format("2006.01.02 15:04:05"))
fmt.Println()

//prints out the result of the patronictl list command
fmt.Println(patronictloutColorize(patronictlout))
Expand All @@ -370,11 +371,13 @@ func PatroniWatch_ssh(patroni_config PatroniConfig, remote_command string, pgMan
// Clears the screen
fmt.Printf("\x1bc")

fmt.Println()
//useless new line at start of screen
//fmt.Println()
currentTime := time.Now()

fmt.Println("+ Patronictl output from host ", patroni_config.Remote_host, "at", currentTime.Format("2006.01.02 15:04:05"))

fmt.Println()

//prints out the result of the patronictl list command
fmt.Println(patronictloutColorize(patronictlout))

Expand Down Expand Up @@ -422,7 +425,7 @@ func PatroniWatch_k8s(patroni_config PatroniConfig, remote_command string, pgMan
err_count := 0

// get primary pod's name
command_args := "/usr/bin/kubectl get pods"
command_args := "kubectl get pods"
command_args += " -n " + patroni_config.K8s_namespace
command_args += " --selector='" + patroni_config.K8s_selector+"'"
command_args += " -o name"
Expand Down Expand Up @@ -455,7 +458,7 @@ func PatroniWatch_k8s(patroni_config PatroniConfig, remote_command string, pgMan
pod = strings.ReplaceAll(strings.TrimSpace(string(out)), "\n", "")

//get patronictl output from master pod
command_args = "/usr/bin/kubectl "
command_args = "kubectl "
command_args += " -n " + patroni_config.K8s_namespace
command_args += " exec -i -c database " + pod
command_args += " -- /bin/bash -c 'patronictl -c /etc/patroni/ " + patroni_config.Format + "'"
Expand Down Expand Up @@ -490,10 +493,13 @@ func PatroniWatch_k8s(patroni_config PatroniConfig, remote_command string, pgMan
// Clears the screen
fmt.Printf("\x1bc")

fmt.Println()
//useless new line at start of output
//fmt.Println()

currentTime := time.Now()

fmt.Println("+ Patronictl output from ", pod, "at", currentTime.Format("2006.01.02 15:04:05"))
fmt.Println()

//prints out the result of the patronictl list command
fmt.Println(patronictloutColorize(patronictlout))
Expand All @@ -517,10 +523,12 @@ func PatroniWatch_k8s(patroni_config PatroniConfig, remote_command string, pgMan
// Clears the screen
fmt.Printf("\x1bc")

fmt.Println()
//useless newline at start of screen
// fmt.Println()
currentTime := time.Now()

fmt.Println("+ Patronictl output from ", pod, "at", currentTime.Format("2006.01.02 15:04:05"))
fmt.Println()

//prints out the result of the patronictl list command
fmt.Println(patronictloutColorize(patronictlout))
Expand Down Expand Up @@ -560,10 +568,13 @@ func PatroniWatch() {
//check if presence of required binary kubectl on the host
//ssh binary not necessary, handled by golang directly
if patroni_config.K8s_selector != "" {
//running localy with kubectl
if _, err := os.Stat("/usr/bin/kubectl"); os.IsNotExist(err) {

// try to run kubectl once to insure it is installed
cmd := exec.Command("kubectl")
err := cmd.Run()
if err != nil {
message := "kubectl is not present on this system. Please install it prior running"
message += "\npgSimload in Patroni-loop mode against a k8s env\n"
message = message + "\npgSimload in Kube-watcher mode against a k8s env\n"
exit1(message,err)
}
mode = "k8s"
Expand Down
14 changes: 12 additions & 2 deletions sqlloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func ExecCreate(pgManager *PGManager) {
exit1("Could not open DDL script:\n" , err)
}

fmt.Println("\nExecuting DDL Script :")
fmt.Println("Executing DDL Script :")

// defer the closing of our jsonFile so that we can parse it later on
defer create_ddl_file.Close()
Expand Down Expand Up @@ -102,6 +102,7 @@ func ExecCreate(pgManager *PGManager) {
fmt.Print(string(colorGreen))
fmt.Printf(" Script %q successfully executed !\n",createfilename.value)
fmt.Print(string(colorReset))
fmt.Println()
}

func SetSessionParameters(pgManager *PGManager) {
Expand Down Expand Up @@ -165,6 +166,7 @@ func SetSessionParameters(pgManager *PGManager) {
fmt.Print(string(colorGreen))
fmt.Printf(" Session parameters applied to the PG session !\n")
fmt.Print(string(colorReset))
fmt.Println()
}
}

Expand Down Expand Up @@ -198,7 +200,6 @@ func do_sqlloop(pgManager *PGManager) {
message += "\nPlease correct the errors prior running pgSimload."
exit1(message,nil)
} else {
fmt.Println()

if sleep_time > 0 {
fmt.Printf("Now entering the main loop, executing script %q each %q\n",scriptfilename.value, sleep_time)
Expand Down Expand Up @@ -408,6 +409,15 @@ func SQLLoop () {

//fmt.Println("DEBUG: Connected to PG!")

// time to clear the screen to remove the licence
// etc...
// Clears the screen
fmt.Printf("\x1bc")

currentTime := time.Now()
fmt.Println("+ SQL-Loop at", currentTime.Format("2006.01.02 15:04:05"))
fmt.Println()

if sessiongucsfilename.set {
SetSessionParameters(pgManager)
}
Expand Down

0 comments on commit 329fa01

Please sign in to comment.