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 NetworkConfigurations to VSphereFailureDomain #3049

Merged
merged 4 commits into from
Nov 13, 2024

Conversation

Nutrymaco
Copy link
Contributor

@Nutrymaco Nutrymaco commented Jun 10, 2024

What this PR does / why we need it:
This PR adds additional API to Failure Domain. This allows to have different configurations based on the selected region/zone.

(Edited by chrischdi)
User stories:

  • As a user I would like to define network configuration for machines, which differs per failure domain.
  • As a user I would like to define a different value for VSphereMachines .spec.template field per failure domain.

(end of Edit by chrischdi)

Which issue(s) this PR fixes
Partially it repeats work that was done for issue #1964 in #1967. But also allows overriding VM template.

Copy link

linux-foundation-easycla bot commented Jun 10, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jun 10, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @Nutrymaco!

It looks like this is your first PR to kubernetes-sigs/cluster-api-provider-vsphere 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-provider-vsphere has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 10, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @Nutrymaco. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jun 10, 2024
@chrischdi
Copy link
Member

/ok-to-test

Do I get it right that the use cases are:

  • As a user I would like to define network configuration for machines, which differs per failure domain.
  • As a user I would like to define a different value for VSphereMachines .spec.template field per failure domain.

@k8s-ci-robot k8s-ci-robot 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 Jun 13, 2024
@Nutrymaco
Copy link
Contributor Author

/ok-to-test

Do I get it right that the use cases are:

  • As a user I would like to define network configuration for machines, which differs per failure domain.
  • As a user I would like to define a different value for VSphereMachines .spec.template field per failure domain.

Yes

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 14, 2024
@chrischdi
Copy link
Member

chrischdi commented Jun 17, 2024

Question: does it make sense to have the full network definition, or is it enought only have the one originally introduced (and not used) here:

type Network struct {
// Name is the network name for this machine's VM.
Name string `json:"name,omitempty"`
// DHCP4 is a flag that indicates whether or not to use DHCP for IPv4
// +optional
DHCP4 *bool `json:"dhcp4,omitempty"`
// DHCP6 indicates whether or not to use DHCP for IPv6
// +optional
DHCP6 *bool `json:"dhcp6,omitempty"`
}

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

Sorry for questioning this now and not earlier. But because this is changing APIs we should be careful to only add/change when we think its a long-term commitment because we have to maintain and support it then for a long time.

Question: what is the reasoning behind wanting to overwrite the template of a machine? Why can't it stay the same?

A substantial part of a MachineDeployment is being able to have the same machine multiple times. Could you please explain the actual use-case where this comes from?

Maybe it helps to split up this discussion from the networking part and maybe also handle them as separate Issues/Pull Requests.

apis/v1beta1/vspherefailuredomain_types.go Outdated Show resolved Hide resolved
@Nutrymaco
Copy link
Contributor Author

Nutrymaco commented Jun 17, 2024

Sorry for questioning this now and not earlier. But because this is changing APIs we should be careful to only add/change when we think its a long-term commitment because we have to maintain and support it then for a long time.

Question: what is the reasoning behind wanting to overwrite the template of a machine? Why can't it stay the same?

A substantial part of a MachineDeployment is being able to have the same machine multiple times. Could you please explain the actual use-case where this comes from?

Maybe it helps to split up this discussion from the networking part and maybe also handle them as separate Issues/Pull Requests.

Yes, let's discuss it in different issue. I'll remove template related changes.

@Nutrymaco
Copy link
Contributor Author

Question: does it make sense to have the full network definition, or is it enought only have the one originally introduced (and not used) here:

type Network struct {
// Name is the network name for this machine's VM.
Name string `json:"name,omitempty"`
// DHCP4 is a flag that indicates whether or not to use DHCP for IPv4
// +optional
DHCP4 *bool `json:"dhcp4,omitempty"`
// DHCP6 indicates whether or not to use DHCP for IPv6
// +optional
DHCP6 *bool `json:"dhcp6,omitempty"`
}

We at least need addressesFromPools, so this struct does not fit

@Nutrymaco
Copy link
Contributor Author

@chrischdi @killianmuldoon
What can i do to make this PR move forward?

@chrischdi
Copy link
Member

cc @lubronzhan , @neolit123 , this is a change to the govmomi API types :-)

Can you maybe take a look if you think they make sense on a high level first?

Copy link
Member

@neolit123 neolit123 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 PR.
added a few comments.

