Skip to content

Commit db2ea27

Browse files
committed
Do not assume replicas are active/ready. Diagnostics are still useful (and particularly so) if pods are not in those states.
Signed-off-by: Kevin Grigorenko <kevin.grigorenko@us.ibm.com>
1 parent 4352ea2 commit db2ea27

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

containerdiag.bat

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
SETLOCAL ENABLEDELAYEDEXPANSION
2323

24-
set "VERSION=0.1.20230227"
24+
set "VERSION=0.1.20230301"
2525
set "SCRIPTNAME=%~nx0"
2626

2727
goto :start
@@ -148,20 +148,20 @@ if "!NAMESPACE!" == "" (
148148
)
149149

150150
if not "!TARGETDEPLOYMENT!" == "" (
151-
call :printInfo Querying available replicas for deployment !TARGETDEPLOYMENT! in namespace !NAMESPACE!
151+
call :printInfo Querying replicas for deployment !TARGETDEPLOYMENT! in namespace !NAMESPACE!
152152

153-
for /F "tokens=* USEBACKQ" %%x in (`!CTL! get deployment !TARGETDEPLOYMENT! "--namespace=!NAMESPACE!" "--output=jsonpath={.status.availableReplicas}"`) do set "AVAILABLEREPLICAS=%%x"
154-
if "!AVAILABLEREPLICAS!" == "" (
153+
for /F "tokens=* USEBACKQ" %%x in (`!CTL! get deployment !TARGETDEPLOYMENT! "--namespace=!NAMESPACE!" "--output=jsonpath={.status.replicas}"`) do set "REPLICAS=%%x"
154+
if "!REPLICAS!" == "" (
155155
call :printInfo Error getting deployment information. Ensure you specify the right namespace with -n NAMESPACE
156156
exit /B 1
157157
)
158158

159-
if "!AVAILABLEREPLICAS!" == "0" (
160-
call :printInfo There are 0 available replicas for this deployment
159+
if "!REPLICAS!" == "0" (
160+
call :printInfo There are 0 replicas for this deployment
161161
exit /B 1
162162
)
163163

164-
call :printInfo There are !AVAILABLEREPLICAS! available replicas
164+
call :printInfo There are !REPLICAS! replicas
165165

166166
call :printInfo Querying deployment selector label
167167

containerdiag.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ EOF
3535
exit 22
3636
}
3737

38-
VERSION="0.1.20230227"
38+
VERSION="0.1.20230301"
3939
NAMESPACE=""
4040
VERBOSE=0
4141
APPEND=1
@@ -143,28 +143,28 @@ processPod() {
143143
}
144144

145145
if [ "${TARGETDEPLOYMENT}" != "" ]; then
146-
printInfo "Querying available replicas for deployment ${TARGETDEPLOYMENT} in namespace ${NAMESPACE}"
146+
printInfo "Querying replicas for deployment ${TARGETDEPLOYMENT} in namespace ${NAMESPACE}"
147147

148148
# Let's check if the deployment has any active pods
149-
AVAILABLEREPLICAS="$("${CTL}" get deployment "${TARGETDEPLOYMENT}" "--namespace=${NAMESPACE}" "--output=jsonpath={.status.availableReplicas}")"
149+
REPLICAS="$("${CTL}" get deployment "${TARGETDEPLOYMENT}" "--namespace=${NAMESPACE}" "--output=jsonpath={.status.replicas}")"
150150
RC="${?}"
151151

152152
if [ ${RC} -ne 0 ]; then
153153
printInfo "Error ${RC} getting deployment information (see previous output). Ensure you specify the right namespace with -n NAMESPACE"
154154
exit ${RC}
155155
fi
156156

157-
if [ "${AVAILABLEREPLICAS}" = "" ]; then
157+
if [ "${REPLICAS}" = "" ]; then
158158
printInfo "Error getting deployment information. Ensure you specify the right namespace with -n NAMESPACE"
159159
exit 1
160160
fi
161161

162-
if [ "${AVAILABLEREPLICAS}" -eq 0 ]; then
163-
printInfo "Error: There are 0 available replicas for this deployment"
162+
if [ "${REPLICAS}" -eq 0 ]; then
163+
printInfo "Error: There are 0 replicas for this deployment"
164164
exit 1
165165
fi
166166

167-
printInfo "There are ${AVAILABLEREPLICAS} available replicas"
167+
printInfo "There are ${REPLICAS} replicas"
168168

169169
printInfo "Querying deployment selector label"
170170

0 commit comments

Comments
 (0)