mirror of
https://github.com/k8snetworkplumbingwg/whereabouts.git
synced 2025-06-03 06:42:26 +00:00

* build: generate ip pool clientSet/informers/listers
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* vendor: update vendor stuff
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* build: vendor net-attach-def-client types
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* config: look for the whereabouts config file in multiple places
The reconciler controller will have access to the whereabouts
configuration via a mount point. As such, we need a way to specify its
path.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* reconcile-loop: requires the IP ranges in normalized format
The IP reconcile loop also requires the IP ranges in a normalized
format; as such, we export it into a function, which will be used in a
follow-up commit.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* config: allow IPAM config parsing from a NetConfList
Currently whereabouts is only able to parse network configurations in
the strict [0] format - i.e. **do not accept** a plugin list - [1].
The `ip-control-loop` must recover the full plugin configuration, which
may be in the network configuration format.
This commit allows whereabouts to now understand both formats.
Furthermore, the current CNI release - v1.0.Z - removed the support for
[0], meaning that only the configuration list format is now supported
[2].
[0] - https://github.com/containernetworking/cni/blob/v0.8.1/SPEC.md#network-configuration
[1] - https://github.com/containernetworking/cni/blob/v0.8.1/SPEC.md#network-configuration-lists
[2] - https://github.com/containernetworking/cni/blob/master/SPEC.md#released-versions
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* reconcile-loop: add a controller
Listen to pod deletion, and for every deleted pod, assure their IPs
are gone.
The rough algorithm goes like this:
- for every network-status in the pod's annotations:
- read associated net-attach-def from the k8s API
- extract the range from the net-attach-def
- find the corresponding IP pool
- look for allocations belonging to the deleted pod
- delete them using `IPManagement(..., types.Deallocate, ...)`
All the API reads go through the informer cache, which is kept updated
whenever the objects are updated on the API.
The dockerfiles are also updated, to ship this new binary.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* e2e tests: remove manual cluster reconciliation
This would leave the `ip-control-loop` as the reconciliation tool.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* unit tests: assure stale IPAllocation cleanup
This commit adds a unit where it is checked that the pod deletion leads
to the cleanup of a stale IP address.
This commit features the automatic provisioning of the controller informer cache
with the data present on the fake clientset tracker (the "fake" datastore).
This way, users can just create the client with provisioned data, and
that'll trickle down to the informer cache of the pod controller.
Because the `network-attachment-definitions` resources feature dashes,
the heuristic function that guesses - yes, guesses. very deterministic
... - the name of the resource can't be used - [0]. As such, it was
needed to create an alternate `newFakeNetAttachDefClient` where it is
possible to specify the correct resource name.
[0] - 2fd7267afc/vendor/k8s.io/client-go/testing/fixture.go (L331)
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* unit tests: move helper funcs to other files
The helper files are tagged with the `test` build tag, to prevent them
from being shipped on the production code binary.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* control loop, queueing: use a rate-limiting queue
Using a queue allows us to re-queue errors.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* control loop: add IPAllocation cleanup related events
Adds two new events related to garbage collection of the whereabouts IP
addresses:
- when an IP address is garbage collected
- when a cleanup operation fails and is not re-queued
The former event looks like:
```
116s Normal IPAddressGarbageCollected pod/macvlan1-worker1 \
successful cleanup of IP address [192.168.2.1] from network \
whereabouts-conf
```
The latter event looks like:
```
10s Warning IPAddressGarbageCollectionFailed failed to garbage \
collect addresses for pod default/macvlan1-worker1
```
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* e2e tests: check out statefulset scenarios
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* e2e tests: test different scale up/down order and instance deltas
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* ci: test e2e bash scripts last
These ugly tests do not cleanup after themselves; this way, the golang
based tests (which **do** cleanup after themselves) will not be impacted by
these left-overs.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* ip control loop, unit tests: test negative scenarios
Check the event thrown when a request is dropped from the queue, and
assure reconciling an allocation is impossible without having access to
the attachment configuration data.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* e2e tests: test fix for issue #182
Issue [0] reports an error when a pod associated to a `StatefulSet`
whose IPPool is already full is deleted. According to it, the new pod -
scheduled by the `StatefulSet` - cannot run because the IPPool is
already full, and the old pod's IP cannot be garbage collected because
we match by pod reference - and the "new" pod is stuck in `creating`
phase.
[0] - https://github.com/k8snetworkplumbingwg/whereabouts/issues/182
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* ip-control-loop: strip pod before queueing it
The ip reconcile loop only requires the pod metadata and its network
status annotatations to garbage collect the stale IP addresses.
As such, we remove the status and spec parameters from the pod before
queueing it.
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
* reconcile-loop: focus on networks w/ whereabouts IPAM type
Signed-off-by: Miguel Duarte Barroso <mdbarroso@redhat.com>
178 lines
5.2 KiB
Go
178 lines
5.2 KiB
Go
// +build !ignore_autogenerated
|
|
|
|
// Code generated by controller-gen. DO NOT EDIT.
|
|
|
|
package v1alpha1
|
|
|
|
import (
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
)
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
func (in *IPAllocation) DeepCopyInto(out *IPAllocation) {
|
|
*out = *in
|
|
}
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAllocation.
|
|
func (in *IPAllocation) DeepCopy() *IPAllocation {
|
|
if in == nil {
|
|
return nil
|
|
}
|
|
out := new(IPAllocation)
|
|
in.DeepCopyInto(out)
|
|
return out
|
|
}
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
func (in *IPPool) DeepCopyInto(out *IPPool) {
|
|
*out = *in
|
|
out.TypeMeta = in.TypeMeta
|
|
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
|
in.Spec.DeepCopyInto(&out.Spec)
|
|
}
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPool.
|
|
func (in *IPPool) DeepCopy() *IPPool {
|
|
if in == nil {
|
|
return nil
|
|
}
|
|
out := new(IPPool)
|
|
in.DeepCopyInto(out)
|
|
return out
|
|
}
|
|
|
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
|
func (in *IPPool) DeepCopyObject() runtime.Object {
|
|
if c := in.DeepCopy(); c != nil {
|
|
return c
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
func (in *IPPoolList) DeepCopyInto(out *IPPoolList) {
|
|
*out = *in
|
|
out.TypeMeta = in.TypeMeta
|
|
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
|
if in.Items != nil {
|
|
in, out := &in.Items, &out.Items
|
|
*out = make([]IPPool, len(*in))
|
|
for i := range *in {
|
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
}
|
|
}
|
|
}
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolList.
|
|
func (in *IPPoolList) DeepCopy() *IPPoolList {
|
|
if in == nil {
|
|
return nil
|
|
}
|
|
out := new(IPPoolList)
|
|
in.DeepCopyInto(out)
|
|
return out
|
|
}
|
|
|
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
|
func (in *IPPoolList) DeepCopyObject() runtime.Object {
|
|
if c := in.DeepCopy(); c != nil {
|
|
return c
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
func (in *IPPoolSpec) DeepCopyInto(out *IPPoolSpec) {
|
|
*out = *in
|
|
if in.Allocations != nil {
|
|
in, out := &in.Allocations, &out.Allocations
|
|
*out = make(map[string]IPAllocation, len(*in))
|
|
for key, val := range *in {
|
|
(*out)[key] = val
|
|
}
|
|
}
|
|
}
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPoolSpec.
|
|
func (in *IPPoolSpec) DeepCopy() *IPPoolSpec {
|
|
if in == nil {
|
|
return nil
|
|
}
|
|
out := new(IPPoolSpec)
|
|
in.DeepCopyInto(out)
|
|
return out
|
|
}
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
func (in *OverlappingRangeIPReservation) DeepCopyInto(out *OverlappingRangeIPReservation) {
|
|
*out = *in
|
|
out.TypeMeta = in.TypeMeta
|
|
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
|
out.Spec = in.Spec
|
|
}
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverlappingRangeIPReservation.
|
|
func (in *OverlappingRangeIPReservation) DeepCopy() *OverlappingRangeIPReservation {
|
|
if in == nil {
|
|
return nil
|
|
}
|
|
out := new(OverlappingRangeIPReservation)
|
|
in.DeepCopyInto(out)
|
|
return out
|
|
}
|
|
|
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
|
func (in *OverlappingRangeIPReservation) DeepCopyObject() runtime.Object {
|
|
if c := in.DeepCopy(); c != nil {
|
|
return c
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
func (in *OverlappingRangeIPReservationList) DeepCopyInto(out *OverlappingRangeIPReservationList) {
|
|
*out = *in
|
|
out.TypeMeta = in.TypeMeta
|
|
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
|
if in.Items != nil {
|
|
in, out := &in.Items, &out.Items
|
|
*out = make([]OverlappingRangeIPReservation, len(*in))
|
|
for i := range *in {
|
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
}
|
|
}
|
|
}
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverlappingRangeIPReservationList.
|
|
func (in *OverlappingRangeIPReservationList) DeepCopy() *OverlappingRangeIPReservationList {
|
|
if in == nil {
|
|
return nil
|
|
}
|
|
out := new(OverlappingRangeIPReservationList)
|
|
in.DeepCopyInto(out)
|
|
return out
|
|
}
|
|
|
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
|
func (in *OverlappingRangeIPReservationList) DeepCopyObject() runtime.Object {
|
|
if c := in.DeepCopy(); c != nil {
|
|
return c
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
func (in *OverlappingRangeIPReservationSpec) DeepCopyInto(out *OverlappingRangeIPReservationSpec) {
|
|
*out = *in
|
|
}
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverlappingRangeIPReservationSpec.
|
|
func (in *OverlappingRangeIPReservationSpec) DeepCopy() *OverlappingRangeIPReservationSpec {
|
|
if in == nil {
|
|
return nil
|
|
}
|
|
out := new(OverlappingRangeIPReservationSpec)
|
|
in.DeepCopyInto(out)
|
|
return out
|
|
}
|