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

Add support for OpenNebula as a cloud provider #1450

Merged
merged 6 commits into from
May 5, 2023

Conversation

nilsding
Copy link
Contributor

What this PR does / why we need it:

This PR adds support for OpenNebula as a cloud provider. Similar to OpenStack it can be hosted on your own infrastructure.

We're using OpenNebula for many years already, and adding (basic?) support for it seemed to be easy enough.

What type of PR is this?
/kind feature

Special notes for your reviewer:
I'm not too fond of GoLang, so if there's anything that's not idiomatic please point it out.

Also I would still like to figure out automated end-to-end tests, any support with that is welcome. I tested it manually on a small kubernetes cluster (just some basic creation of the VMs) and it seems to work fine so far.

Does this PR introduce a user-facing change? Then add your Release Note here:

Add support for OpenNebula as a cloud provider

Documentation:

TBD

(?)

@kubermatic-bot kubermatic-bot added kind/feature Categorizes issue or PR as related to a new feature. docs/tbd Denotes a PR that needs documentation (change) that will be done later. release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. sig/cluster-management Denotes a PR or issue as being assigned to SIG Cluster Management. sig/osm Denotes a PR or issue as being assigned to SIG OSM. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 29, 2022
@kubermatic-bot
Copy link
Contributor

Hi @nilsding. Thanks for your PR.

I'm waiting for a kubermatic member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kubermatic-bot kubermatic-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 29, 2022
@kubermatic-bot kubermatic-bot added dco-signoff: no Denotes that at least one commit in the pull request doesn't have a valid DCO signoff message. and removed dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. labels Nov 16, 2022
@kubermatic-bot kubermatic-bot added dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. and removed dco-signoff: no Denotes that at least one commit in the pull request doesn't have a valid DCO signoff message. labels Nov 16, 2022
Signed-off-by: Georg Gadinger <nilsding@nilsding.org>
Signed-off-by: Georg Gadinger <nilsding@nilsding.org>
Signed-off-by: Georg Gadinger <nilsding@nilsding.org>
@akurz
Copy link

akurz commented Apr 25, 2023

Hi,

we (adidas Runtastic) are testing this provider now for some month in some small user-clusters and it works fine for us. A review and approval would be much aprechiated @xrstf or @ahmedwaleedmalik - Thanks in advance!

Cheers,
Andreas

Copy link
Member

@embik embik left a comment

Choose a reason for hiding this comment

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

Overall this looks good, just a few comments that I think could be addressed.

Comment on lines 997 to 998
fmt.Sprintf("<< YOUR_DATASTORE_NAME >>=%s", oneDatastore),
fmt.Sprintf("<< YOUR_NETWORK_NAME >>=%s", oneNetwork),
Copy link
Member

Choose a reason for hiding this comment

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

Would it be an option to also prefix these with ONE_ instead of YOUR_, so we know that these variable belong to OpenNebula setups?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, can do :)

vcpu: 2
memory: 1024

image: "<< OS_IMAGE >>"
Copy link
Member

Choose a reason for hiding this comment

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

similar to the other comment, can we maybe make sure that this is prefixed to be specific for OpenNebula? e.g. ONE_OS_IMAGE? This way we can avoid collision with the OpenStack image reference.

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 think I'll rename this to ONE_IMAGE then, as OS_ is the prefix for OpenStack

.gitignore Show resolved Hide resolved
// create VM from the generated template above
vmID, err := controller.VMs().Create(tpl.String(), false)
if err != nil {
return nil, err
Copy link
Member

@embik embik Apr 25, 2023

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 helpful to contextualise the error message returned by the upstream SDK here, e.g. with this:

Suggested change
return nil, err
return nil, fmt.Errorf("failed to create VM: %w", err)


vm, err := controller.VM(vmID).Info(false)
if err != nil {
return nil, err
Copy link
Member

Choose a reason for hiding this comment

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

Same here. I'm not exactly sure what this does, but the error should probably look something like this:

Suggested change
return nil, err
return nil, fmt.Errorf("failed to fetch VM information: %w", err)

client := getClient(c)
controller := goca.NewController(client)

vmctrl := controller.VM(instance.(*openNebulaInstance).vm.ID)
Copy link
Member

@embik embik Apr 25, 2023

Choose a reason for hiding this comment

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

I have to say I'm not a huge fan of the type assertions here and later in the code since it can introduce run-time panics. I understand it's required to get the OpenNebula specific information, but e.g. the AWS provider implements a private version of get to return the provider-specific instance, which in turn is then called by the public Get interface implementation:

func (p *provider) get(ctx context.Context, machine *clusterv1alpha1.Machine) (*awsInstance, error) {

Have you considered that approach, so you can get the actual instance type you need here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this hasn't come across my mind, will try to adapt this then.

Copy link
Contributor Author

@nilsding nilsding left a comment

Choose a reason for hiding this comment

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

thanks for the initial review :)

.gitignore Show resolved Hide resolved
Comment on lines 997 to 998
fmt.Sprintf("<< YOUR_DATASTORE_NAME >>=%s", oneDatastore),
fmt.Sprintf("<< YOUR_NETWORK_NAME >>=%s", oneNetwork),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, can do :)

vcpu: 2
memory: 1024

image: "<< OS_IMAGE >>"
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 think I'll rename this to ONE_IMAGE then, as OS_ is the prefix for OpenStack

client := getClient(c)
controller := goca.NewController(client)

vmctrl := controller.VM(instance.(*openNebulaInstance).vm.ID)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this hasn't come across my mind, will try to adapt this then.

Signed-off-by: Georg Gadinger <nilsding@nilsding.org>
Signed-off-by: Georg Gadinger <nilsding@nilsding.org>
@embik
Copy link
Member

embik commented May 2, 2023

/ok-to-test

@kubermatic-bot kubermatic-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 2, 2023
@embik
Copy link
Member

embik commented May 2, 2023

@nilsding please address the linter issues as well. The PR should be good to go afterwards.

Signed-off-by: Georg Gadinger <nilsding@nilsding.org>
@nilsding nilsding requested a review from embik May 5, 2023 07:54
Copy link
Member

@embik embik left a comment

Choose a reason for hiding this comment

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

/approve

@kubermatic-bot kubermatic-bot added the lgtm Indicates that a PR is ready to be merged. label May 5, 2023
@kubermatic-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 457cb4afe9416faa791b8155ae0674826563b67b

@kubermatic-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: embik, nilsding

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

@kubermatic-bot kubermatic-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 5, 2023
@embik
Copy link
Member

embik commented May 5, 2023

Thank you for your contribution, @nilsding!

@embik
Copy link
Member

embik commented May 5, 2023

/retest

@kubermatic-triage-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs

Review the full test history

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

3 similar comments
@kubermatic-triage-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs

Review the full test history

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@kubermatic-triage-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs

Review the full test history

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@kubermatic-triage-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs

Review the full test history

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@kubermatic-bot kubermatic-bot merged commit c92595c into kubermatic:main May 5, 2023
eiabea pushed a commit to anexia-it/machine-controller that referenced this pull request May 8, 2023
* add cloud provider for opennebula

Signed-off-by: Georg Gadinger <nilsding@nilsding.org>

* use a flatcar image in example opennebula machinedeployment

Signed-off-by: Georg Gadinger <nilsding@nilsding.org>

* opennebula: update function signatures to include logger

Signed-off-by: Georg Gadinger <nilsding@nilsding.org>

* opennebula: update after review

Signed-off-by: Georg Gadinger <nilsding@nilsding.org>

* opennebula: add SET_HOSTNAME to context

Signed-off-by: Georg Gadinger <nilsding@nilsding.org>

* opennebula: fix lints

Signed-off-by: Georg Gadinger <nilsding@nilsding.org>

---------

Signed-off-by: Georg Gadinger <nilsding@nilsding.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. docs/tbd Denotes a PR that needs documentation (change) that will be done later. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cluster-management Denotes a PR or issue as being assigned to SIG Cluster Management. sig/osm Denotes a PR or issue as being assigned to SIG OSM. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants