Skip to content

metallb addon fails to deploy when already existing IPAddressPool conflicts with the one to be deployed #832

@pmalek

Description

@pmalek

Problem statement

When trying to deploy the metallb addon (or another addon that depend on it) and there already exists an IPAddressPool which conflicts with the one to be deployed then the following error is blocking the deployment:

Message: "admission webhook \"ipaddresspoolvalidationwebhook.metallb.io\" denied the request: CIDR \"172.18.0.100/30\" in pool \"ktf-pool\" overlaps with already defined CIDR \"172.18.0.100/30\"",
Reason: "CIDR \"172.18.0.100/30\" in pool \"ktf-pool\" overlaps with already defined CIDR \"172.18.0.100/30\"",
Details: *k8s.io/apimachinery/pkg/apis/meta/v1.StatusDetails nil,
Code: 403

type of the error: https://pkg.go.dev/k8s.io/apimachinery/pkg/api/errors#StatusError

relevant piece of code:

_, err = res.Create(ctx, &unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": "metallb.io/v1beta1",
"kind": "IPAddressPool",
"metadata": map[string]string{
"name": addressPoolName,
},
"spec": map[string]interface{}{
"addresses": []string{
fmt.Sprintf("%s-%s", ipStart, ipEnd),
fmt.Sprintf("%s-%s", ip6Start, ip6End),
},
},
},
}, metav1.CreateOptions{})
if err != nil {
if errors.IsAlreadyExists(err) {
// delete the existing resource and recreate it in another round of loop.
err = res.Delete(ctx, addressPoolName, metav1.DeleteOptions{})
}
select {
case <-time.After(time.Second):
lastErr = err
continue
case <-ctx.Done():
return fmt.Errorf("failed to create metallb.io/v1beta1 IPAddressPool: %w, last error on create: %v", ctx.Err(), lastErr)
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions