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, VMTemplate to FailureDomain #3049

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Nutrymaco
Copy link

@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.

  • ✅ login: Nutrymaco / name: Efim Smykov (77a32a0)

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign fabriziopandini for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 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
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
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
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
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
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
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
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

@Nutrymaco Nutrymaco force-pushed the fd-new-api branch 2 times, most recently from b6e9a99 to 7fa4378 Compare July 18, 2024 13:26
@Nutrymaco
Copy link
Author

@chrischdi @lubronzhan @neolit123
I have updated the PR to address your comments, can you take a look?

@Nutrymaco
Copy link
Author

Hi everyone

Just checking in on the status. Is there an estimated timeline for when work on it might continue? Let me know if there’s anything I can do to help move it forward.

Thanks!

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 the long round-trip, busy times...

One addition for the webhook and one more or less question on the API type.

As of that good for me.

apis/v1beta1/vspherefailuredomain_types.go Show resolved Hide resolved
internal/webhooks/vspherefailuredomain.go Show resolved Hide resolved
@chrischdi
Copy link
Member

Also: needs a proper rebase to not have merge commits.

@chrischdi
Copy link
Member

/test help

@k8s-ci-robot
Copy link
Contributor

@chrischdi: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

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

The following commands are available to trigger optional jobs:

  • /test pull-cluster-api-provider-vsphere-apidiff-main

Use /test all to run the following jobs that were automatically triggered:

  • pull-cluster-api-provider-vsphere-apidiff-main
  • pull-cluster-api-provider-vsphere-test-main
  • pull-cluster-api-provider-vsphere-verify-main

In response to this:

/test help

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.

@chrischdi
Copy link
Member

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

@chrischdi
Copy link
Member

/lgtm

cc @lubronzhan @neolit123 @rikatz

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

LGTM label has been added.

Git tree hash: f6886e0604252eff59e2e41883e2baad7defa907

@chrischdi
Copy link
Member

pull-cluster-api-provider-vsphere-e2e-govmomi-main at team-cluster-api#19 are green

@Nutrymaco
Copy link
Author

Hi @chrischdi! When is this pr planned to be merged? Maybe there is something i need to do?

@chrischdi
Copy link
Member

@lubronzhan @neolit123 @rikatz : would be awesome to get another pair of eyes on this :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants