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

Refactoring to fail on vsphere perms validations #6188

Merged
merged 2 commits into from
Jul 17, 2023

Conversation

pokearu
Copy link
Member

@pokearu pokearu commented Jul 17, 2023

Issue #5865:

Description of changes:
Modified to fail on vsphere missing user permissions.

Testing:
Created a user with missing permissions and tested validations. Now the error shows as

2023-07-14T20:09:04.809Z  V3  user ramaliar-test@vsphere.local missing vSphere permissions  {"Permissions": "- username: ramaliar-test@vsphere.local\n  objectType: Network\n  path: /Denver/network/Dev\n  permissions:\n  - VirtualMachine.Interact.PowerOff\n  - VirtualMachine.Interact.PowerOn\n- username: ramaliar-test@vsphere.local\n  objectType: Datastore\n  path: /Denver/datastore/datastore1.1\n  permissions:\n  - VirtualMachine.Interact.PowerOff\n  - VirtualMachine.Interact.PowerOn\n- username: ramaliar-test@vsphere.local\n  objectType: ResourcePool\n  path: /Denver/host/EKS-A/Resources/CI\n  permissions:\n  - VirtualMachine.Interact.PowerOff\n  - VirtualMachine.Interact.PowerOn\n- username: ramaliar-test@vsphere.local\n  objectType: Folder\n  path: /Denver/vm/Dev/capv/ramaliar\n  permissions:\n  - VirtualMachine.Interact.PowerOff\n  - VirtualMachine.Interact.PowerOn\n- username: ramaliar-test@vsphere.local\n  objectType: VirtualMachine\n  path: /Denver/vm/Templates/bottlerocket-v1.25.11-kubernetes-1-25-eks-17-amd64-327823e\n  permissions:\n  - VirtualMachine.Interact.PowerOff\n  - VirtualMachine.Interact.PowerOn\n- username: ramaliar-test@vsphere.local\n  objectType: Folder\n  path: /Denver/vm/Templates\n  permissions:\n  - VirtualMachine.Interact.PowerOff\n  - VirtualMachine.Interact.PowerOn\n"}
2023-07-14T20:09:04.810Z  V0  ❌ Validation failed {"validation": "vsphere Provider setup is valid", "error": "validating vsphere user privileges: user ramaliar-test@vsphere.local missing vSphere permissions", "remediation": ""}

Tested creating a cluster

./eksctl-anywhere create cluster -f ./config.yaml

Documentation added/planned :
Plan to document the change in user experience.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@eks-distro-bot eks-distro-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 17, 2023
@pokearu pokearu added this to the v0.17.0 milestone Jul 17, 2023
@pokearu pokearu added the area/providers/vsphere vSphere provider related issues or feature requests label Jul 17, 2023
@codecov
Copy link

codecov bot commented Jul 17, 2023

Codecov Report

Merging #6188 (c13bb4d) into main (c4c5f73) will decrease coverage by 0.02%.
The diff coverage is 78.57%.

@@            Coverage Diff             @@
##             main    #6188      +/-   ##
==========================================
- Coverage   75.03%   75.01%   -0.02%     
==========================================
  Files         448      448              
  Lines       37040    36971      -69     
==========================================
- Hits        27792    27734      -58     
- Misses       7673     7675       +2     
+ Partials     1575     1562      -13     
Impacted Files Coverage Δ
pkg/providers/vsphere/validator.go 84.95% <78.57%> (+0.19%) ⬆️

... and 13 files with indirect coverage changes

@pokearu pokearu self-assigned this Jul 17, 2023
Copy link
Member

@jonathanmeier5 jonathanmeier5 left a comment

Choose a reason for hiding this comment

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

/lgtm

privs, err = v.getMissingPrivs(ctx, vsc, path, t, privsContent, username)
if err != nil {
return passed, err
return passed, fmt.Errorf("failed to get missing privs: %v", err)
Copy link
Member

@mitalipaygude mitalipaygude Jul 17, 2023

Choose a reason for hiding this comment

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

If this error is something we return to the users, should we be more explicit and say privileges or permissions?

Suggested change
return passed, fmt.Errorf("failed to get missing privs: %v", err)
return passed, fmt.Errorf("failed to get missing privileges: %v", err)

Copy link
Member Author

Choose a reason for hiding this comment

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

ah yes!

@pokearu
Copy link
Member Author

pokearu commented Jul 17, 2023

/approve

@eks-distro-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pokearu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/providers/vsphere vSphere provider related issues or feature requests lgtm size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants