Skip to content

feat: Nutanix VM image preflight check #1130

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

Merged
merged 12 commits into from
Jun 17, 2025

Conversation

dlipovetsky
Copy link
Contributor

@dlipovetsky dlipovetsky commented May 20, 2025

What problem does this PR solve?:
Implements a preflight check that verifies the Nutanix VM images referenced by the Cluster spec.

The VM IMages check reads various various topology variables, and I have defined a pseudo-check that intializes the variables from the Cluster spec.

The VM Images check also uses a Prism Central API client. I have defined a pseudo-check that initializes this client.

Which issue(s) this PR fixes:
Fixes #

How Has This Been Tested?:

Special notes for your reviewer:

Stacked on #1129

I am working on unit tests. The Nutanix client is difficult to mock, so creating the tests is taking more time than I expected.

@dlipovetsky dlipovetsky force-pushed the dlipovetsky/preflight-nutanix-vmimage branch from 4780b5f to 265a77a Compare May 20, 2025 23:59
@dlipovetsky dlipovetsky marked this pull request as draft May 21, 2025 23:52
@dlipovetsky dlipovetsky force-pushed the dlipovetsky/preflight-nutanix-vmimage branch 4 times, most recently from fb9d8a1 to f0cb9f8 Compare June 3, 2025 17:30
@dlipovetsky dlipovetsky marked this pull request as ready for review June 3, 2025 23:14
@jimmidyson
Copy link
Member

Preflight failures work nicely! Not sure it's what we want here but at least it works!

ImageLookup is not yet supported

@dlipovetsky
Copy link
Contributor Author

dlipovetsky commented Jun 4, 2025

The Nutanix e2e test is failing because it uses imageLookup, and the check does not yet support that. I'm working on it.

Update: I will add support for imageLookup in a separate PR. For now, we will allow it with a warning.

> kubectl create --dry-run=server -f test-cluster.yaml
Warning: cluster.spec.topology.workers.machineDeployments[.name=md-0].variables[.name=workerConfig].value.nutanix.machineDetails uses imageLookup, which is not yet supported by checks
cluster.cluster.x-k8s.io/dlag created (server dry run)

@dlipovetsky
Copy link
Contributor Author

dlipovetsky commented Jun 11, 2025

From @yanhua121: If the credential check fails, failures from other checks are just noise. Can we exclude them?

Update: Addressed in 7cc0676

@dlipovetsky dlipovetsky force-pushed the dlipovetsky/preflight-nutanix-vmimage branch from 98103a7 to a1a08d3 Compare June 11, 2025 23:02
Copy link
Contributor

@dkoshkin dkoshkin left a comment

Choose a reason for hiding this comment

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

Looking good, had a question on the clients.

dkoshkin
dkoshkin previously approved these changes Jun 12, 2025
Copy link
Contributor

@dkoshkin dkoshkin left a comment

Choose a reason for hiding this comment

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

Thanks!

@dlipovetsky dlipovetsky force-pushed the dlipovetsky/preflight-nutanix-vmimage branch from 6ab50f2 to 93299d2 Compare June 13, 2025 20:32
@jimmidyson
Copy link
Member

jimmidyson commented Jun 16, 2025

I'm wondering why we are doing this in here rather than in CAPX? Sorry if this has been discussed before! EDIT: Ah yes because we're validating the variable value rather than the rendered cluster resource to prevent invalid data being persisted.

Base automatically changed from dlipovetsky/preflight-checks-framework to main June 17, 2025 15:20
@dlipovetsky dlipovetsky dismissed dkoshkin’s stale review June 17, 2025 15:20

The base branch was changed.

@github-actions github-actions bot added feature and removed feature labels Jun 17, 2025
@dlipovetsky dlipovetsky force-pushed the dlipovetsky/preflight-nutanix-vmimage branch from 93299d2 to 365033c Compare June 17, 2025 15:47
Copy link
Contributor

Automated PR Comment From Black Duck SCA

❌ Found dependencies violating policy!

