Update debug script to warn VS throw exception
Change-Id: Ic8359d2c2f21b0960ddeb0d75907eef8d61bedc5
Signed-off-by: Joey Armstrong <jarmstrong@linuxfoundation.org>
diff --git a/vars/dotkube.groovy b/vars/dotkube.groovy
index e451f42..3b1b460 100644
--- a/vars/dotkube.groovy
+++ b/vars/dotkube.groovy
@@ -1,6 +1,6 @@
#!/usr/bin/env groovy
// -----------------------------------------------------------------------
-// Copyright 2024 Open Networking Foundation (ONF) and the ONF Contributors
+// Copyright 2024 Open Networking Foundation Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -14,6 +14,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// -----------------------------------------------------------------------
+// SPDX-FileCopyrightText: 2024 Open Networking Foundation Contributors
+// SPDX-License-Identifier: Apache-2.0
+// -----------------------------------------------------------------------
+// Intent: Helper script for kubernetes debugging
+// Called by: jjb/pipeline/voltha/bbsim-tests.groovy
+// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
@@ -44,40 +50,66 @@
}
// -----------------------------------------------------------------------
+// Intent: Terminate a process by name.
+// -----------------------------------------------------------------------
+// Note: Due to an exception casting GString to java.lang.string:
+// - Used for parameterized construction of a command line with args
+// - Passed to jenkins sh("${cmd}")
+// - Command line invoked is currently hardcoded.
+// -----------------------------------------------------------------------
+Boolean process(String proc, Map args) {
+ Boolean ans = true
+ String iam = getIam('process')
+
+ // clusterName: kind-ci
+ // config=kind-{clusterName}
+ // -------------------------
+ // loader.go:223] Config not found: /home/jenkins/.kube/kind-kind-ci
+ sh(
+ label : '[DEBUG] ls ~/.kube'
+ script : """
+echo -e "\n** /bin/ls -ld ~/.kube"
+/bin/ls -ld ~/.kube
+
+echo -e "\n** /bin/ls -ld: recursive"
+find ~/.kube/. -print0 | xargs -0 /bin/ls -ld
+""")
+
+ return(ans)
+}
+
+// -----------------------------------------------------------------------
// Intent: Display debug info about .kube/*
// -----------------------------------------------------------------------
-def call(Map config) {
- config ?: [:]
+// Usage: dotkube([debug:False])
+// -----------------------------------------------------------------------
+Boolean call\
+(
+ Map config=[:] // Args passed to callback function
+) {
// Boolean debug = config.debug ?: false
String iam = getIam('main')
+ Boolean ans = true
try {
enter(iam)
+ process()
+ }
- // clusterName: kind-ci
- // config=kind-{clusterName}
- // -------------------------
- // loader.go:223] Config not found: /home/jenkins/.kube/kind-kind-ci
- stage('.kube/ debugging')
- {
- sh("""/bin/ls -ld ~/.kube """)
- sh("""find ~/.kube -print0 \
- | grep --null --null-data -e 'cache' -e 'temp' \
- | xargs -0 /bin/ls -ld""")
- // if (config['do-something']) {}
- }
+ // [DEBUG] function is non-fatal
+ catch (Exception err) { // groovylint-disable-line CatchException
+ // ans = false
+ println("** ${iam}: EXCEPTION WARNING ${err}")
+ // println("** ${iam}: EXCEPTION ${err}")
+ // throw err // non-fatal, no need to croak on find/ls errs
}
- // groovylint-disable-next-line
- catch (Exception err) {
- println("** ${iam}: EXCEPTION ${err}")
- throw err
- }
+
finally {
leave(iam)
}
- return
+ return(ans)
}
// [EOF]