kata-containers / tests

Kata Containers tests, CI, and metrics
https://katacontainers.io/
Apache License 2.0
141 stars 195 forks source link

!x86 could not import C #4044

Closed Jakob-Naucke closed 2 years ago

Jakob-Naucke commented 2 years ago
[static-checks.sh:360] INFO: Running golangci-lint on /home/jenkins/workspace/kata-containers-2.0-ubuntu-s390x-PR/go/src/github.com/kata-containers/kata-containers/src/runtime/cmd/kata-runtime
++ cd /home/jenkins/workspace/kata-containers-2.0-ubuntu-s390x-PR/go/src/github.com/kata-containers/kata-containers/src/runtime/cmd/kata-runtime
++ GO111MODULE=auto
++ eval golangci-lint 'run -c /home/jenkins/workspace/kata-containers-2.0-ubuntu-s390x-PR/go/src/github.com/kata-containers/tests/.ci/.golangci.yml' .
+++ golangci-lint run -c /home/jenkins/workspace/kata-containers-2.0-ubuntu-s390x-PR/go/src/github.com/kata-containers/tests/.ci/.golangci.yml .
kata-check.go:16:8: could not import C (cgo preprocessing failed) (typecheck)
import "C"
       ^
+ remove_tmp_files
+ rm -rf /tmp/tmp.f7kqpWjFRe /tmp/tmp.Dqns1cvvrD

post #4027, http://jenkins.katacontainers.io/job/kata-containers-2.0-ubuntu-ARM-PR/2451, http://jenkins.katacontainers.io/job/kata-containers-2.0-ubuntu-s390x-PR/694, haven't been able to reproduce so far /cc @Amulyam24 @jongwu

Jakob-Naucke commented 2 years ago

Eh. I can sorta reproduce this: s390x, gcc not installed (err 1):

~/go/src/github.com/kata-containers/kata-containers/src/runtime/cmd/kata-runtime$ golangci-lint run ~/go/src/github.com/kata-containers/tests/.ci/.golangci.yml .
ERRO [linters context] typechecking error: directory ../../../../../tests/.ci/.golangci.yml outside available modules 
kata-check.go:16:8: could not import C (cgo preprocessing failed) (typecheck)
import "C"
       ^

s390x, gcc installed (err 1):

~/go/src/github.com/kata-containers/kata-containers/src/runtime/cmd/kata-runtime$ golangci-lint run ~/go/src/github.com/kata-containers/tests/.ci/.golangci.yml .
ERRO [linters context] typechecking error: directory ../../../../../tests/.ci/.golangci.yml outside available modules 
kata-check_s390x_test.go:59:16: fieldalignment: struct with 24 pointer bytes could be 16 (govet)
        type testData struct {
                      ^

x86_64 (err 7):

~/go/src/github.com/kata-containers/kata-containers/src/runtime/cmd/kata-runtime$ golangci-lint run ~/go/src/github.com/kata-containers/tests/.ci/.golangci.yml .
ERRO [linters context] typechecking error: directory ../../../../../tests/.ci/.golangci.yml outside available modules 
Jakob-Naucke commented 2 years ago

I can reach the same err 7 by having gcc installed and fixing alignment á la https://github.com/kata-containers/kata-containers/pull/2237

Jakob-Naucke commented 2 years ago

and gcc will be there after running .ci/setup.sh, but the static checks are run before.

Jakob-Naucke commented 2 years ago

re alignment: see https://github.com/kata-containers/kata-containers/pull/2774

Amulyam24 commented 2 years ago

@Jakob-Naucke , I'm able to reproduce this error on ppc64le now, however, I do have gcc installed and still see this

WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package katautils: could not load export data: no export data for "github.com/kata-containers/kata-containers/src/runtime/pkg/katautils" 
[static-checks.sh:360] INFO: Running golangci-lint on /home/katauser/go/src/github.com/kata-containers/kata-containers/src/runtime/cmd/kata-monitor
WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package katautils: could not load export data: no export data for "github.com/kata-containers/kata-containers/src/runtime/pkg/katautils" 
[static-checks.sh:360] INFO: Running golangci-lint on /home/katauser/go/src/github.com/kata-containers/kata-containers/src/runtime/cmd/kata-runtime
kata-check.go:16:8: could not import C (cgo preprocessing failed) (typecheck)
import "C"
       ^
root@kata5:/home/katauser/go/src/github.com/kata-containers/kata-containers# apt install -y gcc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gcc is already the newest version (4:9.3.0-1ubuntu2).
Jakob-Naucke commented 2 years ago

@Amulyam24 yes, gcc seems to be a red herring. At this moment, it works for me on s390x with gcc not installed (like it does on x86_64).

Jakob-Naucke commented 2 years ago

I have found an architecture-agnostic, back-and-forth-switchable condition to reproduce this: It's the file kata-containers/src/runtime/pkg/katautils/config-settings.go, which is generated by build processes, that must be present for this to work.

Jakob-Naucke commented 2 years ago

Hmmm. For the static checks on GHA, we run the full setup anyways: https://github.com/kata-containers/kata-containers/blob/8739a73dd3fa036e81ecf1612c2a82c5f10cad20/.github/workflows/static-checks.yaml#L60. I still think your approach is nicer because it catches static errors before building and is therefore less CI load. I will check how easy it is to generate that file, and if it itakes me too long, we will just move the static checks after the setup.

Amulyam24 commented 2 years ago

Hmmm. For the static checks on GHA, we run the full setup anyways: https://github.com/kata-containers/kata-containers/blob/8739a73dd3fa036e81ecf1612c2a82c5f10cad20/.github/workflows/static-checks.yaml#L60. I still think your approach is nicer because it catches static errors before building and is therefore less CI load. I will check how easy it is to generate that file, and if it itakes me too long, we will just move the static checks after the setup.

Sure @Jakob-Naucke , makes sense. Let me know if you need me to create a PR for moving the changes it that doesn't work.