operator-framework / ansible-operator-plugins

Experimental extraction/refactoring of the Operator SDK's ansible operator plugin
Apache License 2.0
8 stars 18 forks source link

kubectl v1.30.0 command failed in ansible-operator:v1.34.1 with error malformed ws or wss URL #87

Open caixiangibm opened 1 month ago

caixiangibm commented 1 month ago

Bug Report

kubectl v1.30.0 command failed in ansible-operator:v1.34.1 with error malformed ws or wss URL

What did you do?

We built our ansible operator image based on quay.io/operator-framework/ansible-operator:v1.34.1, and also put kubectl v1.30.0 into the operator image. In one of ansible operator task, we need to use kubectl to copy some folder to temporary Operator pod, but this task failed with following error messages (some words are masked) FAILED! => {"changed": true, "cmd": ["kubectl", "cp", "/some_path/some_folder", "{{tmp_operator_pod_name}}:/some_path", "-n", "name_space"], ..., "msg": "non-zero return code", "rc": 1, ..., "stderr": "Defaulted container \"operator\" out of: operator, * (init)\nerror: malformed ws or wss URL", "stderr_lines": ["Defaulted container \"operator\" out of: operator, (init)", "error: malformed ws or wss URL"], "stdout": "", "stdout_lines": []}

- block:
  - name: Copy some folder from Operator to temporary Operator pod
    command: kubectl cp /some_path/some_folder {{tmp_operator_pod_name}}:/some_path -n {{meta.namespace}}

But the same task works with kubectl v1.29.3 or kubectl v1.28.0

What did you expect to see?

We expect the latest kubectl 1.30.* should work with ansible-operator:v1.34.1 or higher version to run "kubectl cp" or other kubectl commands.

What did you see instead? Under which circumstances?

"kubectl cp" command (kubectl v1.30.0) failed with error: malformed ws or wss URL

Environment

Operator type:

language ansible

Kubernetes cluster type:

OpenShift

$ operator-sdk version

ansible-operator version ansible-operator version: "v1.34.1", commit: "a954ad17369509a87bc108f316276cb1cb4157ee", kubernetes version: "v1.28.0", go version: "go1.20.14", GOOS: "linux", GOARCH: "amd64"

$ go version (if language is Go)

ansible-operator v1.34.1 - go version: "go1.20.14" kubectl v1.30.0 - goVersion: go1.22.2

$ kubectl version

kubectl version --client -o yaml
clientVersion:
  buildDate: "2024-04-17T17:36:05Z"
  compiler: gc
  gitCommit: 7c48c2bd72b9bf5c44d21d7338cc7bea77d0ad2a
  gitTreeState: clean
  gitVersion: v1.30.0
  goVersion: go1.22.2
  major: "1"
  minor: "30"
  platform: linux/amd64
kustomizeVersion: v5.0.4-0.20230601165947-6ce0bf390ce3

Possible Solution

Not sure whether it is compatible problem for ansible-operator to invoke other go application (e.g. kubectl)? kubectl v1.30.0 - goVersion: go1.22.2 kubectl v1.29.3 - goVersion: go1.21.8 kubectl v1.28.0 - goVersion: go1.20.7

Additional context

openshift-ci[bot] commented 1 month ago

@caixiangibm: The label(s) language/ansible cannot be applied, because the repository doesn't have them.

In response to [this](https://github.com/operator-framework/ansible-operator-plugins/issues/87): >## Bug Report >kubectl v1.30.0 command failed in ansible-operator:v1.34.1 with error malformed ws or wss URL > >#### What did you do? > >We built our ansible operator image based on quay.io/operator-framework/ansible-operator:v1.34.1, and also put kubectl v1.30.0 into the operator image. >In one of ansible operator task, we need to use kubectl to copy some folder to temporary Operator pod, but this task failed with following error messages (some words are masked) >FAILED! => {"changed": true, "cmd": ["kubectl", "cp", "/some_path/some_folder", "{{tmp_operator_pod_name}}:/some_path", "-n", "name_space"], ..., "msg": "non-zero return code", "rc": 1, ..., "stderr": "Defaulted container \"operator\" out of: operator, **** (init)\nerror: malformed ws or wss URL", "stderr_lines": ["Defaulted container \"operator\" out of: operator, *** (init)", "error: malformed ws or wss URL"], "stdout": "", "stdout_lines": []} >``` >- block: > - name: Copy some folder from Operator to temporary Operator pod > command: kubectl cp /some_path/some_folder {{tmp_operator_pod_name}}:/some_path -n {{meta.namespace}} >``` > >But the same task works with kubectl v1.29.3 or kubectl v1.28.0 > >#### What did you expect to see? > >We expect the latest kubectl 1.30.* should work with ansible-operator:v1.34.1 or higher version to run "kubectl cp" or other kubectl commands. > >#### What did you see instead? Under which circumstances? > >"kubectl cp" command (kubectl v1.30.0) failed with error: malformed ws or wss URL > >#### Environment > >**Operator type:** > >/language ansible > >**Kubernetes cluster type:** > >OpenShift > >`$ operator-sdk version` > >ansible-operator version >ansible-operator version: "v1.34.1", commit: "a954ad17369509a87bc108f316276cb1cb4157ee", kubernetes version: "v1.28.0", go version: "go1.20.14", GOOS: "linux", GOARCH: "amd64" > >`$ go version` (if language is Go) > >ansible-operator v1.34.1 - go version: "go1.20.14" >kubectl v1.30.0 - goVersion: go1.22.2 > >`$ kubectl version` >``` >kubectl version --client -o yaml >clientVersion: > buildDate: "2024-04-17T17:36:05Z" > compiler: gc > gitCommit: 7c48c2bd72b9bf5c44d21d7338cc7bea77d0ad2a > gitTreeState: clean > gitVersion: v1.30.0 > goVersion: go1.22.2 > major: "1" > minor: "30" > platform: linux/amd64 >kustomizeVersion: v5.0.4-0.20230601165947-6ce0bf390ce3 >``` >#### Possible Solution >Not sure whether it is compatible problem for ansible-operator to invoke other go application (e.g. kubectl)? >kubectl v1.30.0 - goVersion: go1.22.2 >kubectl v1.29.3 - goVersion: go1.21.8 >kubectl v1.28.0 - goVersion: go1.20.7 > >#### Additional context > Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
PYLochou commented 1 week ago

Note that the command: kubectl cp could be rewritten with k8s_cp module (https://docs.ansible.com/ansible/latest/collections/kubernetes/core/k8s_cp_module.html) regardless of kubectl version.