weaveworks / wks-quickstart-firekube

Example configuration to create Kubernetes clusters powered by ignite and gitops
342 stars 372 forks source link

./setup fails due to cant read property '0' of undefined #88

Open nexus-uw opened 4 years ago

nexus-uw commented 4 years ago

hi, I cloned the latest from master earlier today. the setup files fails due to

• Creating Cluster API manifests
/home/simon/wks-quickstart-firekube/setup.js:114
      privateIP: machine.runtimeNetworks[0].ip,
                                        ^
TypeError: Cannot read property '0' of undefined
    at /home/simon/wks-quickstart-firekube/setup.js:114:41
Module (setup.js) has not been loaded

any insights in what i am missing would be greatly appreciated.

machine info below

~/wks-quickstart-firekube$ ignite version
Ignite version: version.Info{Major:"0", Minor:"7", GitVersion:"v0.7.1", GitCommit:"e80a75a4a451395deeb03e37dde7057b9fc29606", GitTreeState:"clean", BuildDate:"2020-07-13T15:52:07Z", GoVersion:"go1.14.2", Compiler:"gc", Platform:"linux/amd64", SandboxImage:version.Image{Name:"weaveworks/ignite", Tag:"v0.7.1", Delimeter:":"}, KernelImage:version.Image{Name:"weaveworks/ignite-kernel", Tag:"4.19.125", Delimeter:":"}}
Firecracker version: v0.21.1
Runtime: containerd

kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.8", GitCommit:"9f2892aab98fe339f3bd70e3c470144299398ace", GitTreeState:"clean", BuildDate:"2020-08-13T16:12:48Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?

docker version
Client: Docker Engine - Community
 Version:           19.03.12
 API version:       1.40
 Go version:        go1.13.10
 Git commit:        48a66213fe
 Built:             Mon Jun 22 15:45:44 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          19.03.11
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.12
  Git commit:       77e06fd
  Built:            Mon Jun  8 20:24:59 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
isfukuda commented 4 years ago

Hello. Me as well. But I did "cleanup.sh", after that it's fine in my case.

$ ./setup.sh
      privateIP: machine.runtimeNetworks[0].ip,
                                        ^
TypeError: Cannot read property '0' of undefined
    at /home/shinichi/work/wks-quickstart-firekube/setup.js:114:41

$ ./cleanup.sh 
 Deleting virtual machines
INFO[0000] Deleting machine: firekube-node0 ...         
INFO[0000] Deleting machine: firekube-node1 ... 

$ ./setup.sh 
 Using git branch: master
 Using git remote: origin
 Found jk 0.3.0
 Found footloose 0.6.3
 Found ignite 0.7.1
 Found wksctl 0.8.4
 Creating footloose manifest
 Creating virtual machines
INFO[0000] Docker Image: weaveworks/ignite-centos:firekube-pre3 present locally 
INFO[0000] Creating machine: firekube-node0 ...         
INFO[0002] Creating machine: firekube-node1 ...         
 Creating Cluster API manifests
 Updating container images and git parameters
 Pushing initial cluster configuration
*** Please tell me who you are.
MikePadge commented 3 years ago

Running cleanup doesn't resolve this for me. Forging forward with versioning.

