Skip to content

Commit aaec4ee

Browse files
Oliver HackOliver Hack
authored andcommitted
11.0.0.8-r1 update
1 parent b347df8 commit aaec4ee

File tree

7 files changed

+143
-60
lines changed

7 files changed

+143
-60
lines changed

asoc/appscan-config.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!-- This file should not be copied to the external repo -->
2+
<Configuration>
3+
<Targets>
4+
<Target path="../">
5+
<Exclude>asoc/</Exclude>
6+
<Exclude>*home.html</Exclude>
7+
<Exclude>*integrationserver.go</Exclude>
8+
<Exclude>*setup.py</Exclude>
9+
<Exclude>*mksysnum.pl</Exclude>
10+
</Target>
11+
</Targets>
12+
</Configuration>

cmd/runaceserver/integrationserver.go

Lines changed: 64 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"io/ioutil"
2424
"net/http"
2525
"os"
26+
"os/exec"
2627
"os/user"
2728
"strings"
2829
"time"
@@ -128,8 +129,6 @@ func initialIntegrationServerConfig() error {
128129
}
129130
}
130131

131-
132-
133132
log.Printf("Initial configuration of integration server complete")
134133

135134
log.Println("Discovering override ports")
@@ -292,8 +291,8 @@ func addOpenTracingToServerConf(serverconfContent []byte) ([]byte, error) {
292291

293292
} else {
294293
serverconfMap["UserExits"] = map[string]string{
295-
"activeUserExitList": "ACEOpenTracingUserExit",
296-
"userExitPath": "/opt/ACEOpenTracing",
294+
"activeUserExitList": "ACEOpenTracingUserExit",
295+
"userExitPath": "/opt/ACEOpenTracing",
297296
}
298297
}
299298

@@ -329,7 +328,7 @@ func getConfigurationFromContentServer() error {
329328
}
330329

