Skip to content

Add support for Dataproc Flexible Machine Types in compute profiles - #16204

Open
123-komal wants to merge 1 commit into
developfrom
flexvm-support
Open

Add support for Dataproc Flexible Machine Types in compute profiles#16204
123-komal wants to merge 1 commit into
developfrom
flexvm-support

Conversation

@123-komal

@123-komal 123-komal commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Adds support for configuring flexible fallback machine types for Dataproc master and worker nodes. This allows clusters to automatically fall back to alternative machine types in priority order if the primary machine type is unavailable.

Changes

  • gcp-dataproc.json: Added masterFlexVmMachineTypes and workerFlexVmMachineTypes dropdowns to configure fallback machine types (n1, n2, n2d, e2).
  • DataprocConf.java: Added parsing and helper methods to format fallback machine types with configured CPU and memory values.
  • DataprocClient.java: Attached flexible machine type configuration to master, primary worker, and secondary worker node configs when present.
  • DataprocProvisioner.java: Added validation to verify machine type naming formats.
  • DataprocProvisionerTest.java: Added unit tests covering property parsing, validation, and cluster creation.

Testing

  • Unit tests pass locally.
  • Verified successful cluster creation and fallback configuration on a live test cluster.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for Dataproc Instance Flexibility Policies by adding configuration options for master and worker flex VM machine types. However, the current implementation is prone to throwing a NullPointerException at runtime because Protobuf builders do not accept null values when these optional properties are omitted. Feedback has been provided to conditionally build and safely apply these flexibility policies, as well as to support comma-separated machine types.

@123-komal 123-komal changed the title Adding Support for the Flexvm Add support for Dataproc Flexible Machine Types in compute profiles Aug 20, 2026
@123-komal
123-komal force-pushed the flexvm-support branch 2 times, most recently from da0c03c to c22ed75 Compare August 20, 2026 13:24
@123-komal 123-komal added the build Triggers github actions build label Aug 20, 2026
@123-komal
123-komal force-pushed the flexvm-support branch 3 times, most recently from 035da77 to 03ed2d9 Compare August 21, 2026 03:54
}
}

private List<String> formatFlexMachineTypes(List<String> flexTypes, int cpus, int memoryMb) {

@vsethi09 vsethi09 Aug 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified as:

private List<String> formatFlexMachineTypes(List<String> flexTypes, int cpus, int memoryMb) {
    return flexTypes.stream()
            .map(type -> getMachineType(type, cpus, memoryMb))
            .collect(Collectors.toUnmodifiableList());
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toUnmodifiableList() option was present for the given java version so I tweak it the logic that you provided too the below one

private List<String> formatFlexMachineTypes(List<String> flexTypes, int cpus, int memoryMb) {  
    List<String> result = flexTypes.stream()
      .map(type -> getMachineType(type, cpus, memoryMb))
      .collect(Collectors.toList());

    return Collections.unmodifiableList(result);
  }

return Strings.isNullOrEmpty(val)
? Collections.emptyList()
: Collections.unmodifiableList(
Splitter.on(',').trimResults().omitEmptyStrings().splitToList(val));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splitter.splitToList returns immutable list. No need to wrap it again.

private static final Splitter COMMA_SPLITTER = 
        Splitter.on(',').trimResults().omitEmptyStrings();

private static List<String> getStringList(Map<String, String> properties, String key) {
    String val = getString(properties, key);
    return Strings.isNullOrEmpty(val) 
            ? List.of() 
            : COMMA_SPLITTER.splitToList(val);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using the same method you provide, but the List.of() is not supported with the given java version. I think it was introduced in the later ones so I used the below one

private static final Splitter COMMA_SPLITTER = 
        Splitter.on(',').trimResults().omitEmptyStrings();

private static List<String> getStringList(Map<String, String> properties, String key) {  
    String val = getString(properties, key);
    return Strings.isNullOrEmpty(val)
      ? Collections.emptyList()
      : COMMA_SPLITTER.splitToList(val);
  }

"n1",
"n2",
"n2d",
"e2"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should n4 be present in the list?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have kept the supported option same as the one with we listed in masterMachineType. But we can still n4 during runtime, which I also tested and it worked.

Assert.assertEquals(1, apiCount.intValue());
Assert.assertEquals(1, genericCount.intValue());
}
@Test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing new line before this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Now.

Comment thread cdap-runtime-ext-dataproc/src/main/resources/gcp-dataproc.json
* Parses a comma-separated string property into a trimmed list of strings,
* or returns an empty list if null/empty.
*/
private static List<String> getStringList(Map<String, String> properties, String key) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check other fields that are "widget-type": "csv"
Example : networkTags ,scopes etc..

How are they parsed ?

And if this function can be made generic to be used for other such fields?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the other "widget-type": "csv" fields (networkTags, scopes, and initActions).

networkTags is a standard CSV, and we can use the same method getStringList for it. However, scopes has domain-specific logic (appending CLOUD_PLATFORM_SCOPE and deduplicating), and initActions has its own constructor and getter lifecycle. I keep their update logic same and it's logic is different from the getStringList.

 Add support for Dataproc Flexible Machine Types in compute profiles

 Adding Support for the Flexvm

 Updated

 Updated

 Updated

 Updated

 Updated

 Updated

 Updated
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

.setGceClusterConfig(clusterConfig.build())
.setSoftwareConfig(softwareConfigBuilder);
.setEndpointConfig(EndpointConfig.newBuilder()
.setEnableHttpPortAccess(conf.isComponentGatewayEnabled())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fix indentation, if broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Triggers github actions build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants