Skip to content

Commit 96a0518

Browse files
authored
handling for HPA (autoscaling) (#5666)
1 parent 12b6185 commit 96a0518

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

pkg/deployment/manifest/ManifestCreationService.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ func (impl *ManifestCreationServiceImpl) getArgoCdHPAResourceManifest(ctx contex
887887
recv, argoErr := impl.acdClient.GetResource(newCtx, query)
888888
if argoErr != nil {
889889
grpcCode, errMsg := util.GetClientDetailedError(argoErr)
890-
if grpcCode.IsInvalidArgumentCode() {
890+
if grpcCode.IsInvalidArgumentCode() || grpcCode.IsNotFoundCode() {
891891
// this is a valid case for hibernated applications, so returning nil
892892
// for hibernated applications, we don't have any hpa resource manifest
893893
return resourceManifest, nil
@@ -1037,6 +1037,11 @@ func (impl *ManifestCreationServiceImpl) autoscalingCheckBeforeTrigger(ctx conte
10371037
if len(resourceManifest) > 0 {
10381038
statusMap := resourceManifest["status"].(map[string]interface{})
10391039
currentReplicaVal := statusMap["currentReplicas"]
1040+
// currentReplicas key might not be available in manifest while k8s is calculating replica count
1041+
// it's a valid case so, we are not throwing error
1042+
if currentReplicaVal == nil {
1043+
return merged, err
1044+
}
10401045
currentReplicaCount, err := globalUtil.ParseFloatNumber(currentReplicaVal)
10411046
if err != nil {
10421047
impl.logger.Errorw("error occurred while parsing replica count", "currentReplicas", currentReplicaVal, "err", err)

pkg/deployment/trigger/devtronApps/TriggerService.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -788,10 +788,10 @@ func (impl *TriggerServiceImpl) TriggerRelease(overrideRequest *bean3.ValuesOver
788788
valuesOverrideResponse, builtChartPath, err := impl.manifestCreationService.BuildManifestForTrigger(overrideRequest, triggeredAt, newCtx)
789789

790790
if envDeploymentConfig == nil || (envDeploymentConfig != nil && envDeploymentConfig.Id == 0) {
791-
envDeploymentConfig, err = impl.deploymentConfigService.GetAndMigrateConfigIfAbsentForDevtronApps(overrideRequest.AppId, overrideRequest.EnvId)
792-
if err != nil {
793-
impl.logger.Errorw("error in getting deployment config by appId and envId", "appId", overrideRequest.AppId, "envId", overrideRequest.EnvId, "err", err)
794-
return releaseNo, err
791+
envDeploymentConfig, err1 := impl.deploymentConfigService.GetAndMigrateConfigIfAbsentForDevtronApps(overrideRequest.AppId, overrideRequest.EnvId)
792+
if err1 != nil {
793+
impl.logger.Errorw("error in getting deployment config by appId and envId", "appId", overrideRequest.AppId, "envId", overrideRequest.EnvId, "err", err1)
794+
return releaseNo, err1
795795
}
796796
valuesOverrideResponse.DeploymentConfig = envDeploymentConfig
797797
}

0 commit comments

Comments
 (0)