open-horizon / anax

Horizon agent control system
https://open-horizon.github.io/docs/anax/docs/
Apache License 2.0
73 stars 98 forks source link

Bug: ./agent-install.sh: line 1562: -1: substring expression < 0 #4072

Closed ashutosrath closed 2 months ago

ashutosrath commented 3 months ago

Describe the bug.

Getting below error while running ./agent-install.sh in macosx bash shell

./agent-install.sh: line 1562: -1: substring expression < 0

Describe the steps to reproduce the behavior.

kubectl version -o json
{
  "clientVersion": {
    "major": "1",
    "minor": "27",
    "gitVersion": "v1.27.2",
    "gitCommit": "7f6f68fdabc4df88cfea2dcf9a19b2b830f1e647",
    "gitTreeState": "clean",
    "buildDate": "2023-05-17T14:20:07Z",
    "goVersion": "go1.20.4",
    "compiler": "gc",
    "platform": "darwin/amd64"
  },
  "kustomizeVersion": "v5.0.1",
  "serverVersion": {
    "major": "1",
    "minor": "29+",
    "gitVersion": "v1.29.4-eks-036c24b",
    "gitCommit": "9c0e57823b31865d0ee095997d9e7e721ffdc77f",
    "gitTreeState": "clean",
    "buildDate": "2024-04-30T23:53:58Z",
    "goVersion": "go1.21.9",
    "compiler": "gc",
    "platform": "linux/amd64"
  }
}
WARNING: version difference between client (1.27) and server (1.29) exceeds the supported minor version skew of +/-1

here the minor_version is calculated as

echo $minor_version
29+

MacOSX bash returns substring expression < 0 error if we calculate as

minor_version=${minor_version::-1}

Fix needs to be like below

minor_version=${minor_version::$((${#minor_version} - 1))}

Expected behavior.

the min_version should have properly calculated

Screenshots.

No response

Operating Environment

mac osx x86

Additional Information

No response