Skip to content

Commit

Permalink
init add healthcheck in tkestack
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeGuo2018 committed Jul 9, 2024
1 parent b291335 commit 17af153
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
49 changes: 49 additions & 0 deletions pkg/application/controller/app/action/healtchcheck.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Tencent is pleased to support the open source community by making TKEStack
* available.
*
* Copyright (C) 2012-2019 Tencent. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at
*
* https://opensource.org/licenses/Apache-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package action

import (
"context"
"fmt"

applicationv1 "tkestack.io/tke/api/application/v1"
applicationversionedclient "tkestack.io/tke/api/client/clientset/versioned/typed/application/v1"
platformversionedclient "tkestack.io/tke/api/client/clientset/versioned/typed/platform/v1"
appconfig "tkestack.io/tke/pkg/application/config"
"tkestack.io/tke/pkg/util/log"
)

// Install installs a chart archive
func HealthCheck(ctx context.Context,
applicationClient applicationversionedclient.ApplicationV1Interface,
platformClient platformversionedclient.PlatformV1Interface,
app *applicationv1.App,
repo appconfig.RepoConfiguration) (*applicationv1.App, error) {
hooks := getHooks(app)

err := hooks.HealthCheck(ctx, applicationClient, platformClient, app, repo)
if err != nil {
log.Errorf(fmt.Sprintf("ERROR: healthcheck cluster %s app %s failed with err :%s", app.Spec.TargetCluster, app.Name, err))
return nil, err
}

//updateStatusFunc
return app, nil
}

3 changes: 2 additions & 1 deletion pkg/application/controller/app/app_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ func (c *Controller) handlePhase(ctx context.Context, key string, cachedApp *cac
case applicationv1.AppPhaseSucceeded:
c.startAppHealthCheck(ctx, key)
// sync release status
return c.syncAppFromRelease(ctx, cachedApp, app)
c.syncAppFromRelease(ctx, cachedApp, app)
return action.HealthCheck(ctx, c.client.ApplicationV1(), c.platformClient, app, c.repo)
case applicationv1.AppPhaseUpgradFailed:
return action.Upgrade(ctx, c.client.ApplicationV1(), c.platformClient, app, c.repo, c.updateStatus)
case applicationv1.AppPhaseRollingBack:
Expand Down

0 comments on commit 17af153

Please sign in to comment.