Skip to content

OWLS-89535 - scalingAction.sh script fails if multiple domains are running in the same namespace #2388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 17 additions & 24 deletions operator/scripts/scaling/scalingAction.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function get_custom_resource_domain() {
-v \
--cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \
-H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" \
$kubernetes_master/apis/weblogic.oracle/$domain_api_version/namespaces/$wls_domain_namespace/domains/$domain_uid)
$kubernetes_master/apis/weblogic.oracle/$domain_api_version/namespaces/$wls_domain_namespace/domains/$wls_domain_uid)
if [ $? -ne 0 ]; then
trace "Failed to retrieve WebLogic Domain Custom Resource Definition"
exit 1
Expand All @@ -164,7 +164,7 @@ function is_defined_in_clusters() {
local in_cluster_startup="False"

if jq_available; then
local inClusterStartupCmd="(.items[].spec.clusters[] | select (.clusterName == \"${wls_cluster_name}\"))"
local inClusterStartupCmd="(.spec.clusters[] | select (.clusterName == \"${wls_cluster_name}\"))"
local clusterDefinedInCRD=$(echo "${DOMAIN}" | jq "${inClusterStartupCmd}" 2>> ${log_file_name})
if [ "${clusterDefinedInCRD}" != "" ]; then
in_cluster_startup="True"
Expand All @@ -173,13 +173,11 @@ function is_defined_in_clusters() {
cat > cmds-$$.py << INPUT
import sys, json
outer_loop_must_break = False
for i in json.load(sys.stdin)["items"]:
j = i["spec"]["clusters"]
for index, cs in enumerate(j):
if j[index]["clusterName"] == "$wls_cluster_name":
outer_loop_must_break = True
print (True)
break
for j in json.load(sys.stdin)["spec"]["clusters"]:
if j["clusterName"] == "$wls_cluster_name":
outer_loop_must_break = True
print (True)
break
if outer_loop_must_break == False:
print (False)
INPUT
Expand All @@ -195,16 +193,14 @@ function get_num_ms_in_cluster() {
local DOMAIN="$1"
local num_ms
if jq_available; then
local numManagedServersCmd="(.items[].spec.clusters[] | select (.clusterName == \"${wls_cluster_name}\") | .replicas)"
local numManagedServersCmd="(.spec.clusters[] | select (.clusterName == \"${wls_cluster_name}\") | .replicas)"
num_ms=$(echo "${DOMAIN}" | jq "${numManagedServersCmd}" 2>> ${log_file_name})
else
cat > cmds-$$.py << INPUT
import sys, json
for i in json.load(sys.stdin)["items"]:
j = i["spec"]["clusters"]
for index, cs in enumerate(j):
if j[index]["clusterName"] == "$wls_cluster_name":
print (j[index]["replicas"])
for j in json.load(sys.stdin)["spec"]["clusters"]:
if j["clusterName"] == "$wls_cluster_name":
print (j["replicas"])
INPUT
num_ms=`echo ${DOMAIN} | python cmds-$$.py 2>> ${log_file_name}`
fi
Expand All @@ -223,12 +219,11 @@ function get_num_ms_domain_scope() {
local DOMAIN="$1"
local num_ms
if jq_available; then
num_ms=$(echo "${DOMAIN}" | jq -r '.items[].spec.replicas' 2>> ${log_file_name})
num_ms=$(echo "${DOMAIN}" | jq -r '.spec.replicas' 2>> ${log_file_name})
else
cat > cmds-$$.py << INPUT
import sys, json
for i in json.load(sys.stdin)["items"]:
print (i["spec"]["replicas"])
print (json.load(sys.stdin)["spec"]["replicas"])
INPUT
num_ms=`echo ${DOMAIN} | python cmds-$$.py 2>> ${log_file_name}`
fi
Expand All @@ -254,17 +249,15 @@ function get_min_replicas {

eval $__result=0
if jq_available; then
minReplicaCmd="(.items[].status.clusters[] | select (.clusterName == \"${clusterName}\")) \
minReplicaCmd="(.status.clusters[] | select (.clusterName == \"${clusterName}\")) \
| .minimumReplicas"
minReplicas=$(echo ${domainJson} | jq "${minReplicaCmd}" 2>> ${log_file_name})
else
cat > cmds-$$.py << INPUT
import sys, json
for i in json.load(sys.stdin)["items"]:
j = i["status"]["clusters"]
for index, cs in enumerate(j):
if j[index]["clusterName"] == "$clusterName":
print (j[index]["minimumReplicas"])
for j in json.load(sys.stdin)["status"]["clusters"]:
if j["clusterName"] == "$clusterName":
print (j["minimumReplicas"])
INPUT
minReplicas=`echo ${DOMAIN} | python cmds-$$.py 2>> ${log_file_name}`
fi
Expand Down
40 changes: 40 additions & 0 deletions operator/src/test/sh/scaling/2clusters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"apiVersion": "weblogic.oracle/v8",
"kind": "Domain",
"spec": {
"clusters": [
{
"clusterName": "cluster-1",
"replicas": 1,
"serverStartState": "RUNNING"
},
{
"clusterName": "cluster-2",
"replicas": 2,
"serverStartState": "RUNNING"
}
],
"dataHome": "",
"domainHome": "/shared/domains/domain1",
"domainHomeSourceType": "PersistentVolume",
"httpAccessLogInLogHome": true,
"image": "container-registry.oracle.com/middleware/weblogic:12.2.1.4",
"imagePullPolicy": "IfNotPresent",
"includeServerOutInPodLog": false,
"logHome": "/shared/logs/domain1",
"logHomeEnabled": true,
"replicas": 2
},
"status": {
"clusters": [
{
"clusterName": "cluster-1",
"minimumReplicas": 1
},
{
"clusterName": "cluster-2",
"minimumReplicas": 2
}
]
}
}
63 changes: 29 additions & 34 deletions operator/src/test/sh/scaling/cluster1.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
{
"apiVersion":"weblogic.oracle/v8",
"items":[
{
"apiVersion": "weblogic.oracle/v8",
"kind": "Domain",
"spec": {
"clusters": [
{
"clusterName": "cluster-1",
"replicas": 1,
"serverStartState": "RUNNING"
}
],
"dataHome": "",
"domainHome": "/shared/domains/domain1",
"domainHomeSourceType": "PersistentVolume",
"httpAccessLogInLogHome": true,
"image": "container-registry.oracle.com/middleware/weblogic:12.2.1.4",
"imagePullPolicy": "IfNotPresent",
"includeServerOutInPodLog": false,
"logHome": "/shared/logs/domain1",
"logHomeEnabled": true,
"replicas": 2
},
"status": {
"clusters": [
{
"clusterName": "cluster-1",
"minimumReplicas": 1
}
]
}
}
]
"apiVersion": "weblogic.oracle/v8",
"kind": "Domain",
"spec": {
"clusters": [
{
"clusterName": "cluster-1",
"replicas": 1,
"serverStartState": "RUNNING"
}
],
"dataHome": "",
"domainHome": "/shared/domains/domain1",
"domainHomeSourceType": "PersistentVolume",
"httpAccessLogInLogHome": true,
"image": "container-registry.oracle.com/middleware/weblogic:12.2.1.4",
"imagePullPolicy": "IfNotPresent",
"includeServerOutInPodLog": false,
"logHome": "/shared/logs/domain1",
"logHomeEnabled": true,
"replicas": 2
},
"status": {
"clusters": [
{
"clusterName": "cluster-1",
"minimumReplicas": 1
}
]
}
}
63 changes: 29 additions & 34 deletions operator/src/test/sh/scaling/cluster_min3.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
{
"apiVersion":"weblogic.oracle/v8",
"items":[
{
"apiVersion": "weblogic.oracle/v8",
"kind": "Domain",
"spec": {
"clusters": [
{
"clusterName": "cluster-1",
"replicas": 1,
"serverStartState": "RUNNING"
}
],
"dataHome": "",
"domainHome": "/shared/domains/domain1",
"domainHomeSourceType": "PersistentVolume",
"httpAccessLogInLogHome": true,
"image": "container-registry.oracle.com/middleware/weblogic:12.2.1.4",
"imagePullPolicy": "IfNotPresent",
"includeServerOutInPodLog": false,
"logHome": "/shared/logs/domain1",
"logHomeEnabled": true,
"replicas": 2
},
"status": {
"clusters": [
{
"clusterName": "cluster-1",
"minimumReplicas": 3
}
]
}
}
]
"apiVersion": "weblogic.oracle/v8",
"kind": "Domain",
"spec": {
"clusters": [
{
"clusterName": "cluster-1",
"replicas": 1,
"serverStartState": "RUNNING"
}
],
"dataHome": "",
"domainHome": "/shared/domains/domain1",
"domainHomeSourceType": "PersistentVolume",
"httpAccessLogInLogHome": true,
"image": "container-registry.oracle.com/middleware/weblogic:12.2.1.4",
"imagePullPolicy": "IfNotPresent",
"includeServerOutInPodLog": false,
"logHome": "/shared/logs/domain1",
"logHomeEnabled": true,
"replicas": 2
},
"status": {
"clusters": [
{
"clusterName": "cluster-1",
"minimumReplicas": 3
}
]
}
}
43 changes: 19 additions & 24 deletions operator/src/test/sh/scaling/cluster_noreplicas.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
{
"apiVersion":"weblogic.oracle/v8",
"items":[
{
"apiVersion": "weblogic.oracle/v8",
"kind": "Domain",
"spec": {
"clusters": [
{
"clusterName": "cluster-1",
"serverStartState": "RUNNING"
}
],
"dataHome": "",
"domainHome": "/shared/domains/domain1",
"domainHomeSourceType": "PersistentVolume",
"httpAccessLogInLogHome": true,
"image": "container-registry.oracle.com/middleware/weblogic:12.2.1.4",
"imagePullPolicy": "IfNotPresent",
"includeServerOutInPodLog": false,
"logHome": "/shared/logs/domain1",
"logHomeEnabled": true
}
}
]
"apiVersion": "weblogic.oracle/v8",
"kind": "Domain",
"spec": {
"clusters": [
{
"clusterName": "cluster-1",
"serverStartState": "RUNNING"
}
],
"dataHome": "",
"domainHome": "/shared/domains/domain1",
"domainHomeSourceType": "PersistentVolume",
"httpAccessLogInLogHome": true,
"image": "container-registry.oracle.com/middleware/weblogic:12.2.1.4",
"imagePullPolicy": "IfNotPresent",
"includeServerOutInPodLog": false,
"logHome": "/shared/logs/domain1",
"logHomeEnabled": true
}
}
Loading