Skip to content

Move the CRDs to MetalLB, step 2#1245

Merged
fedepaol merged 14 commits into
metallb:mainfrom
fedepaol:newcrdsinmetallb
Mar 22, 2022
Merged

Move the CRDs to MetalLB, step 2#1245
fedepaol merged 14 commits into
metallb:mainfrom
fedepaol:newcrdsinmetallb

Conversation

@fedepaol

@fedepaol fedepaol commented Mar 3, 2022

Copy link
Copy Markdown
Member

This is based on #1237 , and is the second part related to what's being proposed in #942

Here we move from the version of CRDs shipped with the operator to the final design.
We still lack a CRD for the communities and a label selector for selecting the addresspool from the L2 and the BGPAdvertisements, which are gonna be added as a next step.

Also, the e2e tests are updated to reflect this new structure.

@fedepaol fedepaol force-pushed the newcrdsinmetallb branch 10 times, most recently from bd9404a to 7a9360b Compare March 8, 2022 11:25

// AddressPoolStatus defines the observed state of AddressPool.
type AddressPoolStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is that a TODO?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's generated by controller-gen, and it was the same in the operator.


// BGPAdvertisementStatus defines the observed state of BGPAdvertisement.
type BGPAdvertisementStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is that a TODO?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's generated by controller-gen, and it was the same in the operator.

Comment thread api/v1beta2/bfdprofile_types.go Outdated
}

// BFDProfileStatus defines the observed state of BFDProfile.
type BFDProfileStatus struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

missing TODO comment?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's generated by controller-gen, and it was the same in the operator.

Comment thread e2etest/e2etest_suite_test.go Outdated
flag.StringVar(&framework.TestContext.Provider, "provider", "", "The name of the Kubernetes provider (gce, gke, local, skeleton (the fallback if not set), etc.)")
framework.TestContext.KubeConfig = os.Getenv(clientcmd.RecommendedConfigPathEnvVar)
framework.RegisterClusterFlags(flag.CommandLine)
//flag.StringVar(&framework.TestContext.Provider, "provider", "", "The name of the Kubernetes provider (gce, gke, local, skeleton (the fallback if not set), etc.)")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why it's commented?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it's not needed any more as we are not importing the crds from the operator anymore, need to delete it.