apis/v1beta1/vspherefailuredomain_types.go Outdated Show resolved Hide resolved
apis/v1beta1/vspherefailuredomain_types.go Outdated Show resolved Hide resolved
apis/v1beta1/vspherefailuredomain_types.go Outdated Show resolved Hide resolved
continue
}
if _, err := deploymentZoneCtx.AuthSession.Finder.Network(ctx, networkConfig.NetworkName); err != nil {
conditions.MarkFalse(deploymentZoneCtx.VSphereDeploymentZone, infrav1.VSphereFailureDomainValidatedCondition, infrav1.NetworkNotFoundReason, clusterv1.ConditionSeverityError, "network %s is misconfigured", networkConfig.NetworkName)
Copy link
Member

Choose a reason for hiding this comment

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

is the network not found rather than misconfigured in such a scenario?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like it's copied from the original network config without failure domain. Could you update both places?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated both

device.NetworkName = network
}

func mergeFailureDomainNetSpecToNetworkDeviceSpec(device *infrav1.NetworkDeviceSpec, fd infrav1.NetworkConfiguration) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func mergeFailureDomainNetSpecToNetworkDeviceSpec(device *infrav1.NetworkDeviceSpec, fd infrav1.NetworkConfiguration) {
func mergeNetworkConfigurationInNetworkDeviceSpec(device *infrav1.NetworkDeviceSpec, fd infrav1.NetworkConfiguration) {

more of a question whether having the types in the function makes more sense?
and on that note should fd be replaced with something like nc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed names as suggested. If you mean types in function name, i don't see other choice due to lack of overloading in go.

@lubronzhan
Copy link
Contributor

lubronzhan commented Jul 18, 2024

Should the Network be marked as deprecated in favor of the new NetworkConfiguration?

In general LGTM

Comment on lines 25 to 32
if len(in.NetworkConfigurations) > 0 {
networks := make([]string, len(in.NetworkConfigurations))
for i := range in.NetworkConfigurations {
networks[i] = in.NetworkConfigurations[i].NetworkName
}
out.Networks = networks
}
return nil
Copy link
Member

Choose a reason for hiding this comment

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

I think we should not convert it from a different struct in v1alpha3 to v1beta1 (same for v1alpha4), because it would cause different results when forward and backwards converting.

We should use it as new additional field because we already have the networks element also in v1beta1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced with the generated conversion

@lubronzhan
Copy link
Contributor

Sorry for the late reply, overall lgtm

@Nutrymaco
Copy link
Contributor Author

Hi, @chrischdi !
Any estimate on when PR can be merged?

internal/webhooks/vspherefailuredomain.go Outdated Show resolved Hide resolved
internal/webhooks/vspherefailuredomain.go Outdated Show resolved Hide resolved
apis/v1alpha3/zz_generated.conversion.go Show resolved Hide resolved
@chrischdi
Copy link
Member

That should be the final steps :-)

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 23, 2024
@Nutrymaco
Copy link
Contributor Author

@chrischdi
Fixed your comments. Did you have a chance to look?

apis/v1beta1/vspherefailuredomain_types.go Outdated Show resolved Hide resolved
apis/v1beta1/vspherefailuredomain_types.go Outdated Show resolved Hide resolved
internal/webhooks/vspherefailuredomain.go Outdated Show resolved Hide resolved
internal/webhooks/vspherefailuredomain.go Outdated Show resolved Hide resolved
pkg/services/vimmachine.go Outdated Show resolved Hide resolved
pkg/services/vimmachine.go Outdated Show resolved Hide resolved
pkg/services/vimmachine_test.go Outdated Show resolved Hide resolved
pkg/services/vimmachine_test.go Outdated Show resolved Hide resolved
@sbueringer
Copy link
Member

@Nutrymaco just a few smaller findings from my side

@sbueringer
Copy link
Member

I'll take another look once tests and linter are back to green

@sbueringer sbueringer added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Nov 13, 2024
@sbueringer
Copy link
Member

/test pull-cluster-api-provider-vsphere-e2e-vcsim-govmomi-main
/test pull-cluster-api-provider-vsphere-e2e-vcsim-supervisor-main

@sbueringer
Copy link
Member

sbueringer commented Nov 13, 2024

Thank you very much!

/lgtm

Will merge once all e2e tests are completed & green

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 13, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 8f254d42426a20bf548cb025fdf428fc517ca8c8

@sbueringer
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 13, 2024
@k8s-ci-robot k8s-ci-robot merged commit a80b417 into kubernetes-sigs:main Nov 13, 2024
13 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.12 milestone Nov 13, 2024
@sbueringer sbueringer changed the title ✨ Add NetworkConfigurations, VMTemplate to FailureDomain ✨ Add NetworkConfigurations to VSphereFailureDomain Nov 13, 2024
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", 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. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants