Skip to content

Conversation

@sivanaikk
Copy link

… available

 ./bin/kagent-local version
{"backend_version":"0.6.10","build_date":"2025-09-10","git_commit":"37d6b63","kagent_version":"v0.0.0-37d6b63"}
➜  go git:(fix/kagent-cli-version) ✗ kagent uninstall

kagent uninstalled successfully
➜  go git:(fix/kagent-cli-version) ✗ 
➜  go git:(fix/kagent-cli-version) ✗ ./bin/kagent-local version            
{"backend_version":"unknown","build_date":"2025-09-10","git_commit":"37d6b63","kagent_version":"v0.0.0-37d6b63"}

Closes #868

Copilot AI review requested due to automatic review settings September 10, 2025 10:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the kagent CLI version command to display version information even when the controller/backend is unavailable. Previously, the version command would fail if it couldn't connect to the server, but now it shows available version information with "unknown" for backend_version when the controller is down.

  • Removes server connection checks from the version command
  • Allows version display regardless of backend availability
  • Maintains version command functionality in both CLI and interactive shell modes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@sivanaikk sivanaikk force-pushed the fix/kagent-cli-version branch from 20c1bd0 to 8ed8dbc Compare September 10, 2025 11:06
@EItanya
Copy link
Contributor

EItanya commented Sep 10, 2025

I don't think this is quite right. This removes the ability to port-forward for the version command altogether. I think rather we want to try and port-forward if the api-url is set to localhost. Does that make sense?

@marcinkubica
Copy link
Contributor

marcinkubica commented Sep 11, 2025

@sivanaikk @EItanya just a ping to make sure we're going in the direction of having this fix compatible with fundamental homebrew test

#868 (comment)

Minitest::Assertion: Expected /"kagent_version":"0\.6\.9"/ to match "".

EItanya pushed a commit that referenced this pull request Oct 6, 2025
…hrough contexts (#980)

This PR prints out the `kagent` version even if a port-forwarding to the
`kagent` server fails. In case the port-forwarding does not succeed, the
unavailable versions will be marked as `<unknown>`:

Fixes: #868
Related to: #879
```sh
> go run cli/cmd/kagent/main.go version
Error starting port-forward: failed to establish connection to kagent-controller. error connecting to server. Please run 'install' command first
{"backend_version":"unknown","build_date":"unknown","git_commit":"none","kagent_version":"dev"}
```

~~**Note:** We might can consider removing the error message as it
breaks the `json` output ...~~


Furthermore: 
- This PR uses `cmd.Context()` consistently throughout all `kagent`
subcommands.
- It adds a `help` Makefile target for a neat list of available Makefile
targets

```sh
> make
controller-gen                 Download controller-gen locally if necessary.
envtest                        Download setup-envtest locally if necessary.
fmt                            Run go fmt against code.
generate                       Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
golangci-lint                  Download golangci-lint locally if necessary.
help                           list makefile targets
lint-config                    Verify golangci-lint linter configuration
lint-fix                       Run golangci-lint linter and perform fixes
lint                           Run golangci-lint linter
manifests                      Generate ClusterRole and CustomResourceDefinition objects.
run                            Run a controller from your host.
setup-envtest                  Download the binaries required for ENVTEST in the local bin directory.
vet                            Run go vet against code.
```

Signed-off-by: Tom Morelly <[email protected]>
supreme-gg-gg pushed a commit to supreme-gg-gg/kagent that referenced this pull request Oct 7, 2025
…hrough contexts (kagent-dev#980)

This PR prints out the `kagent` version even if a port-forwarding to the
`kagent` server fails. In case the port-forwarding does not succeed, the
unavailable versions will be marked as `<unknown>`:

Fixes: kagent-dev#868
Related to: kagent-dev#879
```sh
> go run cli/cmd/kagent/main.go version
Error starting port-forward: failed to establish connection to kagent-controller. error connecting to server. Please run 'install' command first
{"backend_version":"unknown","build_date":"unknown","git_commit":"none","kagent_version":"dev"}
```

~~**Note:** We might can consider removing the error message as it
breaks the `json` output ...~~


Furthermore: 
- This PR uses `cmd.Context()` consistently throughout all `kagent`
subcommands.
- It adds a `help` Makefile target for a neat list of available Makefile
targets

```sh
> make
controller-gen                 Download controller-gen locally if necessary.
envtest                        Download setup-envtest locally if necessary.
fmt                            Run go fmt against code.
generate                       Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
golangci-lint                  Download golangci-lint locally if necessary.
help                           list makefile targets
lint-config                    Verify golangci-lint linter configuration
lint-fix                       Run golangci-lint linter and perform fixes
lint                           Run golangci-lint linter
manifests                      Generate ClusterRole and CustomResourceDefinition objects.
run                            Run a controller from your host.
setup-envtest                  Download the binaries required for ENVTEST in the local bin directory.
vet                            Run go vet against code.
```

Signed-off-by: Tom Morelly <[email protected]>
jmhbh pushed a commit to jmhbh/kagent that referenced this pull request Oct 10, 2025
…hrough contexts (kagent-dev#980)

This PR prints out the `kagent` version even if a port-forwarding to the
`kagent` server fails. In case the port-forwarding does not succeed, the
unavailable versions will be marked as `<unknown>`:

Fixes: kagent-dev#868
Related to: kagent-dev#879
```sh
> go run cli/cmd/kagent/main.go version
Error starting port-forward: failed to establish connection to kagent-controller. error connecting to server. Please run 'install' command first
{"backend_version":"unknown","build_date":"unknown","git_commit":"none","kagent_version":"dev"}
```

~~**Note:** We might can consider removing the error message as it
breaks the `json` output ...~~


Furthermore: 
- This PR uses `cmd.Context()` consistently throughout all `kagent`
subcommands.
- It adds a `help` Makefile target for a neat list of available Makefile
targets

```sh
> make
controller-gen                 Download controller-gen locally if necessary.
envtest                        Download setup-envtest locally if necessary.
fmt                            Run go fmt against code.
generate                       Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
golangci-lint                  Download golangci-lint locally if necessary.
help                           list makefile targets
lint-config                    Verify golangci-lint linter configuration
lint-fix                       Run golangci-lint linter and perform fixes
lint                           Run golangci-lint linter
manifests                      Generate ClusterRole and CustomResourceDefinition objects.
run                            Run a controller from your host.
setup-envtest                  Download the binaries required for ENVTEST in the local bin directory.
vet                            Run go vet against code.
```

Signed-off-by: Tom Morelly <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] cli: kagent version should not fail when controller is unavailable

3 participants