Skip to content

feat: deployment config migration #5368

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

Merged
merged 50 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
8083da3
inital commit - deployment config service
iamayushm Jun 26, 2024
08152bf
wip: migration changes for devtron apps
iamayushm Jun 27, 2024
689c0e8
changes for helm apps
iamayushm Jun 30, 2024
852de8f
dev testing fixes
iamayushm Jul 1, 2024
2e39d03
wire fix
iamayushm Jul 1, 2024
096ba04
bulk get function
iamayushm Jul 1, 2024
7b601eb
wip: bulk logic fixes
iamayushm Jul 2, 2024
847da98
wip: bulk fixes
iamayushm Jul 2, 2024
ad3951c
Merge branch 'main' into deployment-config-migration
kartik-579 Jul 2, 2024
81cd551
feat: Cd pipeline migration sql and query usage update (#5416)
kartik-579 Jul 2, 2024
6c74b69
dev testing fixes
iamayushm Jul 2, 2024
e4a7f16
Merge remote-tracking branch 'origin/deployment-config-migration' int…
iamayushm Jul 2, 2024
63cebe7
QUERY : UPDATED buildAppListingWhereCondition and FIXED deploymentDet…
iamayushm Jul 2, 2024
ffc626f
function for bulk update config
iamayushm Jul 2, 2024
f4d16b9
query changes
iamayushm Jul 3, 2024
b01aa80
remaining query changes
iamayushm Jul 3, 2024
a3335bc
PR review changes and logical fixes
iamayushm Jul 4, 2024
d194d10
nil pointer fix
iamayushm Jul 4, 2024
ff5ea7b
fix cd pipeline helm app create
iamayushm Jul 4, 2024
27b1743
dev testing fixes
iamayushm Jul 5, 2024
b0d4505
updating app stages status check
iamayushm Jul 5, 2024
a8d9228
query active check for deployment config
iamayushm Jul 5, 2024
f7463ae
wip
iamayushm Jul 5, 2024
cde0561
wip: migration fix and main merge
iamayushm Jul 7, 2024
f917146
adding flag for migration and removing bulk code
iamayushm Jul 8, 2024
7900766
Merge remote-tracking branch 'origin/main' into deployment-config-mig…
iamayushm Jul 8, 2024
0b95295
build fix
iamayushm Jul 8, 2024
75d75c5
wip: modifying get function
iamayushm Jul 9, 2024
5c913e6
handling custom gitops case for app clone
iamayushm Jul 9, 2024
0d35486
handling app clone with custom gitops for system generated url
iamayushm Jul 9, 2024
f2a311e
fix: wrong call for helm app deployment app type change
iamayushm Jul 9, 2024
27b60f7
fix migration function for helm app
iamayushm Jul 9, 2024
4c7aefc
wip: updating dc on template update
iamayushm Jul 9, 2024
e62aef1
fix: replacing migrate with get call
iamayushm Jul 9, 2024
b7d0087
fix: wrong call for helm app
iamayushm Jul 9, 2024
e72b79b
minor fixes
iamayushm Jul 9, 2024
4d94230
renaming chart path
iamayushm Jul 9, 2024
e3be2ef
updating deprecated columns
iamayushm Jul 9, 2024
9ad5acb
updating dc.active
iamayushm Jul 9, 2024
3673aac
updating dc.active
iamayushm Jul 9, 2024
641cb35
fix redirection
iamayushm Jul 10, 2024
7b485a0
removing chart path
iamayushm Jul 11, 2024
8a2614a
updating migration
iamayushm Jul 11, 2024
db939dc
conditions in patch object
iamayushm Jul 11, 2024
efbaa75
fix error in flag off-> custom-gitops-> app-clone-> deploy-> flag-on-…
iamayushm Jul 12, 2024
4429da2
wire fix
kartik-579 Jul 12, 2024
18ebdc0
audit log fix
iamayushm Jul 15, 2024
cd12377
migation update
iamayushm Jul 15, 2024
6b7842e
Merge remote-tracking branch 'origin/main' into deployment-config-mig…
iamayushm Jul 15, 2024
ec17f09
reverted 107 sql newline add
kartik-579 Jul 15, 2024
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
18 changes: 13 additions & 5 deletions Wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import (
appWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow"
"github.com/devtron-labs/devtron/internal/sql/repository/bulkUpdate"
"github.com/devtron-labs/devtron/internal/sql/repository/chartConfig"
"github.com/devtron-labs/devtron/internal/sql/repository/deploymentConfig"
dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry"
"github.com/devtron-labs/devtron/internal/sql/repository/helper"
repository8 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging"
Expand Down Expand Up @@ -122,6 +123,7 @@ import (
"github.com/devtron-labs/devtron/pkg/commonService"
delete2 "github.com/devtron-labs/devtron/pkg/delete"
deployment2 "github.com/devtron-labs/devtron/pkg/deployment"
"github.com/devtron-labs/devtron/pkg/deployment/common"
git2 "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git"
"github.com/devtron-labs/devtron/pkg/deployment/manifest/publish"
"github.com/devtron-labs/devtron/pkg/deploymentGroup"
Expand Down Expand Up @@ -207,13 +209,13 @@ func InitializeApp() (*App, error) {
wire.Bind(new(gitSensor.Client), new(*gitSensor.ClientImpl)),
// -------
helper.NewAppListingRepositoryQueryBuilder,
// sql.GetConfig,
// sql.GetConfigForDevtronApps,
eClient.GetEventClientConfig,
// sql.NewDbConnection,
// app.GetACDAuthConfig,
util3.GetACDAuthConfig,
connection.SettingsManager,
// auth.GetConfig,
// auth.GetConfigForDevtronApps,

connection.GetConfig,
wire.Bind(new(session2.ServiceClient), new(*middleware.LoginService)),
Expand Down Expand Up @@ -434,7 +436,7 @@ func InitializeApp() (*App, error) {
wire.Bind(new(repository2.ServiceClient), new(*repository2.ServiceClientImpl)),
wire.Bind(new(connector.Pump), new(*connector.PumpImpl)),

//app.GetConfig,
//app.GetConfigForDevtronApps,

pipeline.GetEcrConfig,
// otel.NewOtelTracingServiceImpl,
Expand Down Expand Up @@ -877,8 +879,8 @@ func InitializeApp() (*App, error) {
wire.Bind(new(repository.UserAttributesRepository), new(*repository.UserAttributesRepositoryImpl)),
pipelineConfig.NewPipelineStatusTimelineRepositoryImpl,
wire.Bind(new(pipelineConfig.PipelineStatusTimelineRepository), new(*pipelineConfig.PipelineStatusTimelineRepositoryImpl)),
wire.Bind(new(pipeline.DeploymentConfigService), new(*pipeline.DeploymentConfigServiceImpl)),
pipeline.NewDeploymentConfigServiceImpl,
wire.Bind(new(pipeline.PipelineDeploymentConfigService), new(*pipeline.PipelineDeploymentConfigServiceImpl)),
pipeline.NewPipelineDeploymentConfigServiceImpl,
pipelineConfig.NewCiTemplateOverrideRepositoryImpl,
wire.Bind(new(pipelineConfig.CiTemplateOverrideRepository), new(*pipelineConfig.CiTemplateOverrideRepositoryImpl)),
pipelineConfig.NewCiBuildConfigRepositoryImpl,
Expand Down Expand Up @@ -975,6 +977,12 @@ func InitializeApp() (*App, error) {

cel.NewCELServiceImpl,
wire.Bind(new(cel.EvaluatorService), new(*cel.EvaluatorServiceImpl)),

deploymentConfig.NewRepositoryImpl,
wire.Bind(new(deploymentConfig.Repository), new(*deploymentConfig.RepositoryImpl)),

common.NewDeploymentConfigServiceImpl,
wire.Bind(new(common.DeploymentConfigService), new(*common.DeploymentConfigServiceImpl)),
)
return &App{}, nil
}
15 changes: 8 additions & 7 deletions api/appStore/InstalledAppRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/resource"
util3 "github.com/devtron-labs/devtron/pkg/appStore/util"
"github.com/devtron-labs/devtron/pkg/bean"
"gopkg.in/go-playground/validator.v9"
"net/http"
"reflect"
"strconv"
Expand All @@ -48,14 +49,14 @@ import (
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
"github.com/devtron-labs/devtron/pkg/auth/user"
"github.com/devtron-labs/devtron/pkg/cluster"
bean3 "github.com/devtron-labs/devtron/pkg/deployment/common/bean"
"github.com/devtron-labs/devtron/util"
"github.com/devtron-labs/devtron/util/argo"
"github.com/devtron-labs/devtron/util/rbac"
"github.com/devtron-labs/devtron/util/response"
"github.com/go-pg/pg"
"github.com/gorilla/mux"
"go.uber.org/zap"
"gopkg.in/go-playground/validator.v9"
)

type InstalledAppRestHandler interface {
Expand Down Expand Up @@ -744,8 +745,8 @@ func (handler *InstalledAppRestHandlerImpl) FetchAppDetailsForInstalledApp(w htt
resourceTreeAndNotesContainer.ResourceTree = map[string]interface{}{}

if len(installedApp.App.AppName) > 0 && len(installedApp.Environment.Name) > 0 {
err = handler.fetchResourceTree(w, r, &resourceTreeAndNotesContainer, *installedApp, "", "")
if installedApp.DeploymentAppType == util2.PIPELINE_DEPLOYMENT_TYPE_ACD {
err = handler.fetchResourceTree(w, r, &resourceTreeAndNotesContainer, *installedApp, appDetail.DeploymentConfig, "", "")
if appDetail.DeploymentAppType == util2.PIPELINE_DEPLOYMENT_TYPE_ACD {
apiError, ok := err.(*util2.ApiError)
if ok && apiError != nil {
if apiError.Code == constants.AppDetailResourceTreeNotFound && installedApp.DeploymentAppDeleteRequest == true {
Expand Down Expand Up @@ -868,8 +869,8 @@ func (handler *InstalledAppRestHandlerImpl) FetchResourceTree(w http.ResponseWri
resourceTreeAndNotesContainer.ResourceTree = map[string]interface{}{}

if len(installedApp.App.AppName) > 0 && len(installedApp.Environment.Name) > 0 {
err = handler.fetchResourceTree(w, r, &resourceTreeAndNotesContainer, *installedApp, appDetail.HelmReleaseInstallStatus, appDetail.Status)
if installedApp.DeploymentAppType == util2.PIPELINE_DEPLOYMENT_TYPE_ACD {
err = handler.fetchResourceTree(w, r, &resourceTreeAndNotesContainer, *installedApp, appDetail.DeploymentConfig, appDetail.HelmReleaseInstallStatus, appDetail.Status)
if appDetail.DeploymentAppType == util2.PIPELINE_DEPLOYMENT_TYPE_ACD {
//resource tree has been fetched now prepare to sync application deployment status with this resource tree call
handler.syncDeploymentStatusWithResourceTreeCall(appDetail)
apiError, ok := err.(*util2.ApiError)
Expand Down Expand Up @@ -960,10 +961,10 @@ func (handler *InstalledAppRestHandlerImpl) FetchResourceTreeForACDApp(w http.Re
common.WriteJsonResp(w, err, appDetail, http.StatusOK)
}

func (handler *InstalledAppRestHandlerImpl) fetchResourceTree(w http.ResponseWriter, r *http.Request, resourceTreeAndNotesContainer *bean2.AppDetailsContainer, installedApp repository.InstalledApps, helmReleaseInstallStatus string, status string) error {
func (handler *InstalledAppRestHandlerImpl) fetchResourceTree(w http.ResponseWriter, r *http.Request, resourceTreeAndNotesContainer *bean2.AppDetailsContainer, installedApp repository.InstalledApps, deploymentConfig *bean3.DeploymentConfig, helmReleaseInstallStatus string, status string) error {
ctx := r.Context()
cn, _ := w.(http.CloseNotifier)
err := handler.installedAppResourceService.FetchResourceTree(ctx, cn, resourceTreeAndNotesContainer, installedApp, helmReleaseInstallStatus, status)
err := handler.installedAppResourceService.FetchResourceTree(ctx, cn, resourceTreeAndNotesContainer, installedApp, deploymentConfig, helmReleaseInstallStatus, status)
return err
}

Expand Down
82 changes: 42 additions & 40 deletions api/bean/AppView.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package bean
import (
"encoding/json"
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/devtron-labs/devtron/pkg/deployment/common/bean"
"time"
)

Expand Down Expand Up @@ -141,46 +142,47 @@ type AppEnvironmentContainer struct {
}

type DeploymentDetailContainer struct {
InstalledAppId int `json:"installedAppId,omitempty"`
AppId int `json:"appId,omitempty"`
CdPipelineId int `json:"cdPipelineId,omitempty"`
TriggerType string `json:"triggerType,omitempty"`
ParentEnvironmentName string `json:"parentEnvironmentName"`
AppStoreInstalledAppVersionId int `json:"appStoreInstalledAppVersionId,omitempty"`
AppStoreChartName string `json:"appStoreChartName,omitempty"`
AppStoreChartId int `json:"appStoreChartId,omitempty"`
AppStoreAppName string `json:"appStoreAppName,omitempty"`
AppStoreAppVersion string `json:"appStoreAppVersion,omitempty"`
AppName string `json:"appName"`
EnvironmentId int `json:"environmentId"`
EnvironmentName string `json:"environmentName"`
Namespace string `json:"namespace,omitempty"`
Status string `json:"status,omitempty"`
StatusMessage string `json:"statusMessage,omitempty"`
LastDeployedTime string `json:"lastDeployedTime,omitempty"`
LastDeployedBy string `json:"lastDeployedBy,omitempty"`
MaterialInfo json.RawMessage `json:"materialInfo,omitempty"`
MaterialInfoJsonString string `json:"-"`
ReleaseVersion string `json:"releaseVersion,omitempty"`
Default bool `json:"default,omitempty"`
DataSource string `json:"dataSource,omitempty"`
LastDeployedPipeline string `json:"lastDeployedPipeline,omitempty"`
Deprecated bool `json:"deprecated"`
K8sVersion string `json:"k8sVersion"`
CiArtifactId int `json:"ciArtifactId"`
ParentArtifactId int `json:"parentArtifactId"`
ClusterId int `json:"clusterId"`
DeploymentAppType string `json:"deploymentAppType"`
CiPipelineId int `json:"ciPipelineId,omitempty"`
IsExternalCi bool `json:"externalCi"`
ClusterName string `json:"clusterName,omitempty"`
DockerRegistryId string `json:"dockerRegistryId,omitempty"`
IpsAccessProvided bool `json:"ipsAccessProvided"`
DeploymentAppDeleteRequest bool `json:"deploymentAppDeleteRequest"`
Description string `json:"description" validate:"max=40"`
IsVirtualEnvironment bool `json:"isVirtualEnvironment"`
HelmPackageName string `json:"helmPackageName"`
HelmReleaseInstallStatus string `json:"-"`
InstalledAppId int `json:"installedAppId,omitempty"`
AppId int `json:"appId,omitempty"`
CdPipelineId int `json:"cdPipelineId,omitempty"`
TriggerType string `json:"triggerType,omitempty"`
ParentEnvironmentName string `json:"parentEnvironmentName"`
AppStoreInstalledAppVersionId int `json:"appStoreInstalledAppVersionId,omitempty"`
AppStoreChartName string `json:"appStoreChartName,omitempty"`
AppStoreChartId int `json:"appStoreChartId,omitempty"`
AppStoreAppName string `json:"appStoreAppName,omitempty"`
AppStoreAppVersion string `json:"appStoreAppVersion,omitempty"`
AppName string `json:"appName"`
EnvironmentId int `json:"environmentId"`
EnvironmentName string `json:"environmentName"`
Namespace string `json:"namespace,omitempty"`
Status string `json:"status,omitempty"`
StatusMessage string `json:"statusMessage,omitempty"`
LastDeployedTime string `json:"lastDeployedTime,omitempty"`
LastDeployedBy string `json:"lastDeployedBy,omitempty"`
MaterialInfo json.RawMessage `json:"materialInfo,omitempty"`
MaterialInfoJsonString string `json:"-"`
ReleaseVersion string `json:"releaseVersion,omitempty"`
Default bool `json:"default,omitempty"`
DataSource string `json:"dataSource,omitempty"`
LastDeployedPipeline string `json:"lastDeployedPipeline,omitempty"`
Deprecated bool `json:"deprecated"`
K8sVersion string `json:"k8sVersion"`
CiArtifactId int `json:"ciArtifactId"`
ParentArtifactId int `json:"parentArtifactId"`
ClusterId int `json:"clusterId"`
DeploymentAppType string `json:"deploymentAppType"`
CiPipelineId int `json:"ciPipelineId,omitempty"`
IsExternalCi bool `json:"externalCi"`
ClusterName string `json:"clusterName,omitempty"`
DockerRegistryId string `json:"dockerRegistryId,omitempty"`
IpsAccessProvided bool `json:"ipsAccessProvided"`
DeploymentAppDeleteRequest bool `json:"deploymentAppDeleteRequest"`
Description string `json:"description" validate:"max=40"`
IsVirtualEnvironment bool `json:"isVirtualEnvironment"`
HelmPackageName string `json:"helmPackageName"`
HelmReleaseInstallStatus string `json:"-"`
DeploymentConfig *bean.DeploymentConfig `json:"-"`
}

type AppDetailContainer struct {
Expand Down
4 changes: 4 additions & 0 deletions api/bean/gitOps/GitOpsConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ const (
func IsGitOpsRepoNotConfigured(gitRepoUrl string) bool {
return len(gitRepoUrl) == 0 || gitRepoUrl == GIT_REPO_NOT_CONFIGURED
}

func IsGitOpsRepoConfigured(gitRepoUrl string) bool {
return len(gitRepoUrl) != 0 || gitRepoUrl != GIT_REPO_NOT_CONFIGURED
}
2 changes: 1 addition & 1 deletion api/helm-app/service/HelmAppService.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (impl *HelmAppServiceImpl) ListHelmApplications(ctx context.Context, cluste
impl.logger.Errorw("error in fetching helm app list from DB created using cd_pipelines", "clusters", clusterIds, "err", err)
}

// if not hyperion mode, then fetch from installed_apps whose deployment_app_type is helm (as in hyperion mode, these apps should be treated as external-apps)
// if not hyperion mode, then fetch from installed_apps whose deploymentAppType is helm (as in hyperion mode, these apps should be treated as external-apps)
if !util2.IsBaseStack() {
newCtx, span = otel.Tracer("pipelineRepository").Start(newCtx, "GetAppAndEnvDetailsForDeploymentAppTypePipeline")
start = time.Now()
Expand Down
Loading
Loading