错误呈现
image.png
image.png

我们在通过gitlab-ci helm方式部署到k8s容器中时,有时可能觉得这个版本不是我想要的,就要中断发布【当然这里虽然中断了,但是代码其实已经部署到k8s 容器中】,这个时候带来的后果就是上图所示,第三步deploy 的时候,不管重试多少次都会有下面的错误,下次再次提交代码的时候,都不能成功发版,。

错误日志

$ helm upgrade —install \ # collapsed multi-line command 41 history.go:53: [debug] getting history for release course-arrangement 42 upgrade.go:121: [debug] preparing upgrade for course-arrangement 43 Error: UPGRADE FAILED: another operation (install/upgrade/rollback) is in progress 44 helm.go:81: [debug] another operation (install/upgrade/rollback) is in progress 45 helm.sh/helm/v3/pkg/action.init

46 /home/circleci/helm.sh/helm/pkg/action/action.go:62

47 runtime.doInit

48 /usr/local/go/src/runtime/proc.go:5453

49 runtime.doInit

50 /usr/local/go/src/runtime/proc.go:5448

51 runtime.main

52 /usr/local/go/src/runtime/proc.go:190

53 runtime.goexit

54 /usr/local/go/src/runtime/asm_amd64.s:1373

55 UPGRADE FAILED

56 main.newUpgradeCmd.func2

57 /home/circleci/helm.sh/helm/cmd/helm/upgrade.go:156

58 github.com/spf13/cobra.(*Command).execute

59 /go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:842

60 github.com/spf13/cobra.(*Command).ExecuteC

61 /go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950

62 github.com/spf13/cobra.(*Command).Execute

63 /go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887

64 main.main

65 /home/circleci/helm.sh/helm/cmd/helm/helm.go:80

66 runtime.main

67 /usr/local/go/src/runtime/proc.go:203

68 runtime.goexit

69 /usr/local/go/src/runtime/asm_amd64.s:1373

71 ERROR: Job failed: command terminated with exit code 1

解决方案
**

进入k8s控制台,使用helm rollback 回滚当前服务到历史版本,然后再次通过gitlab 发布即可

查询服务部署历史版本

helm history 服务名 -n namespace

回滚服务到当前版本到上一个版本

helm rollback 服务名 -n namespace