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

PAYARA-3573 Dynamic Instances #4090

Merged
merged 16 commits into from Aug 1, 2019

Conversation

@Pandrex247
Copy link
Member

commented Jul 15, 2019

Synopsis

Adds "dynamic instances" to Payara Server.
This is an auto-naming feature for Payara Server instances, either resolving naming conflicts or delegating the naming of instances to Payara Server.

The intention is for this to be used with Docker Nodes to allow for much easier auto-scaling of instances (changes to the docker image and any extra work to be done in a separate PR). It's also simply a convenience feature.

This PR adds two new CLI options (not command parameters), meaning that they can be extended for use with any command: autoname and extraterse

Usage

The extraterse option is intended for use with scripts, adding an extra level of terseness to the command output to the CLI. When enabled, the create-instance and create-local-instance commands should only return the name of the instance created. The intention behind this feature being that you should be able to set variables from this output for use with scripts, since you can't know beforehand what the name of an instance is if a name conflict is resolved or a name is generated from scratch.

This option can be enabled either by specifying --extraterse or simply -T on the command line (in comparison, the normal terse option is enabled with --terse or -t) before or after the command name. Being a CLI option rather than a command parameter, it is recommended that you specify it before the command name, as the ability to specify asadmin options (like --host) after the command name is technically deprecated syntax from GlassFish.

The autoname option is enabled either by specifying --autoname or -a on the command line before or after the command name. Just like with the extraterse option, this is technically an asadmin option rather than a command parameter so should be specified before the command name - it should however still work if specified after the command name (see examples).

When enabled, this feature allows the create-instance and create-local-instance commands to automatically resolve any name conflicts, or simply generate a name from scratch. When resolving a name conflict, Payara Server will simply append a new name to the existing name, like so: instance1-BamboozledBarracuda. To automatically generate a name for your instance, simply enable the autoname option and omit the name of your instance (example below).

When creating an instance from the admin console, there is a new Auto Name checkbox present, which performs the same function as the autoname CLI option. This checkbox does not currently allow you to generate an instance name from scratch - it simply resolves any name conflicts.

It should be stressed that these options are optional and disabled by default - if you wish to retain the original behaviour of prompting for an instance name or simply refusing to create an instance due to a name conflict, no action is necessary.

Examples

Name conflict resolution:

asadmin --autoname create-instance --node localhost-domain1 instance1    -> instance1 created
asadmin create-instance --node localhost-domain1 --autoname instance1    -> instance1-BemusedCatfish created
asadmin create-instance --node localhost-domain1 instance1    -> command failed: instance name already in use

Name generation:

asadmin -a create-instance --node localhost-domain1    -> BemusedCatfish created
asadmin create-local-instance --node localhost-domain1 --autoname    -> ConfusedCarp created
asadmin create-instance --node localhost-domain1    -> Please enter an instance name: instance1    -> instance1 created
asadmin create-instance --node localhost-domain1    -> Please enter an instance name: instance1  -> command failed: instance name already in use

Extraterse usage:

$INSTANCE_NAME = asadmin create-local-instance --node localhost-domain1 --autoname --extraterse
asadmin start-instance $INSTANCE_NAME
 
$SECOND_INSTANCE_NAME = asadmin -a -T create-local-instance --node localhost-domain1

IMPORTANT NOTES

This brings quite a sweeping change to ALL asadmin commands; the autoname and extraterse options can actually be used with any command:

  • extraterse currently only performs new actions on the create-local-instance and create-instance commands.
  • The extraterse option implicitly enables terse
  • autoname has far-reaching consequences: this option, when enabled, actually allows you to generate names for almost all resources that take a name as its primary parameter (so essentially all create-* commands). For example, you can generate a name for a deployment group in exactly the same way as you would for instances: asadmin -a create-deployment-group. Be aware though that this is simply the name generation part of this feature; the autoname option will only validate that the name is unique and resolve conflicts for the create-instance and create-local-instance commands.

@Pandrex247 Pandrex247 added this to the 5.193 milestone Jul 15, 2019

@Pandrex247

This comment has been minimized.

Copy link
Member Author

commented Jul 15, 2019

Jenkins test please

@Pandrex247
Copy link
Member Author

left a comment

Notes

@@ -445,3 +445,5 @@ clusters.ejbTimers.PageTitle=EJB Timers
clusters.ejbTimers.TimerCountCol=Timer Count

general.serverNameCol=Server Name

autoName=Auto Name

This comment has been minimized.

Copy link
@Pandrex247

Pandrex247 Jul 15, 2019

Author Member

Happy to have suggestions as this isn't necessarily clear

@@ -118,11 +118,6 @@
<artifactId>glassfish-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.main.core</groupId>
<artifactId>kernel</artifactId>

This comment has been minimized.

Copy link
@Pandrex247

Pandrex247 Jul 15, 2019

Author Member

Removed due to refactoring of ActionReporter out of kernel.

@@ -169,6 +169,12 @@
<artifactId>healthcheck-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>

This comment has been minimized.

Copy link
@Pandrex247

Pandrex247 Jul 15, 2019

Author Member

This had a transitive dependency on kernel, which in turn had a dependency on this.

if (commandModel.getModelFor("terse") != null){
options.set("terse", Boolean.toString(programOpts.isTerse()));
}
if (commandModel.getModelFor("extraterse") != null){

This comment has been minimized.

Copy link
@Pandrex247

Pandrex247 Jul 15, 2019

Author Member

This is for allowing you to specify the option after the command name for CLI commands

if (options.containsKey(TERSE)) {
String value = options.getOne(TERSE);

if (isExtraTerse()) {

This comment has been minimized.

Copy link
@Pandrex247

Pandrex247 Jul 15, 2019

Author Member

Extraterse implicitly enables terse.


report.setMessage(nodeList);

Properties extraProperties = new Properties();

This comment has been minimized.

Copy link
@Pandrex247

Pandrex247 Jul 15, 2019

Author Member

I added these before realising I would have to use the dotted names from the get command for the CLI command (create-local-instance). It's still a valid method however of determining the names in use, and it doesn't really hurt to have these in - I'm sure we can use these elsewhere in future.

Happy to remove though and go with dotted names for both commands

CommandRunner commandRunner) {
List<String> instanceNames = new ArrayList<>();

CommandRunner.CommandInvocation listInstancesCommand = commandRunner.getCommandInvocation("list-instances",

This comment has been minimized.

Copy link
@Pandrex247

Pandrex247 Jul 15, 2019

Author Member

See previous comment about why I have two methods of getting names.

"Old-fashioned", "Plain", "Poised", "Precious", "Quaint", "Shiny", "Sparkling", "Spotless", "Stormy",
public class NameGenerator {
// 161 different possible adjectives to describe a fish
protected static final String[] adjectives = new String[]{"Adorable", "Adventurous", "Aggressive", "Alert", "Beautiful",

This comment has been minimized.

Copy link
@Pandrex247

Pandrex247 Jul 15, 2019

Author Member

I made all of these static since we don't really ever need an actual instance of this class (or its new subclasses)

@@ -56,9 +56,9 @@
@Contract
public interface SupplementalCommandExecutor {

public Collection<SupplementalCommand> listSuplementalCommands(String commandName);
public Collection<SupplementalCommand> listSupplementalCommands(String commandName);

This comment has been minimized.

Copy link
@Pandrex247

Pandrex247 Jul 15, 2019

Author Member

(╯°□°)╯︵ ┻━┻

@@ -1,66 +0,0 @@
/*

This comment has been minimized.

Copy link
@Pandrex247

Pandrex247 Jul 15, 2019

Author Member

This class was completely unused - I assume the version of this class in another module is the copy-pasted version of this.

@Pandrex247

This comment has been minimized.

Copy link
Member Author

commented Jul 16, 2019

Jenkins test please

@dmatej

This comment has been minimized.

Copy link
Contributor

commented Jul 22, 2019

Seems it needs to be rebased ...

@Pandrex247 Pandrex247 force-pushed the Pandrex247:PAYARA-3573-Dynamic-Instances branch from 48b97b4 to ba8aae2 Jul 22, 2019

@Pandrex247

This comment has been minimized.

Copy link
Member Author

commented Jul 22, 2019

Had to rebase AND manually copy-paste the conflicting change since git refused to recognise that the NameGenerator class had been moved. Took the chance to make that method more in-line with our coding style.

@Pandrex247

This comment has been minimized.

Copy link
Member Author

commented Jul 25, 2019

Jenkins test please

@MattGill98
Copy link
Member

left a comment

Seems to work quite well, nicely done! Just a couple of semantic comments, then it looks good to me!

@Pandrex247

This comment has been minimized.

Copy link
Member Author

commented Aug 1, 2019

Jenkins test please

@Pandrex247 Pandrex247 merged commit 6d4d0e6 into payara:master Aug 1, 2019

59 checks passed

Payara Quick Build and Test Quick build and test passed!
Details
security/snyk - api/payara-api/pom.xml (payara-ci) No new issues
Details
security/snyk - api/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/admin/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/admingui/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/ant-tasks/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/appclient/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/batch/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/common/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/concurrent/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/connectors/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/core/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/deployment/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/distributions/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/ejb/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/extras/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/featuresets/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/flashlight/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/grizzly/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/ha/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/installer/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/javaee-api/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/jdbc/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/jms/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/load-balancer/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/orb/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/osgi-platforms/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/packager/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/payara-appserver-modules/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/persistence/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/registration/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/resources/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/security/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/tests/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/transaction/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/web/pom.xml (payara-ci) No new issues
Details
security/snyk - appserver/webservices/pom.xml (payara-ci) No new issues
Details
security/snyk - copyright/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/admin/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/cluster/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/common/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/core/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/deployment/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/diagnostics/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/distributions/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/flashlight/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/grizzly/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/hk2/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/osgi-platforms/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/packager/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/payara-modules/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/resources-l10n/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/resources/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/security/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/test-utils/pom.xml (payara-ci) No new issues
Details
security/snyk - nucleus/tests/pom.xml (payara-ci) No new issues
Details
security/snyk - pom.xml (payara-ci) No new issues
Details

@Pandrex247 Pandrex247 deleted the Pandrex247:PAYARA-3573-Dynamic-Instances branch Aug 1, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.