Can't install operator_sdk on win10: "cannot use syscall.NsecToFiletime"

111 Views Asked by At

I tried following the instructions from the official documentation page of "Operator SDK". The device I'm trying to install it on is running on Windows 10, AMD64. I installed GNU Make via Chocolatey.

 make --version
GNU Make 4.4.1
Built for Windows32
Copyright (C) 1988-2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

As per the "Command and install from master" section of the official documentation:

git clone https://github.com/operator-framework/operator-sdk
cd operator-sdk
git checkout master
make install

The last line "make install" fails:

make install
go install -gcflags "all=-trimpath=C:/Users/erjan/Downloads/operator_k8s_sdk" -asmflags "all=-trimpath=C:/Users/erjan/Downloads/operator_k8s_sdk" -ldflags " -X 'github.com/operator-framework/operator-sdk/internal/version.Version=v1.31.0+git' -X 'github.com/operator-framework/operator-sdk/internal/version.GitVersion=v1.31.0-3-gd21ed649' -X 'github.com/operator-framework/operator-sdk/internal/version.GitCommit=d21ed6499ebfc8ecdb4508e1c2a2a0cfd2a151f3' -X 'github.com/operator-framework/operator-sdk/internal/version.KubernetesVersion=v1.26.0' -X 'github.com/operator-framework/operator-sdk/internal/version.ImageVersion=v1.31.0' "  ./cmd/# github.com/containerd/containerd/archive
..\..\..\go\pkg\mod\github.com\containerd\[email protected]\archive\tar_windows.go:234:19: cannot use syscall.NsecToFiletime(hdr.AccessTime.UnixNano()) (value of type syscall.Filetime) as "golang.org/x/sys/windows".Filetime value in struct literal
..\..\..\go\pkg\mod\github.com\containerd\[email protected]\archive\tar_windows.go:235:19: cannot use syscall.NsecToFiletime(hdr.ModTime.UnixNano()) (value of type syscall.Filetime) as "golang.org/x/sys/windows".Filetime value in struct literal
..\..\..\go\pkg\mod\github.com\containerd\[email protected]\archive\tar_windows.go:236:19: cannot use syscall.NsecToFiletime(hdr.ChangeTime.UnixNano()) (value of type syscall.Filetime) as "golang.org/x/sys/windows".Filetime value in struct literal
..\..\..\go\pkg\mod\github.com\containerd\[email protected]\archive\tar_windows.go:239:17: cannot use syscall.NsecToFiletime(hdr.ModTime.UnixNano()) (value of type syscall.Filetime) as "golang.org/x/sys/windows".Filetime value in struct literal
..\..\..\go\pkg\mod\github.com\containerd\[email protected]\archive\tar_windows.go:257:27: cannot use syscall.NsecToFiletime(createTime.UnixNano()) (value of type syscall.Filetime) as "golang.org/x/sys/windows".Filetime value in assignment
make: *** [Makefile:75: install] Error 1

What could be the reason for this error?

2

There are 2 best solutions below

5
VonC On BEST ANSWER

I see there are several lines where Go is complaining about a type mismatch. Specifically, it is mentioning that syscall.Filetime cannot be used as "golang.org/x/sys/windows".Filetime.

..\..\..\go\pkg\mod\github.com\containerd\[email protected]\archive\tar_windows.go:234:19: cannot use syscall.NsecToFiletime(hdr.AccessTime.UnixNano()) (value of type syscall.Filetime) as "golang.org/x/sys/windows".Filetime value in struct literal

A value of type syscall.Filetime is being used where a value of type "golang.org/x/sys/windows".Filetime is expected. This is a type mismatch issue. The file tar_windows.go within the github.com/containerd/containerd package seems to be the source of these errors, and it appears to be related to how file timestamps are being handled on Windows.

containerd/containerd v1.4.11 seems quite old, considering the operator-framework/operator-sdk project itself needs containerd v1.7.0

Since I got the same error through make install, I tried first go build -a -v ..., which does not trigger errors. The Makefile fails on go install ./cmd/{operator-sdk,helm-operator}

  • go install ./cmd/helm-operator works.
  • go install ./cmd/operator-sdk has the error

That bug is confirmed with your issue operator-framework/operator-sdk issue 6585

We do not officially support or build binaries for windows. But we are open to receiving any help with contributions.
Duplicate of #6586

Operator SDK doesn't officially support or build binaries for Windows.

However, there have been instances where users could still build SDK binary from master on their windows machines. This error seems to be coming from github.com\containerd\[email protected].
Looks like it may have an issue. Also, we have explicitly pinned containerd to 1.4.11:

operator-sdk/go.mod:

github.com/containerd/containerd => github.com/containerd/containerd v1.4.11 

because a bump in it breaks github.com/deislabs/oras.

I would suggest to start by checking if a bump in dependencies fixes these issues without breaking anything else in SDK. If so, we can merge that in master to fix it. Unfortunately, supporting windows builds has not been in our roadmap, but if you would like to try it out, we would appreciate any contributions.

0
Cyril On

As @vonc explained, the build errors are caused by containerd v1.4.11 module. It was intentionally set to 1.4.11 in go.mod file with the following comments:

// TODO(ryantking): investigate further, v1.5 breaks github.com/deislabs/oras, might be able to update whatever uses the old version of oras

After changing containerd version to 1.7.6 in go.mod file, operator sdk can be build successfully. All the unit tests can be passed without any issue.

github.com/containerd/containerd => github.com/containerd/containerd v1.7.6

There is another warning regarding "sqlite3-binding.c" in building which can be resolved with

go env -w CGO_CFLAGS="-g -O2 -Wno-return-local-addr"

Note: Operator SDK on Windows is not officially supported. While it can be built and run on Windows, there are potential risks of encountering issues and limited support available