Skip to content
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 src/server/db/migrations/001_seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ export async function up(knex: Knex): Promise<any> {
INSERT INTO global_config (key, config, "createdAt", "updatedAt", "deletedAt", description) VALUES ('lifecycleIgnores', '{"github":{"branches":[],"events":["closed","deleted"],"organizations":[],"botUsers":[]}}', now(), now(), null, 'Data values for Lifecycle to ignore');
INSERT INTO global_config (key, config, "createdAt", "updatedAt", "deletedAt", description) VALUES ('deletePendingHelmReleaseStep', '{"delete":true,"static_delete":true}', now(), now(), null, 'If deletePendingHelmReleaseStep is set to true');
INSERT INTO global_config (key, config, "createdAt", "updatedAt", "deletedAt", description) VALUES ('redpanda', '{"version":"3.7.2","args":"--force --timeout 60m0s --wait","action":"install","chart":{"name":"redpanda","repoUrl":"https://charts.redpanda.com","version":"5.9.0","values":[],"valueFiles":[]},"tolerations":"tolerations","affinity":"affinity","nodeSelector":"nodeSelector"}', now(), now(), null, 'Redpanda helm chart configuration default values.');
INSERT INTO global_config (key, config, "createdAt", "updatedAt", "deletedAt", description) VALUES ('kedaScaleToZero', '{"type":"http","replicas":{"min":1,"max":3},"scaledownPeriod":10800,"maxRetries":10,"scalingMetric":{"requestRate":{"granularity":"1m","targetValue":30,"window":"1m"},"concurrency":{"targetValue":100}}}', now(), now(), null, 'This is the default configuration for Keda Scale To Zero');
INSERT INTO global_config (key, config, "createdAt", "updatedAt", "deletedAt", description) VALUES ('kedaScaleToZero', '{"enabled":false,"type":"http","replicas":{"min":1,"max":3},"scaledownPeriod":10800,"maxRetries":10,"scalingMetric":{"requestRate":{"granularity":"1m","targetValue":30,"window":"1m"},"concurrency":{"targetValue":100}}}', now(), now(), null, 'This is the default configuration for Keda Scale To Zero');
INSERT INTO global_config (key, config, "createdAt", "updatedAt", "deletedAt", description) VALUES ('mongodb', '{"version":"3.7.2","args":"--force --timeout 60m0s --wait","action":"install","chart":{"name":"mongodb","repoUrl":"https://charts.bitnami.com/bitnami","version":"16.3.0","values":["auth.rootPassword=rootpassword","replicaCount=1","timeoutSeconds=20","periodSeconds=15","timeoutSeconds=20","periodSeconds=15","useStatefulSet=true"],"valueFiles":[]},"label":"labels","tolerations":"tolerations","affinity":"affinity","nodeSelector":"nodeSelector"}', now(), now(), null, 'MongoDB bitnami helm chart configuration default values.');
INSERT INTO global_config (key, config, "createdAt", "updatedAt", "deletedAt", description) VALUES ('serviceDefaults', '{"dockerfilePath":"Dockerfile","cpuRequest":"10m","memoryRequest":"100Mi","readinessInitialDelaySeconds":0,"readinessPeriodSeconds":10,"readinessTimeoutSeconds":1,"readinessSuccessThreshold":1,"readinessFailureThreshold":30,"readinessTcpSocketPort":8090,"readinessHttpGetPort":8080,"readinessHttpGetPath":"/__lbheartbeat__","acmARN":"replace_me","scaleToZero":false,"scaleToZeroMetricsCheckInterval":1800,"grpc":false,"defaultIPWhiteList":"{ 0.0.0.0/0 }"}', now(), now(), null, 'Default configuration for services for values that are not set in the configuration file');
INSERT INTO global_config (key, config, "createdAt", "updatedAt", "deletedAt", description) VALUES ('domainDefaults', '{"http":"app.local","grpc":"app-grpc.local"}', now(), now(), null, 'Default domain hostnames for the lifecycle deployments');
Expand Down
25 changes: 9 additions & 16 deletions src/server/services/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,24 +145,17 @@ export default class DeployService extends BaseService {
}
}

if (deployable?.kedaScaleToZero?.type == 'http') {
const globalConfig = await GlobalConfigService.getInstance().getAllConfigs();
const defaultKedaScaleToZero = globalConfig.kedaScaleToZero;
const deployableKedaScaleToZero = deployable?.kedaScaleToZero;
const { kedaScaleToZero: defaultKedaScaleToZero } = await GlobalConfigService.getInstance().getAllConfigs();

const kedaScaleToZero = {
...defaultKedaScaleToZero,
...deployableKedaScaleToZero,
};
const kedaScaleToZero =
deployable?.kedaScaleToZero?.type === 'http' && defaultKedaScaleToZero?.enabled
? {
...defaultKedaScaleToZero,
...deployable.kedaScaleToZero,
}
: null;

await deploy.$query().patch({
kedaScaleToZero,
});
} else {
await deploy.$query().patch({
kedaScaleToZero: null,
});
}
await deploy.$query().patch({ kedaScaleToZero });
})
).catch((error) => {
logger.error(`[BUILD ${build?.uuid}] Failed to create deploys from deployables: ${error}`);
Expand Down
4 changes: 2 additions & 2 deletions src/server/services/deployable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export default class DeployableService extends BaseService {
}
}
}
const { serviceDefaults, lifecycleDefaults, domainDefaults } =
const { serviceDefaults, lifecycleDefaults, domainDefaults, kedaScaleToZero } =
await GlobalConfigService.getInstance().getAllConfigs();
//TODO check and throw error here?
const defaultUUID = lifecycleDefaults.defaultUUID;
Expand Down Expand Up @@ -371,7 +371,7 @@ export default class DeployableService extends BaseService {
dependsOnDeployableName,
helm: await YamlService.getHelmConfigFromYaml(service),
deploymentDependsOn: service.deploymentDependsOn || [],
kedaScaleToZero: YamlService.getScaleToZeroConfig(service) ?? null,
kedaScaleToZero: kedaScaleToZero?.enabled ? YamlService.getScaleToZeroConfig(service) : null,
builder: YamlService.getBuilder(service) ?? {},
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/services/types/globalConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type GlobalConfig = {
publicChart: PublicChart;
lifecycleIgnores: LifecycleIgnores;
deletePendingHelmReleaseStep: DeletePendingHelmReleaseStep;
kedaScaleToZero: KedaScaleToZero;
kedaScaleToZero: KedaScaleToZero & { enabled: boolean };
serviceDefaults: Record<string, any>;
domainDefaults: DomainDefaults;
orgChart: OrgChart;
Expand Down