k8s升级导致hostPath type check failed
一、问题背景
- 当前Cluster K8s Version: v1.17.4
- 需要升级到K8s Version:v1.19.3
- 在升级过程中,有个Pod卡在ContainerCreating状态
api-9flnb 0/1 ContainerCreating 0 4d19h
api-bb8th 1/1 Running 0 4d20h
api-zwtpp 1/1 Running 0 4d20h
二、问题分析
- Describe该Pod状态,提示hostPath type check failed: /var/run/docker.sock is not a file
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedMount 11m (x3543 over 4d18h) kubelet (combined from similar events): Unable to attach or mount volumes: unmounted volumes=[docker-socket], unattached volumes=[xxxx-service-account-token-rjqz7 nginx-certs host-timezone docker-socket helm-home etc-pki kubernetes-root-ca-file root-ca-file bcmt-home etcd-client-certs]: timed out waiting for the condition
Warning FailedMount 2m39s (x2889 over 4d19h) kubelet MountVolume.SetUp failed for volume "docker-socket" : hostPath type check failed: /var/run/docker.sock is not a file - 查看该Pod中volume "docker-socket"的声明,Path是/var/run/docker.sock,HostPathType是File
Volumes:
etcd-client-certs:
Type: Secret (a volume populated by a Secret)
SecretName: etcd-client-certs
Optional: false
nginx-certs:
Type: HostPath (bare host directory volume)
Path: /opt/bcmt/config/bcmt-api/certs
HostPathType: Directory
docker-socket:
Type: HostPath (bare host directory volume)
Path: /var/run/docker.sock
HostPathType: File - 查看K8s从v1.17.4到v1.19.3关于Type检测方面的相关代码变化
首先,报错的代码函数是checkTypeInternal(),在文件host_path.go定义,会判断HostPathType和实际Type是否一致,否则报错。
func checkTypeInternal(ftc hostPathTypeChecker, pathType *v1.HostPathType) error {
switch *pathType {
case v1.HostPathDirectoryOrCreate:
if !ftc.Exists() {
return ftc.MakeDir()
}
fallthrough
case v1.HostPathDirectory:
if !ftc.IsDir() {
return fmt.Errorf("hostPath type check failed: %s is not a directory", ftc.GetPath())
}
case v1.HostPathFileOrCreate:
if !ftc.Exists() {
return ftc.MakeFile()
}
fallthrough
case v1.HostPathFile:
if !ftc.IsFile() {
return fmt.Errorf("hostPath type check failed: %s is not a file", ftc.GetPath())
}
case v1.HostPathSocket:
if !ftc.IsSocket() {
return fmt.Errorf("hostPath type check failed: %s is not a socket file", ftc.GetPath())
}
case v1.HostPathCharDev:
if !ftc.IsChar() {
return fmt.Errorf("hostPath type check failed: %s is not a character device", ftc.GetPath())
}
case v1.HostPathBlockDev:
if !ftc.IsBlock() {
return fmt.Errorf("hostPath type check failed: %s is not a block device", ftc.GetPath())
}
default:
return fmt.Errorf("%s is an invalid volume type", *pathType)
}
return nil
}
然后,结合我们pod的定义,HostPathType是File,但是实际Path文件/var/run/docker.sock应该是Socket,所以报错是正确的。疑问在于,为什么v1.17.4没有报错(亲测v1.18.x也不会报错),而到了v1.19.3才开始报错???
- 检查checkTypeInternal函数代码有无改动,---> 结果是无改动
- 检查入参hostPathTypeChecker传值是否有改动, --->发现有改动
- v1.17.x和v1.18.x中,IsFile()定义如下
func (ftc *fileTypeChecker) IsFile() bool {
if !ftc.Exists() {
return false
}
return !ftc.IsDir()
}- v1.19.x开始,IsFile()更新如下
func (ftc *fileTypeChecker) IsFile() bool {
if !ftc.Exists() {
return false
}
pathType, err := ftc.hu.GetFileType(ftc.path)
if err != nil {
return false
}
return string(pathType) == string(v1.HostPathFile)
}
三、问题结论
- K8s从v1.19.x修复了IsFile()函数检测功能不完备的Bug;
- 我们的Pod Mount Volume 文件.sock时指定HostPathType错误(应该是Socket, 不应该是File),但是在v1.19.x之前因为k8s的bug正好将错就错反而没有问题,等v1.19.x修复了该Bug就会出现Volume Mount失败的问题
四、解决方案:.sock文件的HostPathType要设置成Socket
Volumes:
docker-socket:
Type: HostPath (bare host directory volume)
Path: /var/run/docker.sock
HostPathType: Socket
k8s升级导致hostPath type check failed的更多相关文章
- Vue报错之"[Vue warn]: Invalid prop: type check failed for prop "jingzinum". Expected Number with value NaN, got String with value "fuNum"."
一.报错截图 [Vue warn]: Invalid prop: type check failed for prop "jingzinum". Expected Number w ...
- Invalid prop: type check failed for prop "XXX". Expected String, got Object.
项目是Vue的,基于elementUI的后台管理系统. Invalid prop: type check failed for prop "total". Expected Str ...
- vue调用组件,组件回调给data中的数组赋值,报错Invalid prop type check failed for prop value. Expecte
报错信息: 代码信息:调用一个tree组件,选择一些信息 <componentsTree ref="typeTreeComponent" @treeCheck="t ...
- vue type check failed for prop . Expected Number, got String
代码是:fileNumLimit接收的类型是Number <vue-upload fileNumLimit='100'/> 改为 <vue-upload :fileNumLimit= ...
- Invalid prop: type check failed for prop "maxlength". Expected Number, got String.
1.项目中,使用element-ui的input表单的maxlength属性报错 2.使用场景: <el-input v-model="fname" maxle ...
- vue.esm.js?efeb:628 [Vue warn]: Invalid prop: type check failed for prop "defaultActive". Expected String with value "0", got Number with value 0.
vue.esm.js?efeb:628 [Vue warn]: Invalid prop: type check failed for prop "defaultActive". ...
- Vue报错 type check failed for prop “xxx“. Expected String with value “xx“,got Number with value ‘xx‘
vue报错 [Vue warn]: Invalid prop: type check failed for prop "name". Expected String with ...
- Invalid prop: type check failed for prop "maxlength"
Invalid prop: type check failed for prop "maxlength", element 框架时,因为想限制文本框的输入长度, maxlength ...
- [Vue warn]: Invalid prop: type check failed for prop "model". Expected Object, got String with value ""
问题描述: [Vue warn]: Invalid prop: type check failed for prop "model". Expected Object, got S ...
- [VUE ERROR] Invalid prop: type check failed for prop "list". Expected Array, got Undefined
错误原因: 子组件 props -> list 要求接收的数据类型是 Array, 然而实际接收到的是 Undefined. 子组件代码: props: { list: { type: Arra ...
随机推荐
- Shiro-721反序列化漏洞
漏洞名称 Shiro-721(Apache Shiro Padding Oracle Attack)反序列化 利用条件 Apache Shiro < 1.4.2 漏洞原理 Apache Shir ...
- Linux C 用GPS时间更新系统时间的方法。
思路: 1.GPS模块会自动收到带时间信息的消息. GPS模块会收到很多的协议消息带时间信息的.我们选择"$GPRMC"这条协议.其中的时间格式有的是hhmmss(时分秒) 有的是 ...
- C# 10 Lambda 语法的改进
C# 10 包括了对 Lambda 表达式的处理方式的许多改进: Lambda 表达式可以具有自然类型,这使编译器可从 Lambda 表达式或方法组推断委托类型. 如果编译器无法推断返回类型,Lamb ...
- Object类的toString方法-Object类的equas方法
Object类的toString方法 Object 是类层次结构的根(最顶层)类.每个类都是用 Object 作为超(父)类. 所有对象(包括数组) 都实现这个类的方法 Person类默认继承了Obj ...
- RabbitMQ消息队列入门及解决常见问题
RabbitMQ消息队列 同步通讯和异步通讯 微服务间通讯有同步和异步两种方式: 同步通讯:就像打电话,需要实时响应. 异步通讯:就像发邮件,不需要马上回复. 两种方式各有优劣,打电话可以立即得到响应 ...
- 互斥锁、线程理论、GIL全局解释器、信号量、event事件、进程池和线程池以及协程
目录 一.互斥锁代码实操 1.互斥锁的概念 2.互斥锁的使用 3.死锁现象 4. 小结 二.线程理论 进程 线程 线程简介 为什么要使用多线程? 多线程概念 多进程的优点: 线程与进程的区别 线程的特 ...
- Syntax Error: Error: Cannot find module ‘node-sass‘
出现问题原因: vscode运行前端项目输入npm run dev命令触发此错误 解决办法: 指定淘宝镜像安装node-sass win+r 打开cmd控制台输入 npm install -g cnp ...
- 用ChatGPT,快速设计一个真实的账号系统
hi,我是熵减,见字如面. 用ChatGPT,可以尝试做很多的事情. 今天我们就来让ChatGPT做为架构师,来帮我们设计一个账号系统吧. 我的实验过程记录如下,与你分享. 用户故事 首先,我们从用户 ...
- Eureka高可用集群服务端和客户端配置
微服务应用中,生产环境一般都需要保障服务注册中心的高可用!高可用也分好几个等级,例如:同数据中心(可用Zone区)高可用-->同地域(Region)跨数据中心(可用Zone区)高可用--> ...
- select省市联动+对应经销商、自定义箭头
HTML: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <met ...