kubernetes 无法在win10上安装operator_sdk:“无法使用syscall.NsecToFiletime”

uxhixvfz  于 2023-10-17  发布在  Kubernetes
关注(0)|答案(1)|浏览(81)

我尝试按照“Operator SDK"官方文档页面的说明操作。我尝试安装它的设备运行在Windows 10,AMD 64上。我通过Chocolatey安装了GNU Make。

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.

根据官方文档的“从master命令和安装”部分:

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

最后一行“make install”失败:

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

出现此错误的原因可能是什么?

r7knjye2

r7knjye21#

我看到有几行Go在抱怨类型不匹配。具体地说,要提到的是,syscall.Filetime不能用作"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

在需要"golang.org/x/sys/windows".Filetime类型的值的情况下使用了syscall.Filetime类型的值。这是一个类型不匹配的问题。github.com/containerd/containerd包中的文件tar_windows.go似乎是这些错误的来源,它似乎与Windows上如何处理文件时间戳有关。
containerd/containerd v1.4.11看起来很老,考虑到operator-framework/operator-sdk项目本身需要containerd v1.7.0
由于我通过make install得到了相同的错误,我首先尝试了go build -a -v ...,它不会触发错误。Makefile在go install ./cmd/{operator-sdk,helm-operator}上失败

  • go install ./cmd/helm-operator工作。
  • go install ./cmd/operator-sdk出现错误

该错误已通过您的问题operator-framework/operator-sdk issue 6585得到确认
我们不正式支持或构建windows的二进制文件。但我们愿意接受任何捐助。
#6586的副本
Operator SDK不正式支持或构建Windows的二进制文件。
然而,在某些情况下,用户仍然可以在Windows机器上从master构建SDK二进制文件。这个错误似乎来自github.com\containerd\ [[email protected]](https://stackoverflow.com/cdn-cgi/l/email-protection)
看起来它可能有问题。此外,我们还将containerd显式固定到1.4.11:
operator-sdk/go.mod:

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

因为它的一个碰撞会破坏github.com/deislabs/oras。
我建议首先检查依赖项中的一个碰撞是否修复了这些问题,而不会破坏SDK中的其他任何内容。如果是这样,我们可以在master中合并它来修复它。不幸的是,我们的路线图中没有支持windows build,但是如果你想尝试一下,我们将非常感谢任何贡献。

相关问题