代码拉取完成,页面将自动刷新
package upgrade
import (
"context"
"fmt"
"github.com/rancher/rancher/pkg/controllers/user/alert/deploy"
"github.com/rancher/rancher/pkg/controllers/user/systemimage"
rv1beta2 "github.com/rancher/types/apis/apps/v1beta2"
"github.com/rancher/types/config"
"k8s.io/api/apps/v1beta2"
apierrors "k8s.io/apimachinery/pkg/api/errors"
)
var (
serviceName = "alerting"
)
type alertService struct {
clusterName string
deployments rv1beta2.DeploymentInterface
}
func init() {
systemimage.RegisterSystemService(serviceName, &alertService{})
}
func (l *alertService) Init(ctx context.Context, cluster *config.UserContext) {
l.clusterName = cluster.ClusterName
l.deployments = cluster.Apps.Deployments("")
}
func (l *alertService) Version() (string, error) {
deployment := deploy.GetDeployment()
return systemimage.DefaultGetVersion(deployment)
}
func (l *alertService) Upgrade(currentVersion string) (string, error) {
deployment := deploy.GetDeployment()
newVersion, err := systemimage.DefaultGetVersion(deployment)
if err != nil {
return "", err
}
if currentVersion == newVersion {
return currentVersion, nil
}
if err := l.upgradeDeployment(deployment); err != nil {
return "", err
}
return newVersion, nil
}
func (l *alertService) upgradeDeployment(deployment *v1beta2.Deployment) error {
if _, err := l.deployments.Update(deployment); err != nil {
if apierrors.IsNotFound(err) {
return nil
}
return fmt.Errorf("upgrade system service %s:%s failed, %v", deployment.Namespace, deployment.Name, err)
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。