From c3cc15a159623d49822feaac8423844aa37b935a Mon Sep 17 00:00:00 2001 From: Daniel Hiller Date: Fri, 20 Sep 2024 10:39:42 +0200 Subject: [PATCH] kubevirtci: replace kci/cluster/virtctl.sh calls KubeVirtCI project has a circular dependency on the virtctl binary [1] - it expects the binary to be present at a certain path. Thus we create our own version of virtctl.sh in the hack folder. We then replace all calls to `virtctl.sh` with the new location. [1]: https://github.com/kubevirt/kubevirtci/issues/1277 Signed-off-by: Daniel Hiller --- cmd/sidecars/README.md | 4 ++-- cmd/sidecars/smbios/README.md | 2 +- docs/README.md | 4 ++-- docs/getting-started.md | 4 ++-- hack/build-verify.sh | 6 +++--- hack/virtctl.sh | 36 +++++++++++++++++++++++++++++++++++ 6 files changed, 46 insertions(+), 10 deletions(-) create mode 100755 hack/virtctl.sh diff --git a/cmd/sidecars/README.md b/cmd/sidecars/README.md index dd692b85f230..bdbdaad7de9f 100644 --- a/cmd/sidecars/README.md +++ b/cmd/sidecars/README.md @@ -205,10 +205,10 @@ see if the desired changes to baseboard manufacturer get reflected: ```shell # Once the VM is ready, connect to its display and login using name and password "fedora" -cluster/virtctl.sh vnc vmi-with-sidecar-hook-configmap +hack/virtctl.sh vnc vmi-with-sidecar-hook-configmap # Check whether the base board manufacturer value was successfully overwritten sudo dmidecode -s baseboard-manufacturer # or cat /sys/devices/virtual/dmi/id/board_vendor -``` \ No newline at end of file +``` diff --git a/cmd/sidecars/smbios/README.md b/cmd/sidecars/smbios/README.md index 510ba92581e9..45c38ee2195c 100644 --- a/cmd/sidecars/smbios/README.md +++ b/cmd/sidecars/smbios/README.md @@ -17,7 +17,7 @@ annotations: cluster/kubectl.sh create -f examples/vmi-with-sidecar-hook.yaml # Once the VM is ready, connect to its display and login using name and password "fedora" -cluster/virtctl.sh vnc vm-with-sidecar-hook +hack/virtctl.sh vnc vm-with-sidecar-hook # Install dmidecode sudo dnf install -y dmidecode diff --git a/docs/README.md b/docs/README.md index 7c0b292b64cd..3042cf530b5d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -45,9 +45,9 @@ the VMI's pod and receives lifecycle commands from virt-handler. * `kubevirtci/cluster-up/kubectl.sh`: This is a wrapper around Kubernetes' kubectl command so that it can be run directly from this checkout without logging into a node. - * `kubevirtci/cluster-up/virtctl.sh` is a wrapper around `virtctl`. `virtctl` brings all + * `hack/virtctl.sh` is a wrapper around `virtctl`. `virtctl` brings all virtual machine specific commands with it. It is supplement to `kubectl`. - e.g. `kubevirtci/cluster-up/virtctl.sh console testvm`. + e.g. `hack/virtctl.sh console testvm`. * `kubevirtci/cluster-up/cli.sh` helps you create ephemeral kubernetes and openshift clusters for testing. This is helpful when direct management or access to cluster nodes is necessary. e.g. `kubevirtci/cluster-up/cli.sh ssh node01`. diff --git a/docs/getting-started.md b/docs/getting-started.md index a5d7eb14b358..9b775438e142 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -348,12 +348,12 @@ to add virt-viewer installation folder to their `PATH`. Then, after you made sure that the VMI `vmi-ephemeral` is running, type: ``` -kubevirtci/cluster-up/virtctl.sh vnc vmi-ephemeral +hack/virtctl.sh vnc vmi-ephemeral ``` This will start a remote session with `remote-viewer`. -`kubevirtci/cluster-up/virtctl.sh` is a wrapper around `virtctl`. `virtctl` brings all +`hack/virtctl.sh` is a wrapper around `virtctl`. `virtctl` brings all virtual machine specific commands with it and is a supplement to `kubectl`. **Note:** If accessing your cluster through ssh, be sure to forward your X11 session in order to launch `virtctl vnc`. diff --git a/hack/build-verify.sh b/hack/build-verify.sh index 880f62fe913b..34140e6f9b2b 100755 --- a/hack/build-verify.sh +++ b/hack/build-verify.sh @@ -5,17 +5,17 @@ set -e function report_dirty_build() { set +e echo "Build is not clean:" - kubevirtci/cluster-up/virtctl.sh version + hack/virtctl.sh version git status exit 1 } # Check that "clean" is reported at least once -if [ -z "$(kubevirtci/cluster-up/virtctl.sh version | grep clean)" ]; then +if [ -z "$(hack/virtctl.sh version | grep clean)" ]; then report_dirty_build fi # Check that "dirty" is never reported -if [ -n "$(kubevirtci/cluster-up/virtctl.sh version | grep dirty)" ]; then +if [ -n "$(hack/virtctl.sh version | grep dirty)" ]; then report_dirty_build fi diff --git a/hack/virtctl.sh b/hack/virtctl.sh new file mode 100755 index 000000000000..acf0597df6d9 --- /dev/null +++ b/hack/virtctl.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# This file is part of the KubeVirt project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Copyright 2018 Red Hat, Inc. +# + +set -e + +source hack/config-kubevirtci.sh + +source ${KUBEVIRTCI_PATH}/hack/common.sh +source ${KUBEVIRTCI_CLUSTER_PATH}/$KUBEVIRT_PROVIDER/provider.sh +source ${KUBEVIRTCI_PATH}/hack/config.sh + +CONFIG_ARGS= + +if [ -n "$kubeconfig" ]; then + CONFIG_ARGS="--kubeconfig=${kubeconfig}" +elif [ -n "$KUBECONFIG" ]; then + CONFIG_ARGS="--kubeconfig=${KUBECONFIG}" +fi + +_out/cmd/virtctl/virtctl $CONFIG_ARGS "$@"