-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Adding support for autoscaling in GCE #8987
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
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
bf21a31
Adding support for autoscaling in GCE
frnidito 7d42d04
adding extra google deps also in gce pom
frnidito e7475b7
fix link in doc
frnidito bfc705c
remove unused deps
frnidito c8eda74
adding terms to spelling file
frnidito a185110
version in pom 0.17.0-incubating-SNAPSHOT --> 0.18.0-SNAPSHOT
frnidito 5607d17
GCEXyz -> GceXyz in naming for consistency
frnidito ff0d8d4
add preconditions
frnidito 7b0761a
add VisibleForTesting annotation
frnidito 96d3804
typos in comments
frnidito 6a43f49
use StringUtils.format instead of String.format
frnidito 8d03c84
use custom exception instead of exit
frnidito 721f4c0
factorize interval time between retries
frnidito a1029af
making literal value a constant
frnidito 35dea27
iter all network interfaces
frnidito 7a5aac2
use provided on google (non api) deps
frnidito ccede8f
adding missing dep
frnidito e2b352b
removing unneded this and use Objects methods instead o 3-way if in h…
frnidito e67e867
adding import
frnidito 0964bad
adding retries around getRunningInstances and adding limit for operat…
frnidito 8b0ae54
refactor GceEnvironmentConfig.hashCode
frnidito c58b2d8
0.18.0-SNAPSHOT -> 0.19.0-SNAPSHOT
frnidito 8337a5f
removing unused config
frnidito 6ad5992
adding tests to hash and equals
frnidito d2fe900
adding nullable to waitForOperationEnd
frnidito 802cc9f
adding testTerminate
frnidito f756cbe
adding unit tests for createComputeService
frnidito 77ff4d5
increasing retries in unrelated integration-test to prevent sporadic …
frnidito 546cb0e
reverting queryResponseTemplate change
frnidito 1791ee6
adding comment for Compute.Builder.build() returning null
frnidito File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| --- | ||
| id: gce-extensions | ||
| title: "GCE Extensions" | ||
| --- | ||
|
|
||
| <!-- | ||
| ~ Licensed to the Apache Software Foundation (ASF) under one | ||
| ~ or more contributor license agreements. See the NOTICE file | ||
| ~ distributed with this work for additional information | ||
| ~ regarding copyright ownership. The ASF licenses this file | ||
| ~ to you under the Apache License, Version 2.0 (the | ||
| ~ "License"); you may not use this file except in compliance | ||
| ~ with the License. You may obtain a copy of the License at | ||
| ~ | ||
| ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| ~ | ||
| ~ Unless required by applicable law or agreed to in writing, | ||
| ~ software distributed under the License is distributed on an | ||
| ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| ~ KIND, either express or implied. See the License for the | ||
| ~ specific language governing permissions and limitations | ||
| ~ under the License. | ||
| --> | ||
|
|
||
|
|
||
| To use this Apache Druid (incubating) extension, make sure to [include](../../development/extensions.md#loading-extensions) `gce-extensions`. | ||
|
|
||
| At the moment, this extension enables only Druid to autoscale instances in GCE. | ||
|
|
||
| The extension manages the instances to be scaled up and down through the use of the [Managed Instance Groups](https://cloud.google.com/compute/docs/instance-groups/creating-groups-of-managed-instances#resize_managed_group) | ||
| of GCE (MIG from now on). This choice has been made to ease the configuration of the machines and simplify their | ||
| management. | ||
|
|
||
| For this reason, in order to use this extension, the user must have created | ||
| 1. An instance template with the right machine type and image to bu used to run the MiddleManager | ||
| 2. A MIG that has been configured to use the instance template created in the point above | ||
|
|
||
| Moreover, in order to be able to rescale the machines in the MIG, the Overlord must run with a service account | ||
| guaranteeing the following two scopes from the [Compute Engine API](https://developers.google.com/identity/protocols/googlescopes#computev1) | ||
| - `https://www.googleapis.com/auth/cloud-platform` | ||
| - `https://www.googleapis.com/auth/compute` | ||
|
|
||
| ## Overlord Dynamic Configuration | ||
|
|
||
| The Overlord can dynamically change worker behavior. | ||
|
|
||
| The JSON object can be submitted to the Overlord via a POST request at: | ||
|
|
||
| ``` | ||
| http://<OVERLORD_IP>:<port>/druid/indexer/v1/worker | ||
| ``` | ||
|
|
||
| Optional Header Parameters for auditing the config change can also be specified. | ||
|
|
||
| |Header Param Name| Description | Default | | ||
| |----------|-------------|---------| | ||
| |`X-Druid-Author`| author making the config change|""| | ||
| |`X-Druid-Comment`| comment describing the change being done|""| | ||
|
|
||
| A sample worker config spec is shown below: | ||
|
|
||
| ```json | ||
| { | ||
| "autoScaler": { | ||
| "envConfig" : { | ||
| "numInstances" : 1, | ||
| "projectId" : "super-project", | ||
| "zoneName" : "us-central-1", | ||
| "managedInstanceGroupName" : "druid-middlemanagers" | ||
| }, | ||
| "maxNumWorkers" : 4, | ||
| "minNumWorkers" : 2, | ||
| "type" : "gce" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| The configuration of the autoscaler is quite simple and it is made of two levels only. | ||
|
|
||
| The external level specifies the `type`—always `gce` in this case— and two numeric values, | ||
| the `maxNumWorkers` and `minNumWorkers` used to define the boundaries in between which the | ||
| number of instances must be at any time. | ||
|
|
||
| The internal level is the `envConfig` and it is used to specify | ||
|
|
||
| - The `numInstances` used to specify how many workers will be spawned at each | ||
| request to provision more workers. This is safe to be left to `1` | ||
| - The `projectId` used to specify the name of the project in which the MIG resides | ||
| - The `zoneName` used to identify in which zone of the worlds the MIG is | ||
| - The `managedInstanceGroupName` used to specify the MIG containing the instances created or | ||
| removed | ||
|
|
||
| Please refer to the Overlord Dynamic Configuration section in the main [documentation](../../configuration/index.md) | ||
| for parameters other than the ones specified here, such as `selectStrategy` etc. | ||
|
|
||
| ## Known limitations | ||
|
|
||
| - The module internally uses the [ListManagedInstances](https://cloud.google.com/compute/docs/reference/rest/v1/instanceGroupManagers/listManagedInstances) | ||
| call from the API and, while the documentation of the API states that the call can be paged through using the | ||
| `pageToken` argument, the responses to such call do not provide any `nextPageToken` to set such parameter. This means | ||
| that the extension can operate safely with a maximum of 500 MiddleManagers instances at any time (the maximum number | ||
| of instances to be returned for each call). | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| <?xml version="1.0"?> | ||
| <!-- | ||
| ~ Licensed to the Apache Software Foundation (ASF) under one | ||
| ~ or more contributor license agreements. See the NOTICE file | ||
| ~ distributed with this work for additional information | ||
| ~ regarding copyright ownership. The ASF licenses this file | ||
| ~ to you under the Apache License, Version 2.0 (the | ||
| ~ "License"); you may not use this file except in compliance | ||
| ~ with the License. You may obtain a copy of the License at | ||
| ~ | ||
| ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| ~ | ||
| ~ Unless required by applicable law or agreed to in writing, | ||
| ~ software distributed under the License is distributed on an | ||
| ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| ~ KIND, either express or implied. See the License for the | ||
| ~ specific language governing permissions and limitations | ||
| ~ under the License. | ||
| --> | ||
| <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| <parent> | ||
| <groupId>org.apache.druid</groupId> | ||
| <artifactId>druid</artifactId> | ||
| <version>0.19.0-SNAPSHOT</version> | ||
| <relativePath>../../pom.xml</relativePath> | ||
| </parent> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>org.apache.druid.extensions.contrib</groupId> | ||
| <artifactId>gce-extensions</artifactId> | ||
| <name>gce-extensions</name> | ||
| <description>Extension to support the autoscaling in GCE</description> | ||
|
|
||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| </properties> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.apache.druid</groupId> | ||
| <artifactId>druid-core</artifactId> | ||
| <version>${project.parent.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.druid</groupId> | ||
| <artifactId>druid-indexing-service</artifactId> | ||
| <version>${project.parent.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.druid</groupId> | ||
| <artifactId>druid-aws-common</artifactId> | ||
| <version>${project.parent.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.druid</groupId> | ||
| <artifactId>druid-processing</artifactId> | ||
| <version>${project.parent.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.code.findbugs</groupId> | ||
| <artifactId>jsr305</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-annotations</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.guava</groupId> | ||
| <artifactId>guava</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.inject</groupId> | ||
| <artifactId>guice</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-databind</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.apis</groupId> | ||
| <artifactId>google-api-services-compute</artifactId> | ||
| <version>v1-rev214-1.25.0</version> | ||
| <scope>compile</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.http-client</groupId> | ||
| <artifactId>google-http-client</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.http-client</groupId> | ||
| <artifactId>google-http-client-jackson2</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.google.api-client</groupId> | ||
| <artifactId>google-api-client</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.curator</groupId> | ||
| <artifactId>curator-client</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <!-- Tests --> | ||
| <dependency> | ||
| <groupId>junit</groupId> | ||
| <artifactId>junit</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.easymock</groupId> | ||
| <artifactId>easymock</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>nl.jqno.equalsverifier</groupId> | ||
| <artifactId>equalsverifier</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.