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

[ResourceCluster Part1] ResourceClustersManager actor + contracts #175

Merged
merged 7 commits into from
Apr 19, 2022

Conversation

Andyz26
Copy link
Collaborator

@Andyz26 Andyz26 commented Apr 14, 2022

Context

This PR adds the new ResourceClustersManagerActor and its dependent classes and contract classes as part of the effort to support non-Mesos cluster type for Mantis.

This new actor will be handling both API requests and requests from other actors related to any resource-cluster-related operations.

To support different cluster types (e.g. Kubernetes/Spinnaker), this new ResourceClustersManager actor and its corresponding contracts will provide abstraction only and not be tied to any framework-specific dependencies.

image

Checklist

  • ./gradlew build compiles code correctly
  • Added new tests where applicable
  • ./gradlew test passes all tests
  • Extended README or added javadocs where applicable
  • Added copyright headers for new files from CONTRIBUTING.md

@github-actions
Copy link

github-actions bot commented Apr 14, 2022

Unit Test Results

111 files  +36  111 suites  +36   5m 26s ⏱️ + 3m 10s
481 tests +95  462 ✔️ +94  19 💤 +2  0  - 1 

Results for commit af10210. ± Comparison against base commit b0f9e60.

♻️ This comment has been updated with latest results.


@Builder
@Value
public class ListResourceClusterRequest {
Copy link
Collaborator

Choose a reason for hiding this comment

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

move these within the actor class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All these contracts in a single file are going to make it a huge one though? Also, there are composite referenced classes that are already huge by themselves.

@Andyz26
Copy link
Collaborator Author

Andyz26 commented Apr 18, 2022

@calvin681 @codyrioux @hmit @sundargates: I would love to get some review/feedback, especially regarding the interface of IResourceClusterProvider and the provisioning part in the ResourceClustersManagerActor.

@Andyz26
Copy link
Collaborator Author

Andyz26 commented Apr 18, 2022

@sundargates I've renamed the classes here to avoid naming conflicts. Let me know if you have any other concerns.

build.gradle Show resolved Hide resolved
int desireSize;

@JsonCreator
public SkuCapacity(
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of adding an explicit constructor with @Json* annotations here, having @Value is enough since it does -- final @ToString @EqualsAndHashCode @AllArgsConstructor @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @Getter

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a workaround (when I tested the original clean version (@value + builder only) in nfmantis the shaded classes and Jackson doesn't play well with each other and other internal SDKs and it can only work when I have both annotation + upgrade shaded Jackson for all combinations).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let me add some notes here about this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add some tests to make sure you codify the expected behaviors? In this case, I'm guessing you want the classes to be Jackson serializable (which they already are because of our lombok.config checked in at the root level).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The tricky part is that these work just fine without any of the extra annotations in OSS repo but started to run into trouble imported in the internal wrapper mixing with other non-shaded Jackson. I will have more tests covering in the nfmantis side.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For OSS I will have some extra coverage on thee too in the follow up PR.

@Andyz26 Andyz26 requested a review from fdc-ntflx as a code owner April 19, 2022 22:06
@Andyz26 Andyz26 merged commit 7d225d7 into Netflix:master Apr 19, 2022
Comment on lines +37 to +44
flink : "1.14.2",
hadoop : "2.7.7",
junit4 : "4.11",
junit5 : "5.4.+",
mockito : "2.0.+",
mockito3: "3.+",
slf4j : "1.7.0",
vavr : "0.9.2",
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: maybe we should try to not align the colons given that this is constantly going to change based on the longest module name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think editor config might help streamline these. I will take a look.

* This interface provides the API to connect resource cluster management actor to actual
* implementations of different resource cluster clients e.g. k8s.
*/
public interface IResourceClusterProvider {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: let's rename this to ResourceClusterProvider. We want a consistent naming style for interfaces, and it's already mixed between I.* and regular interface names.

Comment on lines +66 to +82
@JsonCreator
public MantisResourceClusterSpec(
@JsonProperty("name") final String name,
@JsonProperty("id") final String id,
@JsonProperty("ownerName") final String ownerName,
@JsonProperty("ownerEmail") final String ownerEmail,
@JsonProperty("envType") final MantisResourceClusterEnvType envType,
@JsonProperty("skuSpecs") final Set<SkuTypeSpec> skuSpecs,
@JsonProperty("clusterMetadataFields") final Map<String, String> clusterMetadataFields) {
this.name = name;
this.id = id;
this.ownerName = ownerName;
this.ownerEmail = ownerEmail;
this.envType = envType;
this.skuSpecs = skuSpecs;
this.clusterMetadataFields = clusterMetadataFields;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think you should need both @value and @JsonCreator in the same class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See the other conversation thread regarding the workaround for Jackson.

Comment on lines +109 to +129
@JsonCreator
public SkuTypeSpec(
@JsonProperty("skuId") final String skuId,
@JsonProperty("capacity") final SkuCapacity capacity,
@JsonProperty("imageId") final String imageId,
@JsonProperty("cpuCoreCount") final int cpuCoreCount,
@JsonProperty("memorySizeInBytes") final int memorySizeInBytes,
@JsonProperty("networkMbps") final int networkMbps,
@JsonProperty("diskSizeInBytes") final int diskSizeInBytes,
@JsonProperty("skuMetadataFields") final Map<String, String> skuMetadataFields) {
this.skuId = skuId;
this.capacity = capacity;
this.imageId = imageId;
this.cpuCoreCount = cpuCoreCount;
this.memorySizeInBytes = memorySizeInBytes;
this.networkMbps = networkMbps;
this.diskSizeInBytes = diskSizeInBytes;
this.skuMetadataFields = skuMetadataFields;
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

same here.

int desireSize;

@JsonCreator
public SkuCapacity(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add some tests to make sure you codify the expected behaviors? In this case, I'm guessing you want the classes to be Jackson serializable (which they already are because of our lombok.config checked in at the root level).

Comment on lines +142 to +143
@JsonCreator
public SkuCapacity(
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Don't think you need this.

@Builder
public class MantisResourceClusterSpec {

@NonNull
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's not use the @nonnull annotation. By default, let's assume all fields are non-null by default. If something is nullable, use optional types in case that class is in the API layer (i.e., external-facing) or @nullable if the field is only within a class (i.e., internal-facing).

String ownerEmail;

@NonNull
MantisResourceClusterEnvType envType;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need this? can this not be obtained from the env the mantis-control-plane is being run from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would prefer not to have an assumption about env var at this layer but leave it at the entry-point/wrapper to decide how to obtain it.


@Builder
@Value
public static class SkuCapacity {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants