nmstate / kubernetes-nmstate

Declarative node network configuration driven through Kubernetes API.
GNU General Public License v2.0
177 stars 87 forks source link

Git URL rewriting and `make cluster-up` (i.e. local cluster testing) #1124

Open constcrist opened 1 year ago

constcrist commented 1 year ago

What happened: make cluster-up would stop without properly configuring the local cluster. Somewhere midway the installation scripts:

  1. would wipe out the cloned _kubevirtci repository, reclone it;
  2. try to access _kubevirtci/_ci-configs/k8s-1.22/.kubectl which is no longer there (maybe because it is not re-compiled?)
  3. fail

Snippet from the logs dumped by make cluster-up:

...
selecting docker as container runtime
+ [[ k8s-1.22 =~ ^(okd|ocp)-.*2865759 ]]
++ ./cluster/kubectl.sh get nodes --no-headers
++ awk '{print $1}'
Cloning into '/home/cco/go/src/github.com/kubernetes-nmstate/_kubevirtci'...
X11 forwarding request failed on channel 0
remote: Enumerating objects: 11859, done.
remote: Counting objects: 100% (106/106), done.
remote: Compressing objects: 100% (46/46), done.
remote: Total 11859 (delta 63), reused 88 (delta 54), pack-reused 11753
Receiving objects: 100% (11859/11859), 26.41 MiB | 2.54 MiB/s, done.
Resolving deltas: 100% (6792/6792), done.
Note: switching to '2210070932-bcdea3e'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at bcdea3e Update sonobuoy version to v0.56.9 (#857)
selecting docker as container runtime
/home/cco/go/src/github.com/kubernetes-nmstate/_kubevirtci/cluster-up//cluster/ephemeral-provider-common.sh: line 155: /home/cco/go/src/github.com/kubernetes-nmstate/_kubevirtci/_ci-configs/k8s-1.22/.kubectl: No such file or directory
+ echo 'Enabling and starting up openvswitch'
Enabling and starting up openvswitch
++ ./cluster/kubectl.sh get nodes --no-headers
++ awk '{print $1}'
Cloning into '/home/cco/go/src/github.com/kubernetes-nmstate/_kubevirtci'...
X11 forwarding request failed on channel 0
remote: Enumerating objects: 11859, done.
remote: Counting objects: 100% (106/106), done.
remote: Compressing objects: 100% (47/47), done.
remote: Total 11859 (delta 63), reused 87 (delta 53), pack-reused 11753
Receiving objects: 100% (11859/11859), 26.41 MiB | 4.25 MiB/s, done.
Resolving deltas: 100% (6792/6792), done.
Note: switching to '2210070932-bcdea3e'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at bcdea3e Update sonobuoy version to v0.56.9 (#857)
selecting docker as container runtime
/home/cco/go/src/github.com/kubernetes-nmstate/_kubevirtci/cluster-up//cluster/ephemeral-provider-common.sh: line 155: /home/cco/go/src/github.com/kubernetes-nmstate/_kubevirtci/_ci-configs/k8s-1.22/.kubectl: No such file or directory

I have traced this back to:

  1. git configuration on the test machine is rewriting the git URL in .gitconfig:

    [url "git@github.com:"]
    insteadOf = https://github.com/
  2. the following test in the cluster/kubevirtci.sh script fails and triggers re-cloning:

    function kubevirtci::install() {
    # Remove cloned kubevirtci repository if it does not match the requested one
    if [[ -d ${KUBEVIRTCI_PATH} ]]; then
        if [[ $(kubevirtci::_get_repo) != ${KUBEVIRTCI_REPO} || $(kubevirtci::_get_tag) != ${KUBEVIRTCI_TAG} ]]; then
            rm -rf ${KUBEVIRTCI_PATH}
        fi
    fi
    ...

    As soon as I modify the KUBEVIRTCI_REPO to point to git@github.com:kubevirt/kubevirtci.git (which matches what is used on the test machine) installation works.

What you expected to happen: Imo, ideally make cluster-up should work regardless of the git URL re-writing rules. Maybe, at least the documentation here: https://nmstate.io/kubernetes-nmstate/deployment/local-cluster.html should tell the user to set-up accordingly the KUBEVIRTCI_REPO in the cluster/kubevirtci.sh script.

How to reproduce it (as minimally and precisely as possible):

  1. configure some git URL rewriting rule.
  2. do a make cluster-up

Anything else we need to know?:

Environment:

dougsland commented 1 year ago

/assign

dougsland commented 1 year ago

@phoracek is this one working as expected or needs some work?

phoracek commented 1 year ago

@dougsland I don't know how common is the insteadOf config, but I'd agree that the script should be resilient enough to bring up a cluster even if there is a special config in place.