Ignite version: version.Info{Major:"0", Minor:"9"

kubectl version client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.4", GitCommit:"e87da0bd6e03ec3fea7933c4b5263d151aafd07c", GitTreeState:"clean", BuildDate:"2021-02-18T16:12:00Z", GoVersion:"go1.15.8", Compiler:"gc", Platform:"linux/amd64"}
jk 0.3.0
footloose 0.6.3
ignite 0.9.0
wksctl 0.10.2
System Kernel 4.19.0-14-amd64 #1 SMP Debian

Client: Docker Engine - Community
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:17:50 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.5
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       363e9a8
  Built:            Tue Mar  2 20:15:47 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

I'm failing every time with

• Creating Cluster API manifests
/firekube/setup.js:114
      privateIP: machine.runtimeNetworks[0].ip,
                                        ^
TypeError: Cannot read property '0' of undefined
    at /firekube/setup.js:114:41

This looks like something happening with footloose and ignite, because if I swap the backend to docker, everything stands up accordingly, but it could be an issue with the cni plugin. I'm using the default config for ignite.

If I had to take a wild guess, it's due to this

func (m *Machine) igniteStatus(s *MachineStatus) error {
    vm, err := ignite.PopulateMachineDetails(m.name)
    if err != nil {
        return err
    }

    // Set Ports
    var ports []port
    for _, p := range vm.Spec.Network.Ports {
        ports = append(ports, port{
            Host:  int(p.HostPort),
            Guest: int(p.VMPort),
        })
    }
    s.Ports = ports
    if vm.Status.IpAddresses != nil && len(vm.Status.IpAddresses) > 0 {
        m.ip = vm.Status.IpAddresses[0]
    }

    s.RuntimeNetworks = NewIgniteRuntimeNetwork(&vm.Status)

    return nil
}

in https://github.com/weaveworks/footloose/blob/ff126705213e7bf19306994b212ce1a0b3be52a7/pkg/cluster/machine.go

Not properly seeing that it's an ignite vm? And trying to pull details from a docker container that isn't there?

MikePadge commented 3 years ago

@stealthybox this is what I was referring to in https://github.com/weaveworks/ignite/issues/614

I thought my pr resolved the issue, but it actually causes the script to ignore the ignite backend designation, and reverts to Docker.

tristech81 commented 3 years ago

I'm have this same issue is there a fix / workaround for this?

I guess it has to do with versions because I have same versions as above

• Found jk 0.3.0 • Found footloose 0.6.3 • Found ignite 0.9.0 • Found wksctl 0.10.2

mhmxs commented 3 years ago

If it helps i had the same issue, but because of some previous failed installation. After i executed ./cleanup.sh issue gone.

kewp commented 2 years ago

Having the same issue but cleanup.sh is not fixing it.

It's definitely footloose - if you look at setup.sh you see footloose generates a status json file, which is then read by jk, and jk is looking for a field called runtimeNetworks which is not there (jk translates json into javascript objects).

This is how you can see the json being produced by footloose:

sudo ~/.wks/bin/footloose status -o json > status.json

Look at the output and you'll see a list of machines. Then you can read it into jk like this and see the same error:

~/.wks/bin/jk generate -f config.yaml -f status.json setup.js

(This is just mimicking what setup.sh does.)

kewp commented 2 years ago

Oh I should add that I had to add the ignite binary to the sudo folder cause the above commands complained otherwise https://confluence.jaytaala.com/display/TKB/Adding+folder%28s%29+to+Sudoers+%28sudo%29+Path

I ended up installing ignite manually https://github.com/weaveworks/ignite/blob/main/docs/installation.md#downloading-the-binary and then putting /usr/local/bin at the end of the sudo defaults, but I suppose /home/{user}/.wks/bin should work too...

dulom commented 1 year ago

`./setup.sh • Using git branch: main • Using git remote: origin

• Found jk 0.4.0 • Found footloose 0.6.3 • Found ignite 0.10.0 • Found wksctl 0.10.2 • Creating footloose manifest • Creating virtual machines INFO[0000] Docker Image: harbor.platomics.com/proxy/weaveworks/ignite-centos:7-v0.10.0 present locally INFO[0000] Creating machine: firekube-node0 ...
INFO[0002] Creating machine: firekube-node1 ...
• Creating Cluster API manifests /home/ubuntu/repostories/platomics/firekube/setup.js:114 privateIP: machine.runtimeNetworks[0].ip, ^ TypeError: Cannot read property '0' of undefined at /home/ubuntu/repostories/platomics/firekube/setup.js:114:41 Module (setup.js) has not been loaded`

I still get the same problem that my machine definition is missing runtimeNetworks even after installing firecube from scatch. Any advice for me to investigate the problem further ?

zakariaboualaid commented 1 year ago

If you got this error then most probably you installed ignite's latest version before firekube, and when wks-quickstart-firekube runs its setup.sh script and finds ignite binary, it skips downloading the version 0.7.1. If you have a version superior to this version then downgrade because this repo is only tested with the versions mentioned in ./setup.sh.

basaran commented 1 year ago

I had the same problem, and as @zakariaboualaid suggests it is due to the fact that the repository and the scripts included within are expecting ignite version 0.7.1.

If you had installed the latest and greatest ignite, you need to perform some cleanup. For me, this is what worked:

  1. sudo ./cleanup.sh
  2. rm -fR /var/lib/firecracker
  3. sudo ./setup.sh --force-download

It was necessary for me to remove the fireracker folder in step 2. But experience caution, perhaps get a backup instead of removing it.

--force-download will actually download the ignite version 0.7.1 to /root/.wks/bin which means you don't have to uninstall your latest and greatest ignite while experimenting with this repository.

P.S Prior to executing ./setup.sh, you would also likely need to configure git login for the sudo user.

sudo  git config --global user.email "my@email.com"
sudo git config --global user.name "me"
basaran commented 1 year ago

meanwhile, I am now getting another error:

during the execution of:

wksctl apply --git-url=https://github.com/basaran/wks-quickstart-firekube.git --git-branch=master
INFO[2023-03-14T11:08:19-04:00] Applying                                      resource="install:base"
INFO[2023-03-14T11:08:19-04:00] Applying                                      resource="install:yum-utils"
INFO[2023-03-14T11:08:19-04:00] Applying                                      resource="install:yum-versionlock"
ERRO[2023-03-14T11:08:21-04:00] Failed                                        resource="install:yum-versionlock"
command exited with 1
INFO[2023-03-14T11:08:21-04:00] State of Resource 'top' is Invalid.
Explanation:
{
 "resource": "top",
 "status": "Invalid"
}
ERRO[2023-03-14T11:08:21-04:00] Failed                                        resource="install:base"