Skip to content

Commit 3e0bd61

Browse files
authored
12.0.3.0-r2 (#178)
* 12.0.3.0-r2 update * add compile
1 parent a84721a commit 3e0bd61

26 files changed

+1139
-52
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44

55
**Updates**
66

7+
* Ability to override Statistics->Resource in server.conf.yaml
78
* Improved the logging for metrics when authentication is not enabled
89
* Includes IT39515
910
* Includes IT39573
11+
* Includes IT39917
12+
* Remove need for python
13+
* Fix for CVE-2022-21698
1014

1115
## 12.0.3.0-r1
1216

ace_config_setdbparms.sh

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,6 @@
77
# which accompanies this distribution, and is available at
88
# http://www.eclipse.org/legal/epl-v20.html
99

10-
function argStrings {
11-
shlex() {
12-
python -c $'import sys, shlex\nfor arg in shlex.split(sys.stdin):\n\tsys.stdout.write(arg)\n\tsys.stdout.write(\"\\0\")'
13-
}
14-
args=()
15-
while IFS='' read -r -d ''; do
16-
args+=( "$REPLY" )
17-
done < <(shlex <<<$1)
18-
19-
log "${args[0]}"
20-
log "${args[1]}"
21-
log "${args[2]}"
22-
23-
}
24-
2510
if [ -z "$MQSI_VERSION" ]; then
2611
source /opt/ibm/ace-12/server/bin/mqsiprofile
2712
fi
@@ -41,19 +26,17 @@ if [ -s "/home/aceuser/initial-config/setdbparms/setdbparms.txt" ]; then
4126
continue
4227
fi
4328
IFS=${OLDIFS}
44-
if [[ $line == mqsisetdbparms* ]]; then
29+
if [[ $line == mqsisetdbparms* ]]; then
4530
log "Running suppplied mqsisetdbparms command"
4631
OUTPUT=`eval "$line"`
4732
else
48-
shlex() {
49-
python -c $'import sys, shlex\nfor arg in shlex.split(sys.stdin):\n\tsys.stdout.write(arg)\n\tsys.stdout.write(\"\\0\")'
50-
}
51-
args=()
52-
while IFS='' read -r -d ''; do
53-
args+=( "$REPLY" )
54-
done < <(shlex <<<$line)
55-
log "Setting user and password for resource: ${args[0]}"
56-
cmd="mqsisetdbparms -w /home/aceuser/ace-server -n \"${args[0]}\" -u \"${args[1]}\" -p \"${args[2]}\" 2>&1"
33+
34+
printf "%s" "$line" | xargs -n 1 printf "%s\n" > /tmp/creds
35+
IFS=$'\n' read -d '' -r -a lines < /tmp/creds
36+
37+
38+
log "Setting user and password for resource: ${lines[0]}"
39+
cmd="mqsisetdbparms -w /home/aceuser/ace-server -n \"${lines[0]}\" -u \"${lines[1]}\" -p \"${lines[2]}\" 2>&1"
5740
OUTPUT=`eval "$cmd"`
5841
echo $OUTPUT
5942
fi

cmd/chkacehealthy/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
chkacehealthy

cmd/chkacehealthy/main.go

Lines changed: 122 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,97 @@ limitations under the License.
1818
package main
1919

2020
import (
21+
"context"
2122
"fmt"
23+
"log"
2224
"net"
25+
"net/http"
2326
"os"
2427
"time"
28+
29+
"k8s.io/apimachinery/pkg/api/errors"
2530
)
2631

32+
var checkACE = checkACElocal
33+
var httpCheck = httpChecklocal
34+
var socketCheck = socketChecklocal
35+
var osExit = os.Exit
36+
2737
const restartIsTimeoutInSeconds = 60
2838

39+
var netDial = net.Dial
40+
var httpGet = http.Get
41+
2942
func main() {
43+
44+
err := checkACE()
45+
if err != nil {
46+
log.Fatal(err)
47+
}
48+
49+
// If knative service also check FDR is up
50+
knative := os.Getenv("KNATIVESERVICE")
51+
if knative == "true" || knative == "1" {
52+
fmt.Println("KNATIVESERVICE set so checking FDR container")
53+
err := checkDesignerHealth()
54+
if err != nil {
55+
log.Fatal(err)
56+
}
57+
} else {
58+
fmt.Println("KNATIVESERVICE is not set so skipping FDR checks")
59+
}
60+
61+
}
62+
63+
func checkDesignerHealth() error {
64+
// HTTP LMAP endpoint
65+
err := httpCheck("LMAP Port", "http://localhost:3002/admin/ready")
66+
if err != nil {
67+
return err
68+
}
69+
70+
isConnectorService := os.Getenv("CONNECTOR_SERVICE")
71+
if isConnectorService == "true" || isConnectorService == "1" {
72+
// HTTP LCP Connector service endpoint
73+
err = httpCheck("LCP Port", "http://localhost:3001/admin/ready")
74+
if err != nil {
75+
return err
76+
}
77+
}
78+
79+
// LCP api flow endpoint
80+
lcpsocket := "/tmp/lcp.socket"
81+
if value, ok := os.LookupEnv("LCP_IPC_PATH"); ok {
82+
lcpsocket = value
83+
}
84+
err = socketCheck("LCP socket", lcpsocket)
85+
if err != nil {
86+
return err
87+
}
88+
89+
// LMAP endpoint
90+
lmapsocket := "/tmp/lmap.socket"
91+
if value, ok := os.LookupEnv("LMAP_IPC_PATH"); ok {
92+
lmapsocket = value
93+
}
94+
err = socketCheck("LMAP socket", lmapsocket)
95+
if err != nil {
96+
return err
97+
}
98+
99+
return nil
100+
}
101+
102+
func isEnvExist(key string) bool {
103+
if _, ok := os.LookupEnv(key); ok {
104+
return true
105+
}
106+
return false
107+
}
108+
109+
func checkACElocal() error {
30110
// Check if the integration server has started the admin REST endpoint
31-
conn, err := net.Dial("tcp", "127.0.0.1:7600")
111+
conn, err := netDial("tcp", "127.0.0.1:7600")
32112

33113
if err != nil {
34114

@@ -38,24 +118,60 @@ func main() {
38118

39119
if os.IsNotExist(statErr) {
40120
fmt.Println("Integration server is not active")
41-
os.Exit(1)
42-
} else if statErr != nil {
121+
return errors.NewBadRequest("Integration server is not active")
122+
} else if statErr != nil {
43123
fmt.Println(statErr)
44-
os.Exit(1)
124+
return errors.NewBadRequest("stat error " + statErr.Error())
45125
} else {
46126
fmt.Println("Integration server restart file found")
47127
timeNow := time.Now()
48128
timeDiff := timeNow.Sub(fileInfo.ModTime())
49129

50130
if timeDiff.Seconds() < restartIsTimeoutInSeconds {
51131
fmt.Println("Integration server is restarting")
52-
os.Exit(0)
53132
} else {
54133
fmt.Println("Integration restart time elapsed")
55-
os.Exit(1)
134+
return errors.NewBadRequest("Integration restart time elapsed")
56135
}
57136
}
137+
} else {
138+
fmt.Println("ACE ready check passed")
58139
}
59140
conn.Close()
141+
return nil
142+
}
143+
144+
func httpChecklocal(name string, addr string) error {
145+
resp, err := httpGet(addr)
146+
if err != nil {
147+
return err
148+
}
149+
if resp.StatusCode != 200 {
150+
fmt.Println(name + " ready check failed - HTTP Status is not 200 range")
151+
return errors.NewBadRequest(name + " ready check failed - HTTP Status is not 200 range")
152+
} else {
153+
fmt.Println(name + " ready check passed")
154+
}
155+
return nil
156+
}
60157

158+
func socketChecklocal(name string, socket string) error {
159+
httpc := http.Client{
160+
Transport: &http.Transport{
161+
DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
162+
return net.Dial("unix", socket)
163+
},
164+
},
165+
}
166+
response, err := httpc.Get("http://dummyHostname/admin/ready")
167+
if err != nil {
168+
return err
169+
}
170+
if response.StatusCode != 200 {
171+
log.Fatal(name + " ready check failed - HTTP Status is not 200 range")
172+
return errors.NewBadRequest(name + " ready check failed - HTTP Status is not 200 range")
173+
} else {
174+
fmt.Println(name + " ready check passed")
175+
}
176+
return nil
61177
}

cmd/chkacehealthy/main_test.go

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/*
2+
© Copyright IBM Corporation 2018
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// chkacelively checks that ACE is still runing, by checking if the admin REST endpoint port is available.
18+
package main
19+
20+
import (
21+
"net/http"
22+
"os"
23+
"testing"
24+
25+
"github.com/stretchr/testify/assert"
26+
"k8s.io/apimachinery/pkg/api/errors"
27+
)
28+
29+
func Test_httpChecklocal(t *testing.T) {
30+
31+
t.Run("http get succeeds", func(t *testing.T) {
32+
33+
oldhttpGet := httpGet
34+
defer func() { httpGet = oldhttpGet }()
35+
httpGet = func(string) (resp *http.Response, err error) {
36+
response := &http.Response{
37+
StatusCode: 200,
38+
}
39+
return response, nil
40+
}
41+
42+
err := httpChecklocal("LMAP Port", "http://localhost:3002/admin/ready")
43+
assert.Nil(t, err)
44+
})
45+
46+
t.Run("http get fails with err on get", func(t *testing.T) {
47+
48+
oldhttpGet := httpGet
49+
defer func() { httpGet = oldhttpGet }()
50+
httpGet = func(string) (resp *http.Response, err error) {
51+
response := &http.Response{}
52+
return response, errors.NewBadRequest("mock err")
53+
}
54+
55+
err := httpChecklocal("LMAP Port", "http://localhost:3002/admin/ready")
56+
assert.Error(t, err, "mock err")
57+
})
58+
59+
t.Run("http get fails with non 200", func(t *testing.T) {
60+
61+
oldhttpGet := httpGet
62+
defer func() { httpGet = oldhttpGet }()
63+
httpGet = func(string) (resp *http.Response, err error) {
64+
response := &http.Response{
65+
StatusCode: 404,
66+
}
67+
return response, nil
68+
}
69+
70+
err := httpChecklocal("Test", "http://localhost:3002/admin/ready")
71+
assert.Error(t, err, "Test ready check failed - HTTP Status is not 200 range")
72+
})
73+
}
74+
75+
func Test_checkDesignerHealth(t *testing.T) {
76+
t.Run("connector service enabled and health check is successful", func(t *testing.T) {
77+
os.Setenv("CONNECTOR_SERVICE", "true")
78+
defer os.Unsetenv("CONNECTOR_SERVICE")
79+
oldhttpGet := httpGet
80+
defer func() { httpGet = oldhttpGet }()
81+
httpGet = func(string) (resp *http.Response, err error) {
82+
response := &http.Response{
83+
StatusCode: 200,
84+
}
85+
return response, nil
86+
}
87+
88+
oldSocketCheck := socketCheck
89+
defer func() { socketCheck = oldSocketCheck }()
90+
socketCheck = func(string, string) (err error) {
91+
return nil
92+
}
93+
err := checkDesignerHealth()
94+
assert.Nil(t, err)
95+
})
96+
97+
t.Run("connector service enabled and health check fails", func(t *testing.T) {
98+
os.Setenv("CONNECTOR_SERVICE", "true")
99+
defer os.Unsetenv("CONNECTOR_SERVICE")
100+
oldhttpGet := httpGet
101+
defer func() { httpGet = oldhttpGet }()
102+
httpGet = func(string) (resp *http.Response, err error) {
103+
response := &http.Response{}
104+
return response, errors.NewBadRequest("mock err")
105+
}
106+
107+
oldSocketCheck := socketCheck
108+
defer func() { socketCheck = oldSocketCheck }()
109+
socketCheck = func(string, string) (err error) {
110+
return nil
111+
}
112+
err := checkDesignerHealth()
113+
assert.Error(t, err, "mock err")
114+
})
115+
116+
t.Run("health check fails for socket http server", func(t *testing.T) {
117+
oldhttpGet := httpGet
118+
defer func() { httpGet = oldhttpGet }()
119+
httpGet = func(string) (resp *http.Response, err error) {
120+
response := &http.Response{
121+
StatusCode: 200,
122+
}
123+
return response, nil
124+
}
125+
126+
oldSocketCheck := socketCheck
127+
defer func() { socketCheck = oldSocketCheck }()
128+
socketCheck = func(string, string) (err error) {
129+
return errors.NewBadRequest("mock err")
130+
}
131+
err := checkDesignerHealth()
132+
assert.Error(t, err, "mock err")
133+
})
134+
}

0 commit comments

Comments
 (0)