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

Fixing incomplete execution of the configuration issue #521

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jaysheth2
Copy link
Contributor

Addressing #520
In case the payload consist of the configuration which requires eBPF programs for multiple interfaces to be loaded (for example, eth1, eth2, and eth3).

In the scenario where eth2 exists no more:

  • Due to the return statements in the sequential for loop in the current l3afd code will load the eBPF program for eth1, and return directly as eth2 will not be found, without even attempting to load the eBPF program for eth3.

In this PR, we remove the return statements in the for loop and instead save individual error messages to single variable. This variable is then returned after the for loop is completed.

Copy link
Contributor

@sanfern sanfern left a comment

Choose a reason for hiding this comment

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

Line 780: Replace with combinedError = errors.Join(combinedError, fmt.Errorf("deploy eBPF Programs failed to save configs %v", err))
Line 796: Replace with return combinedError

Comment on lines 768 to 772
if combinedError == nil { // saving all the errors for c.Deploy c.SaveConfigsToConfigStore to combinedError instead of returning right away.
combinedError = fmt.Errorf("deploy eBPF Programs failed to save configs %w", err)
} else {
combinedError = fmt.Errorf("%v; %v", combinedError, fmt.Errorf("deploy eBPF Programs failed to save configs %w", err))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if combinedError == nil { // saving all the errors for c.Deploy c.SaveConfigsToConfigStore to combinedError instead of returning right away.
combinedError = fmt.Errorf("deploy eBPF Programs failed to save configs %w", err)
} else {
combinedError = fmt.Errorf("%v; %v", combinedError, fmt.Errorf("deploy eBPF Programs failed to save configs %w", err))
}
combinedError = combinedError.Join(combinedError, fmt.Errorf("deploy eBPF Programs failed to save configs %w", err))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

combinedError is of type error, which does not have Join function

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment on lines 773 to 777
}
if combinedError == nil {
combinedError = fmt.Errorf("deploy eBPF Programs failed to save configs %w", err)
} else {
combinedError = fmt.Errorf("%v; %v", combinedError, fmt.Errorf("failed to deploy BPF program on iface %s with error: %w", bpfProg.Iface, err))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove this SaveConfigsToConfigStore(); call ? we have to save config at the end with the good state only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the SaveConfigsToConfigStore() call

@@ -782,6 +796,8 @@ func (c *NFConfigs) DeployeBPFPrograms(bpfProgs []models.L3afBPFPrograms) error
return nil
}

// function to combine all errors in []error and return a single error
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove these comments that are no longer relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed

charleskbliu0
charleskbliu0 previously approved these changes Jan 24, 2025
Copy link

@charleskbliu0 charleskbliu0 left a comment

Choose a reason for hiding this comment

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

Looks good

@@ -779,7 +781,7 @@ func (c *NFConfigs) DeployeBPFPrograms(bpfProgs []models.L3afBPFPrograms) error
if err := c.SaveConfigsToConfigStore(); err != nil {
return fmt.Errorf("deploy eBPF Programs failed to save configs %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("deploy eBPF Programs failed to save configs %w", err)
combinedError = errors.Join(combinedError, fmt.Errorf("deploy eBPF Programs failed to save configs %w", err))

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

Copy link
Contributor

@sanfern sanfern left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants