Skip to content

Commit ed40618

Browse files
fix: stack Manager issues (#6619)
* fix upgrade feedback issue * Refactor installer module path handling for configurability. Replaced hardcoded installer module paths with configurable environment variables in `ServerEnvConfig`. This improves flexibility and maintainability, allowing paths to be customized without altering the codebase. Removed redundant constant `INSTALLER_MODULES_HELM_KEY`. * Refactor module key generation to use basePath configuration. Updated functions to include `basePath` in module enable key generation, ensuring consistency and flexibility when constructing keys. Adjusted related calls across services to pass the `basePath` from environment configuration. * Update env_gen.json placeholder content Revised the content of env_gen.json to modify the placeholder or default configuration. This ensures alignment with the expected environment setup and eliminates any outdated references. * Refactor server status mapping logic for Helm applications Simplified and standardized the server status mapping by reinstating Helm release-based logic, removing redundant code, and eliminating the `mapApplicationStatusToServerStatus` function. This enhances maintainability and aligns with existing Helm release workflows. * installation sleep * Fix syntax error in installation script sleep function Replaced incorrect usage of `sleep(180);` with `sleep 180` to align with proper syntax. This ensures the installation script runs without errors during execution. * Fix syntax for sleep function in installation script Replaced incorrect usage of `sleep` with the proper function call `sleep(180)`. This ensures the script executes correctly without syntax errors. * Update installation script to replace sleep with shellScript Replaced the fixed sleep duration with repeated shellScript calls to improve the script's flexibility and manageability. This change aims to enhance the installation process by providing clearer execution control and better * Update installation script to replace sleep with shellScript Replaced the fixed sleep duration with repeated shellScript calls to improve the script's flexibility and manageability. This change aims to enhance the installation process by providing clearer
1 parent 80c7dd5 commit ed40618

File tree

10 files changed

+31
-17
lines changed

10 files changed

+31
-17
lines changed

cmd/external-app/wire_gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

env_gen.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

env_gen.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@
160160
| DEVTRON_HELM_REPO_NAME | string |devtron | Is used to install modules (stack manager) | | false |
161161
| DEVTRON_HELM_REPO_URL | string |https://helm.devtron.ai | Is used to install modules (stack manager) | | false |
162162
| DEVTRON_INSTALLATION_TYPE | string | | Devtron Installation type(EA/Full) | | false |
163+
| DEVTRON_INSTALLER_MODULES_PATH | string |installer.modules | Path to devtron installer modules, used to find the helm charts and values files | | false |
164+
| DEVTRON_INSTALLER_RELEASE_PATH | string |installer.release | Path to devtron installer release, used to find the helm charts and values files | | false |
163165
| DEVTRON_MODULES_IDENTIFIER_IN_HELM_VALUES | string |installer.modules | | | false |
166+
| DEVTRON_OPERATOR_BASE_PATH | string | | Base path for devtron operator, used to find the helm charts and values files | | false |
164167
| DEVTRON_SECRET_NAME | string |devtron-secret | | | false |
165168
| DEVTRON_VERSION_IDENTIFIER_IN_HELM_VALUES | string |installer.release | devtron operator version identifier in helm values yaml | | false |
166169
| DEX_CID | string |example-app | dex client id | | false |

manifests/installation-script

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
LTAG="v1.6.0";
22
REPO_RAW_URL="https://raw.githubusercontent.com/devtron-labs/devtron/";
3-
3+
shebang = `#!/bin/bash
4+
`;
5+
sleep50 = shebang + `
6+
sleep 50`;
7+
ignore = shellScript sleep50;
8+
ignore = shellScript sleep50;
9+
ignore = shellScript sleep50;
410
log("executed devtron setup installation");

pkg/module/ModuleService.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,15 @@ func (impl ModuleServiceImpl) handleModuleNotFoundStatus(moduleName string) (bea
251251

252252
// if check non-cicd module status
253253
if moduleName != bean.ModuleNameCiCd {
254-
isEnabled := gjson.Get(releaseValues, moduleUtil.BuildModuleEnableKey(moduleName)).Bool()
254+
isEnabled := gjson.Get(releaseValues, moduleUtil.BuildModuleEnableKey(impl.serverEnvConfig.DevtronOperatorBasePath, moduleName)).Bool()
255255
if isEnabled {
256256
status, err := impl.saveModuleAsInstalled(moduleName, moduleType, flagForEnablingState)
257257
return status, moduleType, flagForActiveTool, err
258258
}
259259
} else if util2.IsBaseStack() {
260260
// check if cicd is in installing state
261261
// if devtron is installed with cicd module, then cicd module should be shown as installing
262-
installerModulesIface := gjson.Get(releaseValues, bean.INSTALLER_MODULES_HELM_KEY).Value()
262+
installerModulesIface := gjson.Get(releaseValues, impl.serverEnvConfig.DevtronInstallerModulesPath).Value()
263263
if installerModulesIface != nil {
264264
installerModulesIfaceKind := reflect.TypeOf(installerModulesIface).Kind()
265265
if installerModulesIfaceKind == reflect.Slice {
@@ -410,20 +410,20 @@ func (impl ModuleServiceImpl) HandleModuleAction(userId int32, moduleName string
410410
}
411411

412412
extraValues := make(map[string]interface{})
413-
extraValues["installer.release"] = moduleActionRequest.Version
414-
extraValues[bean.INSTALLER_MODULES_HELM_KEY] = []interface{}{moduleName}
413+
extraValues[impl.serverEnvConfig.DevtronInstallerReleasePath] = moduleActionRequest.Version
414+
extraValues[impl.serverEnvConfig.DevtronInstallerModulesPath] = []interface{}{moduleName}
415415
alreadyInstalledModuleNames, err := impl.moduleRepository.GetInstalledModuleNames()
416416
if err != nil {
417417
impl.logger.Errorw("error in getting modules with installed status ", "err", err)
418418
return nil, err
419419
}
420-
moduleEnableKeys := moduleUtil.BuildAllModuleEnableKeys(moduleName)
420+
moduleEnableKeys := moduleUtil.BuildAllModuleEnableKeys(impl.serverEnvConfig.DevtronOperatorBasePath, moduleName)
421421
for _, moduleEnableKey := range moduleEnableKeys {
422422
extraValues[moduleEnableKey] = true
423423
}
424424
for _, alreadyInstalledModuleName := range alreadyInstalledModuleNames {
425425
if alreadyInstalledModuleName != moduleName {
426-
alreadyInstalledModuleEnableKeys := moduleUtil.BuildAllModuleEnableKeys(alreadyInstalledModuleName)
426+
alreadyInstalledModuleEnableKeys := moduleUtil.BuildAllModuleEnableKeys(impl.serverEnvConfig.DevtronOperatorBasePath, alreadyInstalledModuleName)
427427
for _, alreadyInstalledModuleEnableKey := range alreadyInstalledModuleEnableKeys {
428428
extraValues[alreadyInstalledModuleEnableKey] = true
429429
}

pkg/module/bean/bean.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ type ModuleStatus = string
8080
type ModuleName = string
8181

8282
const BlobStorage = "blob-storage"
83-
const INSTALLER_MODULES_HELM_KEY = "installer.modules"
8483
const (
8584
CLAIR_V4 = "V4"
8685
CLAIR_V2 = "V2"

pkg/module/util/ModuleUtil.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ import (
2121
"strings"
2222
)
2323

24-
func BuildAllModuleEnableKeys(moduleName string) []string {
24+
func BuildAllModuleEnableKeys(basePath string, moduleName string) []string {
2525
var keys []string
26-
keys = append(keys, BuildModuleEnableKey(moduleName))
26+
keys = append(keys, BuildModuleEnableKey(basePath, moduleName))
2727
if strings.Contains(moduleName, ".") {
2828
parent := strings.Split(moduleName, ".")[0]
29-
keys = append(keys, BuildModuleEnableKey(parent))
29+
keys = append(keys, BuildModuleEnableKey(basePath, parent))
3030
}
3131
return keys
3232
}
3333

34-
func BuildModuleEnableKey(moduleName string) string {
34+
func BuildModuleEnableKey(basePath string, moduleName string) string {
35+
if len(basePath) > 0 {
36+
return fmt.Sprintf("%s.%s.%s", basePath, moduleName, "enabled")
37+
}
3538
return fmt.Sprintf("%s.%s", moduleName, "enabled")
3639
}

pkg/server/ServerService.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@ func (impl ServerServiceImpl) HandleServerAction(userId int32, serverActionReque
158158
}
159159

160160
extraValues := make(map[string]interface{})
161-
extraValues["installer.release"] = serverActionRequest.Version
161+
extraValues[impl.serverEnvConfig.DevtronInstallerReleasePath] = serverActionRequest.Version
162162
alreadyInstalledModuleNames, err := impl.moduleRepository.GetInstalledModuleNames()
163163
if err != nil {
164164
impl.logger.Errorw("error in getting modules with installed status ", "err", err)
165165
return nil, err
166166
}
167167
for _, alreadyInstalledModuleName := range alreadyInstalledModuleNames {
168-
alreadyInstalledModuleEnableKeys := moduleUtil.BuildAllModuleEnableKeys(alreadyInstalledModuleName)
168+
alreadyInstalledModuleEnableKeys := moduleUtil.BuildAllModuleEnableKeys(impl.serverEnvConfig.DevtronOperatorBasePath, alreadyInstalledModuleName)
169169
for _, alreadyInstalledModuleEnableKey := range alreadyInstalledModuleEnableKeys {
170170
extraValues[alreadyInstalledModuleEnableKey] = true
171171
}

pkg/server/config/ServerEnvConfig.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ type ServerEnvConfig struct {
4141
ModuleMetaDataApiUrl string `env:"MODULE_METADATA_API_URL" envDefault:"https://api.devtron.ai/module?name=%s" description:"Modules list and meta info will be fetched from this server, that is central api server of devtron."`
4242
ParallelismLimitForTagProcessing int `env:"PARALLELISM_LIMIT_FOR_TAG_PROCESSING" description:"App manual sync job parallel tag processing count."`
4343
AppSyncJobShutDownWaitDuration int `env:"APP_SYNC_SHUTDOWN_WAIT_DURATION" envDefault:"120"`
44+
DevtronOperatorBasePath string `env:"DEVTRON_OPERATOR_BASE_PATH" envDefault:"" description:"Base path for devtron operator, used to find the helm charts and values files"`
45+
DevtronInstallerModulesPath string `env:"DEVTRON_INSTALLER_MODULES_PATH" envDefault:"installer.modules" description:"Path to devtron installer modules, used to find the helm charts and values files"`
46+
DevtronInstallerReleasePath string `env:"DEVTRON_INSTALLER_RELEASE_PATH" envDefault:"installer.release" description:"Path to devtron installer release, used to find the helm charts and values files"`
4447
ErrorEncounteredOnGettingDevtronHelmRelease error
4548
}
4649

wire_gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)