Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Helm type pipeline app status #6262

Merged
merged 23 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/appStore/InstalledAppRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/json"
"errors"
"fmt"
bean2 "github.com/devtron-labs/devtron/api/bean/AppView"
client "github.com/devtron-labs/devtron/api/helm-app/gRPC"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode"
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deploymentTypeChange"
Expand All @@ -35,7 +36,6 @@ import (
"strings"
"time"

bean2 "github.com/devtron-labs/devtron/api/bean"
"github.com/devtron-labs/devtron/api/restHandler/common"
"github.com/devtron-labs/devtron/client/argocdServer/application"
"github.com/devtron-labs/devtron/client/cron"
Expand Down
2 changes: 1 addition & 1 deletion api/bean/AppView.go → api/bean/AppView/AppView.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package bean
package AppView

import (
"encoding/json"
Expand Down
13 changes: 13 additions & 0 deletions api/helm-app/gRPC/applicationClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type HelmAppClient interface {
GetAppDetail(ctx context.Context, in *AppDetailRequest) (*AppDetail, error)
GetResourceTreeForExternalResources(ctx context.Context, in *ExternalResourceTreeRequest) (*ResourceTreeResponse, error)
GetAppStatus(ctx context.Context, in *AppDetailRequest) (*AppStatus, error)
GetAppStatusV2(ctx context.Context, in *AppDetailRequest) (*AppStatus, error)
Hibernate(ctx context.Context, in *HibernateRequest) (*HibernateResponse, error)
UnHibernate(ctx context.Context, in *HibernateRequest) (*HibernateResponse, error)
GetDeploymentHistory(ctx context.Context, in *AppDetailRequest) (*HelmAppDeploymentHistory, error)
Expand Down Expand Up @@ -164,6 +165,18 @@ func (impl *HelmAppClientImpl) GetAppStatus(ctx context.Context, in *AppDetailRe
return appStatus, nil
}

func (impl *HelmAppClientImpl) GetAppStatusV2(ctx context.Context, in *AppDetailRequest) (*AppStatus, error) {
applicationClient, err := impl.getApplicationClient()
if err != nil {
return nil, err
}
appStatus, err := applicationClient.GetAppStatusV2(ctx, in)
if err != nil {
return nil, err
}
return appStatus, nil
}

func (impl *HelmAppClientImpl) Hibernate(ctx context.Context, in *HibernateRequest) (*HibernateResponse, error) {
applicationClient, err := impl.getApplicationClient()
if err != nil {
Expand Down
293 changes: 149 additions & 144 deletions api/helm-app/gRPC/applist.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api/helm-app/gRPC/applist.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ service ApplicationService {
rpc ListFluxApplications(AppListRequest) returns (stream FluxApplicationList){}
rpc GetAppDetail(AppDetailRequest) returns (AppDetail){}
rpc GetAppStatus(AppDetailRequest) returns (AppStatus){}
rpc GetAppStatusV2(AppDetailRequest) returns (AppStatus){}
rpc Hibernate(HibernateRequest) returns (HibernateResponse){}
rpc UnHibernate(HibernateRequest) returns (HibernateResponse){}
rpc GetDeploymentHistory(AppDetailRequest) returns (HelmAppDeploymentHistory){}
Expand Down
36 changes: 36 additions & 0 deletions api/helm-app/gRPC/applist_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 22 additions & 9 deletions api/helm-app/service/HelmAppService.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ type HelmAppService interface {
GetRevisionHistoryMaxValue(appType bean.SourceAppType) int32
GetResourceTreeForExternalResources(ctx context.Context, clusterId int, clusterConfig *gRPC.ClusterConfig, resources []*gRPC.ExternalResourceDetail) (*gRPC.ResourceTreeResponse, error)
CheckIfNsExistsForClusterIds(clusterIdToNsMap map[int]string) error

GetAppStatusV2(ctx context.Context, req *gRPC.AppDetailRequest, clusterId int) (*gRPC.AppStatus, error)
}

type HelmAppServiceImpl struct {
Expand Down Expand Up @@ -175,7 +177,7 @@ func (impl *HelmAppServiceImpl) ListHelmApplications(ctx context.Context, cluste
http.StatusInternalServerError)
return
}

// get helm apps which are created using cd_pipelines
newCtx, span := otel.Tracer("pipelineRepository").Start(ctx, "GetAppAndEnvDetailsForDeploymentAppTypePipeline")
start = time.Now()
Expand Down Expand Up @@ -244,18 +246,18 @@ func (impl *HelmAppServiceImpl) UnHibernateApplication(ctx context.Context, app
}

func (impl *HelmAppServiceImpl) GetApplicationDetail(ctx context.Context, app *helmBean.AppIdentifier) (*gRPC.AppDetail, error) {
return impl.getApplicationDetail(ctx, app, nil)
return impl.getApplicationDetailWithInstallerStatus(ctx, app, nil)
}

func (impl *HelmAppServiceImpl) GetApplicationAndReleaseStatus(ctx context.Context, app *helmBean.AppIdentifier) (*gRPC.AppStatus, error) {
return impl.getApplicationAndReleaseStatus(ctx, app)
}

func (impl *HelmAppServiceImpl) GetApplicationDetailWithFilter(ctx context.Context, app *helmBean.AppIdentifier, resourceTreeFilter *gRPC.ResourceTreeFilter) (*gRPC.AppDetail, error) {
return impl.getApplicationDetail(ctx, app, resourceTreeFilter)
return impl.getApplicationDetailWithInstallerStatus(ctx, app, resourceTreeFilter)
}

func (impl *HelmAppServiceImpl) getApplicationDetail(ctx context.Context, app *helmBean.AppIdentifier, resourceTreeFilter *gRPC.ResourceTreeFilter) (*gRPC.AppDetail, error) {
func (impl *HelmAppServiceImpl) getApplicationDetailWithInstallerStatus(ctx context.Context, app *helmBean.AppIdentifier, resourceTreeFilter *gRPC.ResourceTreeFilter) (*gRPC.AppDetail, error) {
config, err := impl.helmAppReadService.GetClusterConf(app.ClusterId)
if err != nil {
impl.logger.Errorw("error in fetching cluster detail", "err", err)
Expand All @@ -267,7 +269,7 @@ func (impl *HelmAppServiceImpl) getApplicationDetail(ctx context.Context, app *h
ReleaseName: app.ReleaseName,
ResourceTreeFilter: resourceTreeFilter,
}
appdetail, err := impl.helmAppClient.GetAppDetail(ctx, req)
appDetail, err := impl.getAppDetail(ctx, req)
if err != nil {
impl.logger.Errorw("error in fetching app detail", "err", err)
return nil, err
Expand All @@ -281,14 +283,24 @@ func (impl *HelmAppServiceImpl) getApplicationDetail(ctx context.Context, app *h
impl.serverDataStore.InstallerCrdObjectExists {
if impl.serverDataStore.InstallerCrdObjectStatus != serverBean.InstallerCrdObjectStatusApplied {
// if timeout
if time.Now().After(appdetail.GetLastDeployed().AsTime().Add(1 * time.Hour)) {
appdetail.ApplicationStatus = serverBean.AppHealthStatusDegraded
if time.Now().After(appDetail.GetLastDeployed().AsTime().Add(1 * time.Hour)) {
appDetail.ApplicationStatus = serverBean.AppHealthStatusDegraded
} else {
appdetail.ApplicationStatus = serverBean.AppHealthStatusProgressing
appDetail.ApplicationStatus = serverBean.AppHealthStatusProgressing
}
}
}
return appdetail, err
return appDetail, err
}

func (impl *HelmAppServiceImpl) getAppDetail(ctx context.Context, req *gRPC.AppDetailRequest) (*gRPC.AppDetail, error) {
impl.updateAppDetailRequestWithCacheConfig(req)
appDetail, err := impl.helmAppClient.GetAppDetail(ctx, req)
if err != nil {
impl.logger.Errorw("error in fetching app detail", "payload", req, "err", err)
return nil, err
}
return appDetail, nil
}

func (impl *HelmAppServiceImpl) GetResourceTreeForExternalResources(ctx context.Context, clusterId int,
Expand All @@ -308,6 +320,7 @@ func (impl *HelmAppServiceImpl) GetResourceTreeForExternalResources(ctx context.
ClusterConfig: config,
ExternalResourceDetail: resources,
}
impl.updateExternalResTreeRequestWithCacheConfig(clusterId, req)
return impl.helmAppClient.GetResourceTreeForExternalResources(ctx, req)
}

Expand Down
18 changes: 18 additions & 0 deletions api/helm-app/service/HelmAppService_ent.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package service

import (
"context"
"github.com/devtron-labs/devtron/api/helm-app/gRPC"
)

func (impl *HelmAppServiceImpl) GetAppStatusV2(ctx context.Context, req *gRPC.AppDetailRequest, clusterId int) (*gRPC.AppStatus, error) {
return nil, nil
}

func (impl *HelmAppServiceImpl) updateAppDetailRequestWithCacheConfig(req *gRPC.AppDetailRequest) {
return
}

func (impl *HelmAppServiceImpl) updateExternalResTreeRequestWithCacheConfig(clusterId int, req *gRPC.ExternalResourceTreeRequest) {
return
}
8 changes: 4 additions & 4 deletions api/k8s/application/k8sApplicationRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
util3 "github.com/devtron-labs/common-lib/utils/k8s"
k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean"
"github.com/devtron-labs/common-lib/utils/k8sObjectsUtil"
"github.com/devtron-labs/devtron/api/bean"
"github.com/devtron-labs/devtron/api/bean/AppView"
"github.com/devtron-labs/devtron/api/connector"
"github.com/devtron-labs/devtron/api/helm-app/gRPC"
client "github.com/devtron-labs/devtron/api/helm-app/service"
Expand Down Expand Up @@ -253,7 +253,7 @@ func (handler *K8sApplicationRestHandlerImpl) GetHostUrlsByBatch(w http.Response
}

token := r.Header.Get("token")
var k8sAppDetail bean.AppDetailContainer
var k8sAppDetail AppView.AppDetailContainer
var resourceTreeResponse *gRPC.ResourceTreeResponse
var clusterId int
var namespace string
Expand Down Expand Up @@ -344,8 +344,8 @@ func (handler *K8sApplicationRestHandlerImpl) GetHostUrlsByBatch(w http.Response
resourceTreeResponse = appDetail.ResourceTreeResponse
}

k8sAppDetail = bean.AppDetailContainer{
DeploymentDetailContainer: bean.DeploymentDetailContainer{
k8sAppDetail = AppView.AppDetailContainer{
DeploymentDetailContainer: AppView.DeploymentDetailContainer{
ClusterId: clusterId,
Namespace: namespace,
},
Expand Down
Loading
Loading