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

New MAAS (Metal as a Service) infrastructure. #53

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

vinseon
Copy link
Contributor

@vinseon vinseon commented Aug 4, 2017

Implementation of the new MAAS (Metal as a Service) cloud infrastructure.

The new infrastructure essentially rely on the Java REST Client developped by ActiveEon: https://github.com/ow2-proactive/maas-rest-client.

Note: It is assumed that the machines to deploy are already registered to the MAAS region/rack controllers. Usually a first boot is enough to register new machines when controllers are configured with auto-discovery feature. New machines may need to be configured manually if the power parameters can not be retrieved automatically (eg. IPMI configuration). Once the machines are recognized by MAAS (systemId generated) they can be allocated, deployed, and released by the connector-iaas.

For now, the deployment can be done in two different ways:

  • The user provide the minimal amount of CPU and/or RAM desired for the new machines to deploy. If provided, the amount of instances will be used to deploy multiple machines if available.
  • The user provide the systemId of the Machine to deploy. In this case the amount of instances to deploy and the minimal resources needed are ignored.

Supported feature:

  • Fully deploy machines in parallel: [Allocate -> Set tag -> Deploy -> Run script]
  • Deploy from systemId
  • Keep a cache of deployed machines on MAAS' side by using a specific tag
  • Release single or all deployed machines
  • Upload commissioning scripts

Limitations:

  • Tags' name must be unique, so multiple connector-iaas should have different tag names. The value is therefore useless and not used for filtering (it is worth noting that the tag name should be customized before using the connector).

Improvements:

  • Add new filtering options for deployment
  • Provide a list of systemId to deploy multiple Machines from their IDs
  • Manage networking configuration (like fabrics, interfaces, etc.) in the future if needed

infrastructure.getCredentials().getPassword(),
infrastructure.isAllowSelfSignedSSLCertificate());
} catch (RemoteConnectFailureException e) {
throw new RuntimeException("ERROR trying to create MaasClient with infrastructure : " + infrastructure, e);

Choose a reason for hiding this comment

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

MINOR Define and throw a dedicated exception instead of using a generic one. rule

private Function<Infrastructure, MaasClient> buildMaasClient = memoise(infrastructure -> maasClientBuilder.buildMaasClientFromInfrastructure(infrastructure));

private Function<Infrastructure, MaasClient> memoise(Function<Infrastructure, MaasClient> fn) {
return (a) -> maasClientCache.computeIfAbsent(a, fn);

Choose a reason for hiding this comment

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

MINOR Remove the parentheses around the "a" parameter rule

maasClientCache.remove(infrastructure);
}

private Function<Infrastructure, MaasClient> buildMaasClient = memoise(infrastructure -> maasClientBuilder.buildMaasClientFromInfrastructure(infrastructure));

Choose a reason for hiding this comment

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

MINOR Move this variable to comply with Java Code Conventions. rule

@Override
public void deleteInstance(Infrastructure infrastructure, String instanceId) {
if (!maasProviderClientCache.getMaasClient(infrastructure).releaseMachineById(instanceId)) {
throw new RuntimeException("ERROR when deleting MAAS instance : " + instanceId);

Choose a reason for hiding this comment

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

MINOR Define and throw a dedicated exception instead of using a generic one. rule

@Component
public class MaasProvider implements CloudProvider {

private final Logger logger = Logger.getLogger(MaasProvider.class);
Copy link

@sonarqube-activeeon sonarqube-activeeon Aug 4, 2017

Choose a reason for hiding this comment

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

MINOR Make the "logger" logger private static final. rule

Set<Instance> instances = futureMachines.stream().map(futureMachine -> {
try {
return futureMachine.get();
} catch (InterruptedException | ExecutionException e) {

Choose a reason for hiding this comment

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

MAJOR Either log or rethrow this exception. rule

private final Logger logger = Logger.getLogger(MaasProvider.class);

@Getter
private final String type = "maas";

Choose a reason for hiding this comment

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

MINOR Make this final field static too. rule


@Override
public Set<Image> getAllImages(Infrastructure infrastructure) {
throw new NotSupportedException("Operation not supported for MAAS");

Choose a reason for hiding this comment

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

MINOR Define a constant instead of duplicating this literal "Operation not supported for MAAS" 3 times. rule

@sonarqube-activeeon
Copy link

SonarQube analysis reported 8 issues

  • MAJOR 1 major
  • MINOR 7 minor

Watch the comments in this conversation to review them.

@marcocast
Copy link
Contributor

retest this please

1 similar comment
@Mykhailenko
Copy link

retest this please

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.

4 participants