Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gitops check failing after kubectl --short flag deprecation #4157

Closed
mjtrangoni opened this issue Dec 6, 2023 · 4 comments · Fixed by #4158
Closed

gitops check failing after kubectl --short flag deprecation #4157

mjtrangoni opened this issue Dec 6, 2023 · 4 comments · Fixed by #4158
Labels
bug Something isn't working

Comments

@mjtrangoni
Copy link

Describe the bug

Running gitops check return exit status 1 instead of skipping/handling the error.

Environment

  • Weave-Gitops Version
gitops version
Current Version: 0.37.0
GitCommit: 3f850ced58c9fe9d593807e299058e0e06c735eb
BuildTime: 2023-11-22T13:24:19Z
Branch: releases/v0.37.0
  • Flux Version
 flux -v
flux version 2.1.2
  • Kubernetes version
kubectl version
Client Version: v1.28.4
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.28.3+k3s2

To Reproduce
Steps to reproduce the behavior:

  1. Having a running flux and gitops installation
kubectl get po -n flux-system
NAME                                           READY   STATUS    RESTARTS   AGE
helm-controller-5f964c6579-kz2vg               1/1     Running   0          2d16h
kustomize-controller-9c588946c-nhrvf           1/1     Running   0          2d16h
notification-controller-76dc5d768-l8hqh        1/1     Running   0          2d16h
source-controller-6c49485888-jz5t6             1/1     Running   0          2d16h
image-reflector-controller-84c449dc57-vpqqj    1/1     Running   0          2d12h
image-automation-controller-7764f8957c-l7xll   1/1     Running   0          2d12h
ww-gitops-weave-gitops-5fcfdb67b4-6x2fg        1/1     Running   0          22h
  1. Run gitops check
gitops check
Error: unable to get kubernetes version: exit status 1

Expected behavior

To run without errors, maybe checking kubectl version compatibility?

Actual Behavior

gitops check
Error: unable to get kubernetes version: exit status 1

Additional Context (screenshots, logs, etc)

It seems this is related to kubectl --short flag used in this project, see here.

As it says in kubectl's CHANGELOG.md, --short is deprecated and changed kubectl version default output to be identical to what kubectl version --short printed

@mjtrangoni mjtrangoni added the bug Something isn't working label Dec 6, 2023
@bigkevmcd
Copy link
Contributor

@makkes wanna take a look? :-)

@makkes
Copy link
Member

makkes commented Dec 6, 2023

I'm on it.

makkes pushed a commit that referenced this issue Dec 6, 2023
The `--short` flag has been removed from `kubectl version` in 1.28
(https://github.com/kubernetes/kubernetes/blob/7fe31be11fbe9b44af262d5f5cffb1e73648aa96/CHANGELOG/CHANGELOG-1.28.md#L1718)
so the command obviously fails now.

This commit changes the behaviour of the `gitops check` command to
create a client-go DiscoveryClient and use that to retrieve the server
version. That way we don't have to rely on forking a `kubectl` process
and the output being consistent.

The code is now much cleaner, easier to read and properly tested.

closes #4157

Signed-off-by: Max Jonas Werner <mail@makk.es>
makkes pushed a commit that referenced this issue Dec 6, 2023
The `--short` flag has been removed from `kubectl version` in 1.28
(https://github.com/kubernetes/kubernetes/blob/7fe31be11fbe9b44af262d5f5cffb1e73648aa96/CHANGELOG/CHANGELOG-1.28.md#L1718)
so the command obviously fails now.

This commit changes the behaviour of the `gitops check` command to
create a client-go DiscoveryClient and use that to retrieve the server
version. That way we don't have to rely on forking a `kubectl` process
and the output being consistent.

The code is now much cleaner, easier to read and properly tested.

closes #4157

Signed-off-by: Max Jonas Werner <mail@makk.es>
makkes pushed a commit that referenced this issue Dec 6, 2023
The `--short` flag has been removed from `kubectl version` in 1.28
(https://github.com/kubernetes/kubernetes/blob/7fe31be11fbe9b44af262d5f5cffb1e73648aa96/CHANGELOG/CHANGELOG-1.28.md#L1718)
so the command obviously fails now.

This commit changes the behaviour of the `gitops check` command to
create a client-go DiscoveryClient and use that to retrieve the server
version. That way we don't have to rely on forking a `kubectl` process
and the output being consistent.

The code is now much cleaner, easier to read and properly tested.

closes #4157

Signed-off-by: Max Jonas Werner <mail@makk.es>
makkes pushed a commit that referenced this issue Dec 6, 2023
The `--short` flag has been removed from `kubectl version` in 1.28
(https://github.com/kubernetes/kubernetes/blob/7fe31be11fbe9b44af262d5f5cffb1e73648aa96/CHANGELOG/CHANGELOG-1.28.md#L1718)
so the command obviously fails now.

This commit changes the behaviour of the `gitops check` command to
create a client-go DiscoveryClient and use that to retrieve the server
version. That way we don't have to rely on forking a `kubectl` process
and the output being consistent.

The code is now much cleaner, easier to read and properly tested.

closes #4157

Signed-off-by: Max Jonas Werner <mail@makk.es>
bigkevmcd pushed a commit that referenced this issue Dec 6, 2023
* Fix `gitops check`

The `--short` flag has been removed from `kubectl version` in 1.28
(https://github.com/kubernetes/kubernetes/blob/7fe31be11fbe9b44af262d5f5cffb1e73648aa96/CHANGELOG/CHANGELOG-1.28.md#L1718)
so the command obviously fails now.

This commit changes the behaviour of the `gitops check` command to
create a client-go DiscoveryClient and use that to retrieve the server
version. That way we don't have to rely on forking a `kubectl` process
and the output being consistent.

The code is now much cleaner, easier to read and properly tested.

closes #4157

* Bump supported K8s version

The support policy of Weave GitOps is to "test Weave GitOps against
the latest supported Kubernetes releases" which means that only 1.26,
1.27 and 1.28 are supported at this point.

This change doesn't prevent Weave GitOps from being run on older
versions of Kubernetes as the constraint is only used by the
`gitops check` command which is purely informational.

Signed-off-by: Max Jonas Werner <mail@makk.es>
@makkes
Copy link
Member

makkes commented Dec 6, 2023

@mjtrangoni this should be fixed in the 0.38.0 CLI which we released today. Mind giving it a try?

@mjtrangoni
Copy link
Author

@makkes thank you! It works now, see

 gitops version
Current Version: 0.38.0
GitCommit: 693dafd494f1027c4bc740be9ffef98e21cdcfb6
BuildTime: 2023-12-06T15:43:30Z
Branch: releases/v0.38.0
 gitops check
✔ Kubernetes 1.28.4+k3s1 >=1.26

Not related with this issue but I just wonder, the command says, Validate flux and kubernetes compatibility but the output is only about kubernetes. Is it working as intended?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants