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

Do not error out if no ip is available in a prefix #551

Merged
merged 2 commits into from
Jul 24, 2024

Conversation

majst01
Copy link
Contributor

@majst01 majst01 commented Jul 22, 2024

closes: #550
Depends on: metal-stack/go-ipam#157

@majst01 majst01 requested a review from a team as a code owner July 22, 2024 05:53
@majst01 majst01 force-pushed the do-not-error-if-no-ip-available-in-prefix branch from cb63feb to 7603269 Compare July 22, 2024 07:40
@@ -560,6 +561,12 @@ func (r *networkResource) freeNetwork(request *restful.Request, response *restfu
for _, prefix := range nw.Prefixes {
err = r.ipamer.ReleaseChildPrefix(ctx, prefix)
if err != nil {
var connectErr *connect.Error
if errors.As(err, &connectErr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably we cannot skip here as then we have orphaned prefixes after freeing the network.

@@ -439,8 +437,11 @@ func allocateSpecificIP(ctx context.Context, parent *metal.Network, specificIP s
func allocateRandomIP(ctx context.Context, parent *metal.Network, ipamer ipam.IPAMer) (ipAddress, parentPrefixCidr string, err error) {
for _, prefix := range parent.Prefixes {
ipAddress, err = ipamer.AllocateIP(ctx, prefix)
if err != nil && errors.Is(err, goipam.ErrNoIPAvailable) {
continue
var connectErr *connect.Error
Copy link
Contributor Author

Choose a reason for hiding this comment

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

check for err != nil is missing here

@@ -730,6 +743,12 @@ func (r *networkResource) deleteNetwork(request *restful.Request, response *rest
for _, p := range nw.Prefixes {
err := r.ipamer.DeletePrefix(ctx, p)
if err != nil {
var connectErr *connect.Error
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

@majst01 majst01 force-pushed the do-not-error-if-no-ip-available-in-prefix branch from ee1c960 to c8ca47a Compare July 24, 2024 08:35
…o do-not-error-if-no-ip-available-in-prefix
@majst01 majst01 force-pushed the do-not-error-if-no-ip-available-in-prefix branch from c8ca47a to 6889816 Compare July 24, 2024 08:37
@Gerrit91 Gerrit91 merged commit d5e5fcf into master Jul 24, 2024
2 checks passed
@Gerrit91 Gerrit91 deleted the do-not-error-if-no-ip-available-in-prefix branch July 24, 2024 08:41
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.

Fix allocateRandomIP in machine-service to check for no ip available error
2 participants