Closed rafzal1078 closed 2 years ago
Hi @rafzal1078, thanks for the issue. This issue looks to be related to running on an ARM cpu running 32bit in golang. I'll continue my research and see if I can come up with a fix shortly.
@rafzal1078 I have published a new release v2.7.1 which should fix it, though I don't have a 32 bit arm device on hand so I won't close the ticket until I have confirmation that it is really fixed.
Also I made a few tweaks to your bash script to show how it could be simplified a bit.
#!/bin/bash
# Check if someone has set a session already
if declare -p C8Y_SESSION >&/dev/null ; then
# This allows the script to play nicely if you want to run set-session yourself on the console before
# calling this script
echo "Session is already set (via C8Y_SESSION env variable)"
c8y sessions get
else
echo "Use fixed credentials (set via env variables)"
#
# Docs: https://goc8ycli.netlify.app/docs/concepts/sessions/#continuous-integration-usage-environment-variables
#
export C8Y_HOST=""
export C8Y_TENANT=""
export C8Y_USERNAME=""
export C8Y_PASSWORD=""
fi
# Disable all prompts and enable create/update/delete. Easier alternative rather than using c8y settings update mode.enableCreate 'true'
# docs: https://goc8ycli.netlify.app/docs/configuration/settings/#ci-boolean
export C8Y_SETTINGS_CI=true
install_software(){
local software="$1"
local version="$2"
local device="$3"
echo "Installing software: $name=$version on device ($device)"
echo "$device" | c8y software versions install --software "$software" --version "$version"
}
#
# Main
#
#
# Case statements are a little easier to read then if/else in this situation
#
case "$1" in
P)
echo "Setting P software install"
SOFTWARE="asdm_algorithm_stack_P"
;;
Q)
echo "Setting Q software install"
SOFTWARE="asdm_algorithm_stack_Q"
;;
*)
echo "No software release type set"
exit 1
;;
esac
#
# Select latest version (this relies on version sorting via gnu sort)
#
echo "Finding latest version of '$SOFTWARE'"
LATEST_VERSION=$(
c8y software versions list \
--software "$SOFTWARE" \
--select "c8y_Software.version" \
--includeAll \
--output csv \
| sort -Vr \
| head -1
)
#
# Check if the latest version is defined, and cancel if not
#
if [ -z "$LATEST_VERSION" ]; then
echo "Could not find the latest version for software package '$SOFTWARE'"
exit 2
fi
#
# Update this part to do want you want. I just changed it so the 2nd script argument is the target device...
#
TARGET_DEVICE="$2"
install_software "$SOFTWARE" "$LATEST_VERSION" "$TARGET_DEVICE"
Actually I was able to test it on an armel (arm32) bit and c8y v2.7.1 works now
I verified the bug in v2.7.0
user@device:~/tmp$ ./c8y_2.7.0 software versions list --software python3-c8yda -p 1
panic: unaligned 64-bit atomic operation
goroutine 11 [running]:
runtime/internal/atomic.panicUnaligned()
/opt/hostedtoolcache/go/1.16.13/x64/src/runtime/internal/atomic/unaligned.go:8 +0x24
runtime/internal/atomic.Xadd64(0x137e504, 0x1, 0x0, 0x0, 0x1c64c)
/opt/hostedtoolcache/go/1.16.13/x64/src/runtime/internal/atomic/asm_arm.s:233 +0x14
github.com/reubenmiller/go-c8y-cli/pkg/iterator.(*SliceIterator).GetNext(0x137e4f8, 0x8, 0x0, 0x4, 0x1c3b0, 0x19f74, 0x13c8400, 0x8)
/home/runner/work/go-c8y-cli/go-c8y-cli/pkg/iterator/slice.go:16 +0x34
github.com/reubenmiller/go-c8y-cli/pkg/c8yfetcher.(*EntityIterator).GetNext(0x138e180, 0x775901, 0x138e180, 0x91fad4, 0x138e180, 0x1, 0x0, 0x0)
/home/runner/work/go-c8y-cli/go-c8y-cli/pkg/c8yfetcher/c8yfetcher.go:234 +0x34
github.com/reubenmiller/go-c8y-cli/pkg/flags.(*StringTemplate).Execute(0x1340430, 0x5fa00, 0x0, 0x0, 0x0, 0x102ad18, 0x0, 0x13c83f8, 0x0, 0x1, ...)
/home/runner/work/go-c8y-cli/go-c8y-cli/pkg/flags/stringtemplate.go:77 +0x2e8
github.com/reubenmiller/go-c8y-cli/pkg/flags.(*StringTemplate).GetNext(0x1340430, 0x102ad18, 0x0, 0x0, 0x1, 0x13c83f8, 0x0, 0x1)
/home/runner/work/go-c8y-cli/go-c8y-cli/pkg/flags/stringtemplate.go:100 +0x38
github.com/reubenmiller/go-c8y-cli/pkg/requestiterator.(*RequestIterator).GetNext(0x1327c20, 0x7e9aba, 0x19, 0x102ae4c, 0x1, 0x1)
/home/runner/work/go-c8y-cli/go-c8y-cli/pkg/requestiterator/requestiterator.go:86 +0xc60
github.com/reubenmiller/go-c8y-cli/pkg/worker.(*Worker).runBatched.func1(0x12db1c0, 0x13a8e78, 0x13961e0, 0x1327c20, 0x0, 0x0, 0x12db200, 0x0, 0x0, 0x1, ...)
/home/runner/work/go-c8y-cli/go-c8y-cli/pkg/worker/worker.go:223 +0x100
created by github.com/reubenmiller/go-c8y-cli/pkg/worker.(*Worker).runBatched
/home/runner/work/go-c8y-cli/go-c8y-cli/pkg/worker/worker.go:215 +0x368
And ran the same command in the new v2.7.1
user@device:~/tmp$ ./c8y_2.7.1 software versions list --software python3-c8yda -p 1
| additionParents.references.0.managedObject.additionParents.references | additionParents.references.0.managedObject.additionParents.self |
|-----------------------------------------------------------------------|--------------------------------------------------------------------------------|
| [] | https://dummy-value.com/inventory/managedObjects/111111/addi… |
Thank you for the quick response, and improvements to my script. I will on my setup today.
I receive an error when trying to run the 'software versions list --software' command on a RaspberryPi. Here is the script I'm using to set my session and run the command:
This is the command prompt output when running the script:
I am able to run 'c8y software list' without getting the error.