Policies Violated Dependency License(s) Vulnerabilities Short Term Recommended Upgrade Long Term Recommended Upgrade Resolved / Filtered Out
Unknown github.com/samber/lo (github.com/samber/lo:v1.51.0) Unknown License

@dlipovetsky
Copy link
Contributor Author

Neither of the two failing checks failed before...

@dlipovetsky
Copy link
Contributor Author

dlipovetsky commented Jun 17, 2025

Blackduck is giving a false negative here.

github.com/samber/lo has had an MIT license since its initial commit.

And it has the same license in the v1.51.0 tag: https://github.com/samber/lo/blob/v1.51.0/LICENSE

(For reference, the dependency was changed by #1160, and the Blackduck scan also failed for the same reason there)

Allow imageLookup with warning
Mock nutanix clients to allow unit tests
* Refactor nutanixChecker to allow unit tests of all checks.
* Add unit tests.
* Fix field reported when spec init for worker spec fails.
* Fix handling of credentials "Insecure" option.
* Use lowercase 'v' in errors that refers to the Nutanix client
Run VM Image check only if Nutanix clients are initialized. This avoids returning errors that are not actionable. The user will see an error from the credentials check only.
Merge separate v3 and v4 clients into one
Refactor to simplify, and remove need to checker factory.
@dlipovetsky dlipovetsky force-pushed the dlipovetsky/preflight-nutanix-vmimage branch from 97075a2 to ed9b787 Compare June 17, 2025 20:05
@dlipovetsky
Copy link
Contributor Author

Rebased because #1164 merged.

@dlipovetsky dlipovetsky merged commit 35fd169 into main Jun 17, 2025
22 of 23 checks passed
@dlipovetsky dlipovetsky deleted the dlipovetsky/preflight-nutanix-vmimage branch June 17, 2025 20:33
supershal added a commit that referenced this pull request Jun 24, 2025
🤖 I have created a release *beep* *boop*
---


## 0.30.0 (2025-06-24)

<!-- Release notes generated using configuration in .github/release.yaml
at main -->

## What's Changed
### Exciting New Features 🎉
* feat: Build with Go 1.24.4 to fix CVEs by @jimmidyson in
#1157
* feat: add requests and limits to registry containers by @dkoshkin in
#1158
* feat: Add preflight checks framework by @dlipovetsky in
#1129
* feat: Preflight check opt-out by @dlipovetsky in
#1156
* feat: Nutanix VM image preflight check by @dlipovetsky in
#1130
* feat: update addons by @dkoshkin in
#1168
* feat: Enforce MD replicas within cluster autoscaler bounds by
@jimmidyson in
#1169
* feat(preflight): Storage container checks for Nutanix by
@thunderboltsid in
#1136
* feat: update Nutanix CSI to 3.3.4 by @dkoshkin in
#1179
### Fixes 🔧
* fix: update CNCF registry version to 2.3.4, app version 2.8.3 by
@dkoshkin in
#1150
* fix: registry addon headless service port by @dkoshkin in
#1159
* fix: preserve registry addon root CA on move by @dkoshkin in
#1155
* fix: Add noderegistration patch to previous handler by @jimmidyson in
#1177
### Other Changes
* build: include regclient/regsync image for registry addon by @dkoshkin
in
#1148
* test: Add update test helpers by @jimmidyson in
#1162
* test(e2e): Nutanix 1.33.1 testing by @jimmidyson in
#1164
* build: Update all tools by @jimmidyson in
#1165
* refactor: add global feature.Gates variable by @dkoshkin in
#1167
* ci: new env variable to set --feature-gates by @dkoshkin in
#1166
* build: github.com/hashicorp/go-retryablehttp@v0.7.8 to fix CVE by
@jimmidyson in
#1170
* docs: Update link to default Cilium values in cni.md by
@yannickstruyf3 in
#1173
* docs: Fix up Cilium config link (again) & icons by @jimmidyson in
#1176

## New Contributors
* @yannickstruyf3 made their first contribution in
#1173

**Full Changelog**:
v0.29.0...v0.30.0

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Shalin Patel <shalin.patel@nutanix.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants