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

fix: handling for HPA (autoscaling) #5666

Merged
merged 4 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
handling for HPA (autoscaling)
  • Loading branch information
prkhrkat committed Aug 12, 2024
commit 13cdd59df93b5b4695ecc1f50ed5730df086f861
7 changes: 6 additions & 1 deletion pkg/deployment/manifest/ManifestCreationService.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ func (impl *ManifestCreationServiceImpl) getArgoCdHPAResourceManifest(ctx contex
recv, argoErr := impl.acdClient.GetResource(newCtx, query)
if argoErr != nil {
grpcCode, errMsg := util.GetClientDetailedError(argoErr)
if grpcCode.IsInvalidArgumentCode() {
if grpcCode.IsInvalidArgumentCode() || grpcCode.IsNotFoundCode() {
// this is a valid case for hibernated applications, so returning nil
// for hibernated applications, we don't have any hpa resource manifest
return resourceManifest, nil
Expand Down Expand Up @@ -914,6 +914,11 @@ func (impl *ManifestCreationServiceImpl) autoscalingCheckBeforeTrigger(ctx conte
if len(resourceManifest) > 0 {
statusMap := resourceManifest["status"].(map[string]interface{})
currentReplicaVal := statusMap["currentReplicas"]
// currentReplicas key might not be available in manifest while k8s is calculating replica count
// it's a valid case so, we are not throwing error
if currentReplicaVal == nil {
return merged, err
}
currentReplicaCount, err := util4.ParseFloatNumber(currentReplicaVal)
if err != nil {
impl.logger.Errorw("error occurred while parsing replica count", "currentReplicas", currentReplicaVal, "err", err)
Expand Down
8 changes: 4 additions & 4 deletions pkg/deployment/trigger/devtronApps/TriggerService.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,10 +788,10 @@ func (impl *TriggerServiceImpl) TriggerRelease(overrideRequest *bean3.ValuesOver
valuesOverrideResponse, builtChartPath, err := impl.manifestCreationService.BuildManifestForTrigger(overrideRequest, triggeredAt, newCtx)

if envDeploymentConfig == nil || (envDeploymentConfig != nil && envDeploymentConfig.Id == 0) {
envDeploymentConfig, err = impl.deploymentConfigService.GetAndMigrateConfigIfAbsentForDevtronApps(overrideRequest.AppId, overrideRequest.EnvId)
if err != nil {
impl.logger.Errorw("error in getting deployment config by appId and envId", "appId", overrideRequest.AppId, "envId", overrideRequest.EnvId, "err", err)
return releaseNo, err
envDeploymentConfig, err1 := impl.deploymentConfigService.GetAndMigrateConfigIfAbsentForDevtronApps(overrideRequest.AppId, overrideRequest.EnvId)
if err1 != nil {
impl.logger.Errorw("error in getting deployment config by appId and envId", "appId", overrideRequest.AppId, "envId", overrideRequest.EnvId, "err", err1)
return releaseNo, err1
}
valuesOverrideResponse.DeploymentConfig = envDeploymentConfig
}
Expand Down
Loading