Comment thread api/v1beta2/bfdprofile_types.go Outdated
DetectMultiplier *uint32 `json:"detectMultiplier,omitempty"`
// +kubebuilder:validation:Maximum:=60000
// +kubebuilder:validation:Minimum:=10
EchoInterval *uint32 `json:"echoInterval,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What about echoTransmitInterval? I see it in the design proposal

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That was because the proposal was written when we were aiming at frr 8. Frr 7.5 only has echo interval.
That was the same in the operator, and in the configmap.

Comment thread internal/config/config.go Outdated
}
ad.Communities[v] = true
}
func validateBGPAddPerPool(adv *BGPAdvertisement, pool *Pool) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

validateBGPAddPerPool -> validateBGPAdvPerPool

@fedepaol fedepaol force-pushed the newcrdsinmetallb branch 3 times, most recently from 573f797 to 4b363fc Compare March 9, 2022 14:30
Comment thread internal/config/config.go Outdated
case BGP:
ads, err := bgpAdvertisementsFromLegacyCR(p.Spec.BGPAdvertisements, cidrsPerAddresses, bgpCommunities)
if err != nil {
return nil, fmt.Errorf("parsing BGP communities: %s", err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The err msg here is misleading. bgpAdvertisementsFromLegacyCR func parsing not just communities.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Changed

Comment thread speaker/layer2_controller_test.go Outdated
pool := c1.config.Pools[poolFor(c1.config.Pools, []net.IP{lbIP})]
response1 := c1.protocols[pool.Protocol].ShouldAnnounce(l, "test1", []net.IP{lbIP}, svc, test.eps[lbIP_s])
response2 := c2.protocols[pool.Protocol].ShouldAnnounce(l, "test1", []net.IP{lbIP}, svc, test.eps[lbIP_s])
// pool := c1.config.Pools[poolFor(c1.config.Pools, []net.IP{lbIP})]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this commented line be removed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

removed

Comment thread speaker/main.go
@@ -198,11 +200,12 @@ type controllerConfig struct {

// For testing only, and will be removed in a future release.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i know it's unrelated to this PR, but do you know something about this comment from 4 years ago? the issue was closed.

@fedepaol fedepaol force-pushed the newcrdsinmetallb branch 4 times, most recently from 91ce27b to 501e21a Compare March 11, 2022 13:25
@fedepaol fedepaol force-pushed the newcrdsinmetallb branch 3 times, most recently from 6907124 to c6a6704 Compare March 21, 2022 21:00
Comment thread speaker/speaker_test.go
t.Fatal("two handlers, ip is not announced in bgp")
}
if !c.announced[config.Layer2]["testsvc"] {
t.Fatal("two handlers, ip is not announced in bgp")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: in l2

Comment thread speaker/speaker_test.go Outdated
t.Fatal("one handler, ip is not announced in bgp")
}
if c.announced[config.Layer2]["testsvc"] {
t.Fatal("one handler, ip is not announced in bgp")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: ip is announced in l2

Comment thread speaker/speaker_test.go Outdated
t.Fatal("no handlers, l2 handler was called")
}
if bgpMockHandler.setBalancerCalled {
t.Fatal("no handlers, bgp handler was not called")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: was called

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

Comment thread speaker/speaker_test.go Outdated
Comment on lines +150 to +149
if l2MockHandler.setBalancerCalled {
t.Fatal("no handlers, l2 handler was called")
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it is a duplication of lines 144-146

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

Comment thread speaker/speaker_test.go Outdated
t.Fatal("no handlers, l2 handler was called")
}
if !bgpMockHandler.deleteBalancerCalled {
t.Fatal("no handlers, l2 delete handler was not called")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: bgp delete handler was not called

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done, thanks!

Comment thread speaker/speaker_test.go Outdated
t.Fatal("no handlers, ip is announced in bgp")
}
if c.announced[config.Layer2]["testsvc"] {
t.Fatal("no handlers, ip is announced in bgp")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"in l2"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done, thanks!

fedepaol added 12 commits March 22, 2022 09:58
This is the evolution of the CRDs defined in the operator, separating
the IP allocation function handled by the address pool, the connection
with bgp peers handled by the BGPPeer CRD, and the intent to advertise a
prefix over L2 or BGP (or both) via the L2Advertisement and
BGPAdvertisement CRDs.

Instead of having a different addersspool version, we create a new CRD
(IPPool) which will live together with the old address pool. This is
required because it's not possible to have converting webhook from one
CRD (addresspool) to two (addresspool, new version + BGP Advertisement
or L2 advertisement). Also, it's not possible to have two different
versions of the same CR stored in etcd. For this reason, it's safer to
have a new CR and make metallb work with the old one.

BGPPeer is then moved to v1beta2, because there it's possible to
translate the node selector, and we'll add new fields in a compatible
manner.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
With the separation of the addresspool from the protocol and the
introduction of l2 and bgp advertisement, we change the internal
structure so that the pool also contains the reference to its
advertisements.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
AddressPool is the legacy CRD, and we need to handle it together with
IPPools.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
In order to understand if an address (or a prefix) must be advertised,
we now need to look at the list of advertisements the pool comes with.

Also, now it's possible to have multiple protocols for the same
addresspool, so the speaker internal structure changes to accomodate
this.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
We change the tests to reflect the new structure, and the config updater
to write directly the CRs instead of jumping in the intermediate
configuration.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
Cleaning up go.mod and go.sum after dependency changes.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
Aligning the manifests to reflect the changes in the api.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
Aligning the helm charts to reflect the changes in the api.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
We want to ensure that IPPool and AddressPools work together in order to
offer compatibility to existing users.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
The configmap name is not needed anymore as there is no configmap, so
removing the environment variable.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
The first parameter is of the wrong type, setting it to string.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
We removed the defaulting when parsing the config, so we want to ensure
that the default value is being set on the cr.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
@oribon

oribon commented Mar 22, 2022

Copy link
Copy Markdown
Member

LGTM

Now that the integration code is a bit more complex, because it needs to
take into account multiple protocols, we add a test that validates it.

Signed-off-by: Federico Paolinelli <fpaoline@redhat.com>
@fedepaol fedepaol merged commit 54e0c0f into metallb:main Mar 22, 2022
@adampl

adampl commented Mar 29, 2022

Copy link
Copy Markdown

Is this going to resolve #277 ?

Nope, but it will pave the road for that. Feature wise, this is not introducing anything new, just a different (and cleaner) way to configure metallb. When this is in place, the interface would ideally be set on the l2 advertisement.

@fedepaol Thanks, at least it's good to know it will be possible in the future :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants