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

Jenkins node helper API #1

Merged
merged 1 commit into from
Mar 15, 2018
Merged

Jenkins node helper API #1

merged 1 commit into from
Mar 15, 2018

Conversation

VermaSh
Copy link
Contributor

@VermaSh VermaSh commented Mar 14, 2018

The class NodeHelper partially addresses feature requests in adoptium/infrastructure#259

  • Add machines to Jenkins: addNewNode()

  • Determine machine stats

    • getCpuCount(String computerName)
    • getLocation(String computerName)
    • getOsPatchLevel(String computerName)
    • getMemory(String computerName)
    • getSpaceLeftInGb(String computerName)
    • getTotalSpace(String computerName)
  • Set machine description based on machine stats

    • Machine stats retrieved from the above functions are used for the description
  • Determine machine capabilities

    • getEndian(String computerName)
    • getOsArch(String computerName)
    • getOsInfo(String computerName)
  • Add labels to nodes based on machine capabilities

    • addLabel(String computerName, String label)
      • Overwrites the labels with the ones in the arguments
      • weekly maintaince job will call this function with labels from the inventory file plus labels returned from constructLabels(String computerName)
    • appendLabel(String computerName, String label)
      • does only an append
  • Other useful functions

    • constructLabels(String computerName)
      • this function returns a string containing the default labels
      • as of right now, it only returns OS, arch and Endian (only if it is ppc running linux)
      • here is a list of labels which have been implemented so far:
        • constructOsLabel(String computerName)
        • constructCPULabel(String computerName)
        • constructMemoryLabel(String computerName)
        • constructEndianLabel(String computerName)
        • constructPlatformLabel(String computerName)
        • constructArchLabel(String computerName)
        • constructKernelLabel(String computerName)
  • Few side notes:

    • computerName: is what the node name on Jenkins
    • getComputer(String computerName)
      • This was created with the intention to have computer name validations in one place.
        At the moment it's very basic but it can be extended to enforce a standardized naming convention

- Add machines to Jenkins:
- Set machine description based on machine stats
- Determine machine capabilities
- Add labels to nodes based on machine capabilities
@VermaSh VermaSh changed the title Initial commit, Jenkins node helper API Jenkins node helper API Mar 14, 2018
@karianna karianna added the enhancement New feature or request label Mar 15, 2018
Copy link
Contributor

@karianna karianna left a comment

Choose a reason for hiding this comment

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

This looks good overall! LMK if you'd like me to merge (would be good if you raised the issues etc so we know what to work on though).


class NodeHelper {

// TODO: Move strings out to a config file
Copy link
Contributor

Choose a reason for hiding this comment

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

Raise an issue for this please.

Copy link
Contributor Author

@VermaSh VermaSh Mar 15, 2018

Choose a reason for hiding this comment

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


String ret = "INVALID_NODE_NAME";

if (newNodeName.length() > 2) { // TODO: Some sort of validation for node names
Copy link
Contributor

Choose a reason for hiding this comment

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

Add an issue for the TODO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

def launcher
) {

String ret = "INVALID_NODE_NAME";
Copy link
Contributor

Choose a reason for hiding this comment

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

ret --> nodeName?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same goes for all usages of 'ret', can replace with more meaningful variable name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using "ret" makes it easier to follow the return variable through a function. As for meaning, the function name, header comments, and function(s) called to update "ret" variable aid in the meaning.

* @return string of labels set on the computer
*/
public String addLabel(String computerName, String label) {
String ret = "addLabel:COMPUTER_NOT_FOUND";
Copy link
Contributor

Choose a reason for hiding this comment

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

ret --> label?

* @return label string
*/
public String constructLabels(String computerName) {
/* Procedure for adding support for new labels
Copy link
Contributor

Choose a reason for hiding this comment

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

Haul comment up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have left that comment inside because it's for anyone who wants to add more functionality to the function. It isn't necessarily needed in the header comment of the function

if (computer != null) {
ret = constructOsLabel(computer.getName());
if (getOsArch(computer.getName()).contains("ppc")
&& getOsKernelInfo(computer.getName()).get(0).equalsIgnoreCase("linux")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could extract this to a helper function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! I'll add it to my next commit


Computer computer = getComputer(computerName);
if (computer != null) {
ret = "hw.hypervisor.";// TODO: finish implementation, get something
Copy link
Contributor

Choose a reason for hiding this comment

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

Add issue in issue tracker

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ret = getAIXOsInfo(computer);
break;
case "zos":
// ret = // TODO: find the command
Copy link
Contributor

Choose a reason for hiding this comment

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

Issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! z/OS version

// ret = // TODO: find the command
// break;
case "mac":
// ret = getMacOsInfo(computer);
Copy link
Contributor

Choose a reason for hiding this comment

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

commented out on purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, wasn't sure if we needed the version number since it is the same as kernel version. I implement it and check it in with the next commit

* this returns an inaccurate result.
* This has to be fixed by the person who did the setup for the virtual
* machines.
* As of right now, we do not know how to fix the bug.
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was actually bad on my part. I haven't had a chance to check this bug on external machines. I'll run tests regarding this on the external machines and open an issue if needed.

@karianna karianna merged commit a2ae656 into adoptium:master Mar 15, 2018
@karianna
Copy link
Contributor

@VermaSh Just wanted to say thanks for opening up those issues - appreciate the admin effort!

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

Successfully merging this pull request may close these issues.

3 participants