Skip to content

Conversation

@caseywilliams
Copy link
Contributor

Outside of AIX, the data in the lparstat source was left uninitialized;
This caused false positives for LPAR/WPAR on power8 machines.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 91.146% when pulling 170038c on caseywilliams:lparstat-power8 into f43c12f on puppetlabs:master.

{
if (!data_) {
data_.reset(new lparstat_data);
data_.reset(new lparstat_data {"", 0, 0, 0});
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to just give lparstat_data a proper constructor, so that it is always correctly initialized

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 91.152% when pulling 2504c83 on caseywilliams:lparstat-power8 into f43c12f on puppetlabs:master.

@geoffnichols geoffnichols requested a review from ekinanp November 1, 2017 17:14
REQUIRE(lparstat_source.wpar_configured_id() == 1);
}

WHEN("An lparstat executable is available but this is not an AIX machine") {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test looks like it's just making sure that the lparstat data is initialized correctly. I'd change the name to indicate that.

Copy link
Contributor

@ekinanp ekinanp left a comment

Choose a reason for hiding this comment

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

The feature changes LGTM. Only suggestion I have is for the tests. Looking at how the detector tests are structured, it seems like we determine whether something runs inside LPAR/WPAR or outside LPAR/WPAR from just oslevel's output. But the detector functions look at partition_number (for LPAR) and wpar_key (for WPAR) to detect those hypervisors -- something that lparstat displays, not oslevel. So my suggestion would be to make oslevel valid for both those tests, but change the lparstat output to something invalid. Then in the lparstat source tests, I'd maybe add some tests that indicates "If we're on an AIX machine and lparstat is available, we collect its information" and "If we are not on an AIX machine and lparstat is available, we don't collect anything".

@caseywilliams
Copy link
Contributor Author

@ekinanp as I understand it, WPARs were introduced in AIX 6.1; If you try to run lparstat -W, (-W is the flag to include the WPAR information along with the LPAR information) pre-6.1, the command errors, so we need to check the oslevel before trying that. If you check out the lparstat source implementation, it checks and stores the oslevel output first to determine which flags to use, then calls lparstat after that - I think that's valid, but I may be misreading your comment, too. I'll push an update in just a second with updates to make the tests clearer.

@ekinanp
Copy link
Contributor

ekinanp commented Nov 1, 2017

@caseywilliams Yes, but those details (checking oslevel, making sure it is > 6.1 for WPAR) are in the lparstat source, not the detectors. The detectors are only concerned with some parts of what the source returns (partition_number and wpar_key for LPAR and WPAR, respectively) when it comes to hypervisor detection after the source is done processing its information. That is why I suggest adding the oslevel specific tests in the lparstat source tests, and keep the detector tests focused on just lparstat related stuff (think of it as "mocking out" the lparstat source, if that makes sense).

@caseywilliams
Copy link
Contributor Author

@ekinanp oh! I was looking in the wrong place - you're right, that could be clearer - I'll change it

}

WHEN("An lparstat executable is available but this is not an AIX machine") {
THEN("the source does not attempt to collect any data and empty values are correctly initialized") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this is much clearer. Thanks.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 91.192% when pulling fe97485 on caseywilliams:lparstat-power8 into f43c12f on puppetlabs:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 91.282% when pulling 8a9c091 on caseywilliams:lparstat-power8 into f43c12f on puppetlabs:master.

}
}

WHEN("WPAR information is available") {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd probably change the structure to something like:

WHEN("LPAR information is available") {
  WHEN("WPAR information is unavailable") {
  }
  WHEN("WPAR information is available") {
  }
}

because you check the lpar information in both cases anyways.

}
}

WHEN("Running outside of an LPAR but `lparstat` is available") {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd change these to:

WHEN("Running on a non-AIX machine") {
   THEN("the result is not valid") {
   }
}

WHEN("Running on an AIX machine") {
    WHEN("lparstat is available") {
        THEN(...)
    }
    WHEN("lparstat is unavailable") {
        THEN(...)
    }
}

makes it clearer that these detectors only make sense for AIX machines.

}
}

WHEN("Running outside of a WPAR but `lparstat` is available") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same idea as my comment above for the lpar detector.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 91.488% when pulling f318da5 on caseywilliams:lparstat-power8 into f43c12f on puppetlabs:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 91.42% when pulling 4f3243d on caseywilliams:lparstat-power8 into f43c12f on puppetlabs:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.5%) to 91.457% when pulling 07fd21c on caseywilliams:lparstat-power8 into f43c12f on puppetlabs:master.

Copy link
Contributor

@ekinanp ekinanp left a comment

Choose a reason for hiding this comment

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

Nice! I have only one comment.

WHEN("Running inside a WPAR") {
lparstat_fixture lparstat_source {"7.1.0.0", "output/lparstat/wpar.txt"};
WHEN("Running on AIX") {
WHEN("Running inside an LPAR") {
Copy link
Contributor

@ekinanp ekinanp Nov 2, 2017

Choose a reason for hiding this comment

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

Do you think the LPAR WHEN is necessary? i.e. Does it have to run under LPAR for it to run inside WPAR or can it run inside WPAR independently of LPAR? If it's the latter, it might be helpful to remove the WHEN("Running inside an LPAR") part so that someone looking at this won't think that WPAR has to be in LPAR.

Outside of AIX, the data in the lparstat source was left uninitialized;
This caused false positives for LPAR/WPAR on power8 machines.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 91.445% when pulling 204db80 on caseywilliams:lparstat-power8 into f43c12f on puppetlabs:master.

@ekinanp ekinanp merged commit 32a9af0 into puppetlabs:master Nov 2, 2017
@caseywilliams caseywilliams deleted the lparstat-power8 branch November 7, 2017 12:30
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.

5 participants