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

API to autocreate subnets for external hosts #10621

Merged
merged 1 commit into from
Oct 12, 2016

Conversation

rajatchopra
Copy link
Contributor

@rajatchopra rajatchopra commented Aug 25, 2016

One can now allocate hostsubnets for hosts that are not part of the cluster. This is useful when a host wants to be part of the SDN, but not part of the cluster (e.g. F5)
Trello: https://trello.com/c/fnW1tPCY/155-8-f5-integration-get-lease-from-cluster-cidr

Implementation details:

  1. Allow creation of a hostsubnet resource without the 'subnet' field being present. But only if a specific annotation exists ('hostsubnet.sdn.openshift.io/autocreate').
  2. Let the master also watch hostsubnets, but only bother with the ones that have the annotation. The rest of them are also created by master, but by watching nodes.
  3. When the master learns about a hostsubnet being created with the annotation, it allocates a subnet of the clusterNetwork IPAM, deletes the annotated hostsubnet and recreates a new one with the assigned subnet.

The deletion and recreation have been done so that migration of existing infrastructure can go on smoothly. Even if one were to update master and not the nodes, and add an F5 machine in the middle, no issues should appear.

@rajatchopra
Copy link
Contributor Author

@pravisankar Thanks for the help. Please take a look.
cc @openshift/networking

PS: This is for 3.4 release. So do not merge before the 1.3 has been cut.

@@ -87,7 +87,10 @@ func ValidateHostSubnet(hs *sdnapi.HostSubnet) field.ErrorList {

_, _, err := net.ParseCIDR(hs.Subnet)
if err != nil {
allErrs = append(allErrs, field.Invalid(field.NewPath("subnet"), hs.Subnet, err.Error()))
// check if annotation exists, then let the Subnet field be empty
if _, ok := hs.Annotations["hostsubnet.sdn.openshift.io/autocreate"]; !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not make this an actual field?

Choose a reason for hiding this comment

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

This annotation is mainly to address F5 use case. We use actual fields for generic use cases?

Copy link

@pravisankar pravisankar Aug 25, 2016

Choose a reason for hiding this comment

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

When this annotation/field is set, ensure Subnet field is empty?

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 am in favour of an actual field. Will be easy to identify such hostsubnets easily post creation too. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

We use actual fields for generic use cases?

at the point where API-level validation is using the data, it should probably be a field rather than an annotation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then it makes me against the field idea here. This is not a useful field at runtime, its merely a direction at create time.

@pravisankar
Copy link

In SubnetStartMaster(), you need to ignore HostSubnets that doesn't have populated Subnet field.

}

if _, ok := hs.Annotations["hostsubnet.sdn.openshift.io/autocreate"]; ok {
err = master.registry.DeleteSubnet(name)

Choose a reason for hiding this comment

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

Add a comment on why we are doing delete+create subnet instead of update subnet.

@knobunc knobunc changed the title API to create autocreate subnets for external hosts API to create autocreate subnets for external hosts [DO NOT MERGE] Aug 25, 2016
@danwinship
Copy link
Contributor

  1. Allow creation of a hostsubnet resource without the 'subnet' field being present. But only if a specific annotation exists ('hostsubnet.sdn.openshift.io/autocreate').

Why not just drop the annotation, and say people with HostSubnet-creating permission can always create HostSubnets-without-Subnet-fields, and the master will always then fill in the missing field?

deletes the annotated hostsubnet and recreates a new one with the assigned subnet.

Why does it do this rather than just update the existing one?

@rajatchopra
Copy link
Contributor Author

Fixed the issues in feedback.
@danwinship We could drop the annotation and be permissive in allowing that hostsubnets be created without subnet being defined. The annotation method just makes it more explicit with respect to the intent. It will prevent the accidental case of subnet gone missing in another case.

Also, added a comment about why a delete+create is done instead of an update. The only reason is to avoid migration issues. The node side watchSubnets skips the actual planting of OVS rules if the hostsubnet was modified but the host name remains the same.

@pravisankar
Copy link

LGTM, update docs about this feature?

@rajatchopra
Copy link
Contributor Author

Yes, docs need to be updated. But, kind of a half story right now without the F5 use case. The complete F5 native-vxlan thing is coming in another PR, so probably a doc when that is ready. Thanks for the feedback.

@rajatchopra rajatchopra changed the title API to create autocreate subnets for external hosts [DO NOT MERGE] API to autocreate subnets for external hosts Sep 1, 2016
@@ -87,7 +88,10 @@ func ValidateHostSubnet(hs *sdnapi.HostSubnet) field.ErrorList {

_, _, err := net.ParseCIDR(hs.Subnet)
if err != nil {
allErrs = append(allErrs, field.Invalid(field.NewPath("subnet"), hs.Subnet, err.Error()))
// check if annotation exists, then let the Subnet field be empty
if _, ok := hs.Annotations[sdnplugin.AssignHostSubnetAnnotation]; !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

this isn't just allowing the subnet field to be empty, it's allowing it to be invalid... that's not what we want is it?

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 this. The check is made only on empty field.

@rajatchopra rajatchopra force-pushed the f5 branch 2 times, most recently from 081564b to 75940fd Compare September 23, 2016 00:34
@rajatchopra
Copy link
Contributor Author

Refactored with feedback and the restructure from eventQueue to DeltaFifo

@knobunc
Copy link
Contributor

knobunc commented Sep 23, 2016

[test]

Copy link
Contributor

@danwinship danwinship left a comment

Choose a reason for hiding this comment

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

LGTM other than one comment nit

@@ -240,6 +241,41 @@ func (node *OsdnNode) initSelfSubnet() error {
return nil
}

// Only run on the master
// Watch for all hostsubnet events and if one is found with the right annotation, use the IPAM to dole a real subnet
Copy link
Contributor

@danwinship danwinship Sep 28, 2016

Choose a reason for hiding this comment

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

"use the subnet allocator" not "use the IPAM". "IPAM" refers to assigning IPs to pods, not networks to nodes

Copy link

@pravisankar pravisankar left a comment

Choose a reason for hiding this comment

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

LGTM, fix the comment DanWinship pointed out.

@knobunc
Copy link
Contributor

knobunc commented Sep 29, 2016

[test]

…luster. This is useful when a host wants to be part of the SDN, but not part of the cluster (e.g. F5)
@rajatchopra
Copy link
Contributor Author

rajatchopra commented Oct 1, 2016

re [test]
Flake: #9624

@rajatchopra
Copy link
Contributor Author

re [test]
Flake: #9548 #9490

@knobunc
Copy link
Contributor

knobunc commented Oct 7, 2016

re [test]

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 6926d71

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/9758/)

@danwinship
Copy link
Contributor

[merge]

@knobunc
Copy link
Contributor

knobunc commented Oct 12, 2016

Flake #11315 [merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 6926d71

@openshift-bot
Copy link
Contributor

openshift-bot commented Oct 12, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/9985/) (Base Commit: a5c2619) (Image: devenv-rhel7_5166)

@openshift-bot openshift-bot merged commit 2cd1700 into openshift:master Oct 12, 2016
@rajatchopra rajatchopra deleted the f5 branch October 31, 2016 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants