Sunday, April 28, 2019

Error:request.go:598:31: not enough arguments in call to watch.NewStreamWatcher have (*versioned.Decoder) want (watch.Decoder, watch.Reporter)

Symptom:

When we build a go program, we hit such error:
k8s.io/client-go/rest/request.go:598:31: not enough arguments in call to watch.NewStreamWatcher have (*versioned.Decoder) want (watch.Decoder, watch.Reporter)
It appears there are updates on the request.go which have new requirements
See details of changes log  on apimachinary 

Solution:

   We need to avoid to use the latest master branch of the client-go. Instead we can use stable version of client-go. Fortunately go-modules addresses these problems
see github go-modules
So here are the steps to fix it

  • $ export GO111MODULE=on
  • In your project location, run :  go mod init     ---- create go.mod file
  • Go build  cmd/test.go    --- go mod will fetch related files which replace dep ensure
  • You will still see the error, that's ok , next step we fix it 
  • Edit go.mod and replace client-go with correct version
  • In this case  we use :   k8s.io/client-go v0.0.0-20190425172711-65184652c889
  • Go build cmd/test.go     ---error would be gone

Saturday, April 27, 2019

Error: No route to host while ICMP is working

Symptom:

   We try to access a port 1521 service in a VM which has Oracle Linux 7.6 . Ping (ICMP) is working fine. But we get error when we test port via nc or telnet
Ncat: No route to host.

Solution:

  There are quite a few reasons for that.

  • check your subnet security list, make sure ports are open
  • use traceroute and dig to check route table is working as expected
  • check target VM linux firewalld is up 
In our case, firewalld is up by default, it blocks traffic of  1521. The error message is confusing people "Ncat: No route to host." . It is not about route. It is due to traffic blocked by target host Linux
Fix it via systemctl stop firewalld ;systemctl disable firewalld

Friday, April 26, 2019

Error: cannot refer to unexported name in Golang

Symptom:

  The packages are in the right place and imported ,but when we define variable from a type in another package, it error out when we define myvar a.mytype
Error: cannot refer to unexported name ******

package a
type  mytype struct {
    a int
}

package main
import "a"
func main() {
  var myvar a.mytype
}

Solution:

The reason why mytype can't be exported is due to Golang needs uppercase of first letter of a exported type or functions.  See more details in stackoverflow link

Correct one is
package a
type  Mytype struct {
    a int
}

package main
import "a"
func main() {
  var myvar a.Mytype
}

VirtualBox Guest OS Network Connects To Host VPN

Requirement:

   We have linux guest OS running in virtualbox win 10.  We have vpn running on win 10 host.
We have issues to connect to network in guest OS after VPN started.  After VPN shutdown, it works fine

Solution:

We need to add natdnsresolver1 to the VM

  • Set Guest OS to attach to NAT and use adapter to "Paravirutalized network"  
  • Shutdown Guest OS
  • Run VBoxManage.exe list vms
  • Run VBoxManage.exe modifyvm <uuid here or name > --natdnshostresolver1 on
  • Start Guest OS
  • We can disconnect and reconnect host VPN on the fly, Guest OS can pick up connections.


Wednesday, April 17, 2019

Error: Package libseccomp was not found in the pkg-config search path in go build

Symptom:

  When we test usage of  "github.com/seccomp/libseccomp-golang" , it always error out as below
package libseccomp was not found in the pkg-config search path.
Perhaps you should add the directory containing `libseccomp.pc'

Solution:

It turns out we need to manually compile this libseccomp library from code as it is not included in normal pkg.
  • download released C code from github
  • tar zxvf <release tar file>
  • ./configure
  • make
  • make install
Then we have this library included in our OS, the issue is gone