331330
token := os.Getenv("ACE_CONTENT_SERVER_TOKEN")
332-
if token == "" && defaultContentServer == "true" {
331+
if token == "" && defaultContentServer == "true" {
333332
log.Errorf("No content server token available but a url is defined")
334333
return errors.New("No content server token available but a url is defined")
335334
}
@@ -375,7 +374,7 @@ func getConfigurationFromContentServer() error {
375374
contentServerKey := os.Getenv("CONTENT_SERVER_KEY")
376375
cert, err := tls.LoadX509KeyPair(contentServerCert, contentServerKey)
377376
if err != nil {
378-
if ( contentServerCert != "" && contentServerKey != "" ) {
377+
if contentServerCert != "" && contentServerKey != "" {
379378
log.Errorf("Error reading Certificates: %s", err)
380379
return errors.New("Error reading Certificates")
381380
}
@@ -386,9 +385,9 @@ func getConfigurationFromContentServer() error {
386385
client := &http.Client{
387386
Transport: &http.Transport{
388387
TLSClientConfig: &tls.Config{
389-
RootCAs: caCertPool,
388+
RootCAs: caCertPool,
390389
Certificates: []tls.Certificate{cert},
391-
ServerName: serverName,
390+
ServerName: serverName,
392391
},
393392
},
394393
}
@@ -459,11 +458,11 @@ func startIntegrationServer() command.BackgroundCmd {
459458
return returnErr
460459
}
461460

462-
defaultAppName := os.Getenv("ACE_DEFAULT_APPLICATION_NAME")
463-
if defaultAppName == "" {
464-
log.Printf("No default application name supplied. Using the integration server name instead.")
465-
defaultAppName = serverName
466-
}
461+
defaultAppName := os.Getenv("ACE_DEFAULT_APPLICATION_NAME")
462+
if defaultAppName == "" {
463+
log.Printf("No default application name supplied. Using the integration server name instead.")
464+
defaultAppName = serverName
465+
}
467466

468467
if qmgr.UseQueueManager() {
469468
qmgrName, err := name.GetQueueManagerName()
@@ -513,32 +512,56 @@ func stopIntegrationServer(integrationServerProcess command.BackgroundCmd) {
513512
}
514513

515514
func createWorkDir() error {
516-
log.Printf("Checking if work dir is already initialized")
517-
f, err := os.Open("/home/aceuser/ace-server")
518-
if err != nil {
519-
log.Printf("Error reading /home/aceuser/ace-server")
520-
return err
521-
}
522-
523-
log.Printf("Checking for contents in the work dir")
524-
_, err = f.Readdirnames(1)
525-
if err != nil {
526-
log.Printf("Work dir is not yet initialized - initializing now in /home/aceuser/ace-server")
527-
528-
if qmgr.UseQueueManager() {
529-
_, _, err := command.RunAsUser("mqm", "/opt/ibm/ace-11/server/bin/mqsicreateworkdir", "/home/aceuser/ace-server")
530-
if err != nil {
531-
log.Printf("Error reading initializing work dir")
532-
return err
533-
}
534-
} else {
535-
_, _, err := command.RunAsUser("aceuser", "/opt/ibm/ace-11/server/bin/mqsicreateworkdir", "/home/aceuser/ace-server")
536-
if err != nil {
537-
log.Printf("Error reading initializing work dir")
538-
return err
539-
}
540-
}
541-
}
542-
log.Printf("Work dir initialization complete")
543-
return nil
515+
log.Printf("Checking if work dir is already initialized")
516+
f, err := os.Open("/home/aceuser/ace-server")
517+
if err != nil {
518+
log.Printf("Error reading /home/aceuser/ace-server")
519+
return err
520+
}
521+
522+
log.Printf("Checking for contents in the work dir")
523+
_, err = f.Readdirnames(1)
524+
if err != nil {
525+
log.Printf("Work dir is not yet initialized - initializing now in /home/aceuser/ace-server")
526+
527+
if qmgr.UseQueueManager() {
528+
_, _, err := command.RunAsUser("mqm", "/opt/ibm/ace-11/server/bin/mqsicreateworkdir", "/home/aceuser/ace-server")
529+
if err != nil {
530+
log.Printf("Error reading initializing work dir")
531+
return err
532+
}
533+
} else {
534+
_, _, err := command.RunAsUser("aceuser", "/opt/ibm/ace-11/server/bin/mqsicreateworkdir", "/home/aceuser/ace-server")
535+
if err != nil {
536+
log.Printf("Error reading initializing work dir")
537+
return err
538+
}
539+
}
540+
}
541+
log.Printf("Work dir initialization complete")
542+
return nil
543+
}
544+
545+
func checkLogs() error {
546+
log.Printf("Contents of log directory")
547+
system("ls", "-l", "/home/aceuser/ace-server/config/common/log")
548+
549+
if os.Getenv("MQSI_PREVENT_CONTAINER_SHUTDOWN") == "true" {
550+
log.Printf("MQSI_PREVENT_CONTAINER_SHUTDOWN set to blocking container shutdown to enable log copy out")
551+
log.Printf("Once all logs have been copied out please kill container")
552+
select {}
553+
}
554+
555+
log.Printf("If you want to stop the container shutting down to enable retrieval of these files please set the environment variable \"MQSI_PREVENT_CONTAINER_SHUTDOWN=true\"")
556+
log.Printf("If you are running under kubernetes you will also need to disable the livenessProbe")
557+
log.Printf("Log checking complete")
558+
return nil
559+
}
560+
561+
func system(cmd string, arg ...string) {
562+
out, err := exec.Command(cmd, arg...).Output()
563+
if err != nil {
564+
log.Printf(err.Error())
565+
}
566+
log.Printf(string(out))
544567
}

cmd/runaceserver/integrationserver_internal_test.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ var yamlTests = []struct {
2323
in string
2424
out string
2525
}{
26-
{ // User's yaml has Statistics - it should keep accountingOrigin in Statics and any other main sections
27-
`
26+
{ // User's yaml has Statistics - it should keep accountingOrigin in Statics and any other main sections
27+
`
2828
Defaults:
2929
defaultApplication: ''
3030
policyProject: 'DefaultPolicies'
@@ -35,8 +35,8 @@ Statistics:
3535
accountingOrigin: 'test'
3636
Archive:
3737
test1: 'blah'
38-
test2: 'blah2'`,
39-
`Defaults:
38+
test2: 'blah2'`,
39+
`Defaults:
4040
Policies:
4141
HTTPSConnector: HTTPS
4242
defaultApplication: ""
@@ -54,14 +54,14 @@ Statistics:
5454
publicationOn: active
5555
threadDataLevel: none
5656
`},
57-
{ // User's yaml does not have a Statistics section, it adds the default metrics info
58-
`
57+
{ // User's yaml does not have a Statistics section, it adds the default metrics info
58+
`
5959
Defaults:
6060
defaultApplication: ''
6161
policyProject: 'DefaultPolicies'
6262
Policies:
63-
HTTPSConnector: 'HTTPS'`,
64-
`Defaults:
63+
HTTPSConnector: 'HTTPS'`,
64+
`Defaults:
6565
Policies:
6666
HTTPSConnector: HTTPS
6767
defaultApplication: ""
@@ -76,17 +76,17 @@ Statistics:
7676
publicationOn: active
7777
threadDataLevel: none
7878
`},
79-
{ // User's yaml has accountingOrigin in Statistics.Snapshot. It keeps this value.
80-
`
79+
{ // User's yaml has accountingOrigin in Statistics.Snapshot. It keeps this value.
80+
`
8181
Defaults:
8282
defaultApplication: ''
8383
policyProject: 'DefaultPolicies'
8484
Policies:
8585
HTTPSConnector: 'HTTPS'
8686
Statistics:
8787
Snapshot:
88-
accountingOrigin: 'test'`,
89-
`Defaults:
88+
accountingOrigin: 'test'`,
89+
`Defaults:
9090
Policies:
9191
HTTPSConnector: HTTPS
9292
defaultApplication: ""
@@ -115,3 +115,10 @@ func TestAddMetricsToServerConf(t *testing.T) {
115115
}
116116
}
117117
}
118+
119+
func TestCheckLogs(t *testing.T) {
120+
err := checkLogs()
121+
if err != nil {
122+
t.Error(err)
123+
}
124+
}

cmd/runaceserver/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ func doMain() error {
6565
qmgr.StopQueueManager(qmgrProcess)
6666
log.Print("Queue Mgr stopped")
6767

68+
checkLogs()
69+
6870
log.Print("Shutdown complete")
6971
}
7072

internal/metrics/update.go

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ import (
2626
"fmt"
2727
"math"
2828
"net/url"
29+
"net/http"
30+
"net/http/cookiejar"
2931
"os"
32+
"strings"
3033
"sync"
3134

3235
"github.com/ot4i/ace-docker/internal/logger"
@@ -160,11 +163,47 @@ func ReadStatistics(log *logger.Logger) {
160163
ServerName: aceAdminServerName,
161164
},
162165
}
163-
c, _, dialError = d.Dial(u.String(), nil)
166+
// Create the websocket connection
167+
c, _, dialError = d.Dial(u.String(), http.Header{"Origin": {u.String()}})
164168
} else {
165-
u := url.URL{Scheme: "ws", Host: *addr, Path: "/"}
166-
log.Printf("Connecting to %s for statistics", u.String())
167-
c, _, dialError = websocket.DefaultDialer.Dial(u.String(), nil)
169+
wsUrl := url.URL{Scheme: "ws", Host: *addr, Path: "/"}
170+
log.Printf("Connecting to %s for statistics", wsUrl.String())
171+
172+
d := websocket.DefaultDialer
173+
174+
// Retrieve session if the webusers exist
175+
contentBytes, err := ioutil.ReadFile("/home/aceuser/initial-config/webusers/admin-users.txt")
176+
if err != nil {
177+
log.Printf("Cannot find admin-users.txt file, not retrieving session")
178+
} else {
179+
userPassword := strings.Fields(string(contentBytes))
180+
username := userPassword[0]
181+
password := userPassword[1]
182+
183+
httpUrl := url.URL{Scheme: "http", Host: *addr, Path: "/"}
184+
client := &http.Client{}
185+
req, err := http.NewRequest("GET", httpUrl.String(), nil)
186+
req.SetBasicAuth(username, password)
187+
resp, err := client.Do(req)
188+
if err != nil{
189+
log.Errorf("Error retrieving session: %s", err)
190+
}
191+
192+
jar, _ := cookiejar.New(nil)
193+
if (resp != nil) {
194+
cookies := resp.Cookies()
195+
jar.SetCookies(&httpUrl, cookies)
196+
}
197+
198+
if (jar.Cookies(&httpUrl) != nil) {
199+
log.Printf("Connecting to %s using session cookie", wsUrl.String())
200+
d.Jar = jar
201+
} else {
202+
log.Printf("Connecting to %s without using session cookie", wsUrl.String())
203+
}
204+
}
205+
// Create the websocket connection
206+
c, _, dialError = d.Dial(wsUrl.String(), http.Header{"Origin": {wsUrl.String()}})
168207
}
169208

170209
if dialError == nil {

ubi/Dockerfile.acemq

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG BASE_IMAGE=ibmcom/mq:9.1.3.0-r3
1+
ARG BASE_IMAGE=ibmcom/mq:9.1.4.0-r1
22

33
FROM golang:1.10.3 as builder
44

@@ -57,7 +57,7 @@ COPY deps/OpenTracing/config/* ./etc/ACEOpenTracing/
5757

5858
WORKDIR /opt/ibm
5959

60-
RUN microdnf install --nodocs openssl util-linux unzip python2 && microdnf clean all
60+
RUN microdnf install openssl util-linux unzip python2 && microdnf clean all
6161
RUN microdnf update
6262
COPY --from=builder /opt/ibm/ace-11 /opt/ibm/ace-11
6363
RUN /opt/ibm/ace-11/ace make registry global accept license silently

ubi/Dockerfile.mqclient

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ARG BASE_IMAGE=ibmcom/ace
33
FROM $BASE_IMAGE
44

55
# The MQ packages to install - see install-mq.sh for default value
6-
ARG MQ_URL="https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/mqadv_dev913_linux_x86-64.tar.gz"
6+
ARG MQ_URL="https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/mqadv_dev914_linux_x86-64.tar.gz"
77
ARG MQ_URL_USER
88
ARG MQ_URL_PASS
99
ARG MQ_PACKAGES="MQSeriesRuntime*.rpm MQSeriesJava*.rpm MQSeriesGSKit*.rpm MQSeriesClient*.rpm"

0 commit comments

Comments
 (0)