Skip to content

Commit

Permalink
Add denied reason for MAX_SIZE
Browse files Browse the repository at this point in the history
  • Loading branch information
nielm committed Dec 1, 2023
1 parent 7eac777 commit 324e082
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/scaler/scaler-core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,25 @@ async function processScalingRequest(spanner, autoscalerState) {
});

const suggestedSize = getSuggestedSize(spanner);
if (suggestedSize == spanner.currentSize) {
if (suggestedSize == spanner.maxSize) {
log(`----- ${spanner.projectId}/${spanner.instanceId}: has ${
spanner.currentSize} ${
spanner.units}, no scaling needed at the moment`,
spanner.units}, no scaling possible - at maxSize`,
{
severity: 'INFO',
projectId: spanner.projectId,
instanceId: spanner.instanceId,
payload: spanner,
});
Counters.incScalingDeniedCounter(
spanner,
suggestedSize,
'MAX_SIZE');
return;
} else if (suggestedSize == spanner.currentSize) {
log(`----- ${spanner.projectId}/${spanner.instanceId}: has ${
spanner.currentSize} ${
spanner.units}, no scaling needed - at current size`,
{
severity: 'INFO',
projectId: spanner.projectId,
Expand Down
21 changes: 21 additions & 0 deletions src/scaler/scaler-core/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,27 @@ describe('#processScalingRequest', () => {
assert.equals(countersStub.incScalingFailedCounter.callCount, 0);
});

it('should not autoscale if suggested size is equal to max size',
async function() {
spanner = createSpannerParameters();
app.__set__(
'getSuggestedSize', sinon.stub().returns(spanner.maxSize));

await processScalingRequest(spanner, createStubState());

assert.equals(stubScaleSpannerInstance.callCount, 0);

assert.equals(countersStub.incScalingSuccessCounter.callCount, 0);
assert.equals(countersStub.incScalingDeniedCounter.callCount, 1);
assert.equals(
countersStub.incScalingDeniedCounter.getCall(0).args[1],
spanner.maxSize);
assert.equals(
countersStub.incScalingDeniedCounter.getCall(0).args[2],
'MAX_SIZE');
assert.equals(countersStub.incScalingFailedCounter.callCount, 0);
});

it('should autoscale if suggested size is not equal to current size',
async function() {
spanner = createSpannerParameters();
Expand Down

0 comments on commit 324e082

Please sign in to comment.