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

app number free on underlay network #2285

Closed
wants to merge 1 commit into from

Conversation

srinibas-zededa
Copy link
Contributor

  • app number free on underlay network should trigger network instance delete try
  • added a wrapper function to address the portability concerns for appnumOnUNetFree()
  • simplified the handleAppNetworkModify() code structure a bit.
    Signed-off-by: Srinibas Maharana srinibas@zededa.com

…e delete try

Signed-off-by: Srinibas Maharana <srinibas@zededa.com>
@@ -896,6 +896,7 @@ func handleAppNetworkCreate(ctxArg interface{}, key string, configArg interface{

// allocate application numbers on underlay network
if err := appNumsOnUNetAllocate(ctx, &config); err != nil {
status.PendingAdd = false
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bugfix. Please do as separate PR.

Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

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

99% of these changes are unneccesary and I don't see how they improve readability.
Two bug fixes are needed: the PendingCreate = false fix and making sure that when a Modify releases an appnum the maybeNetworkInstanceDelete() gets called.

The latter only makes sense from the top as I said before.
zedrouter.go should always call a new function which does what appNumOnNetworkInstanceRelease() does, but I'm not sure about the name for this function. (The abstraction hence naming is a bit of a mess IMHO.)

Thus the code in appnumonunet.go should have no idea what a network instance is.
It merely operates on network UUIDs and app instance UUID. (Yes, the arguments should be a networkID; the caller has no idea what a baseid is; the notion of a baseID belongs in uuidpairtonum. As I said, the abstraction hence naming is a bit of a mess.)

So I

if _, err := appNumOnUNetGet(ctx, networkID, appID); err == nil {
appNumOnUNetFree(ctx, networkID, appID)
}
netstatus := lookupNetworkInstanceStatus(ctx, networkID.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need to do this when you didn't call appNumOnUNetFree?

Comment on lines +1490 to +1491
if !status.Activated {
// need not handle ACL changes in deactivated state
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see how these changes make the code any easier to read and understand.

Comment on lines -1925 to -1930
if maybeNetworkInstanceDelete(ctx, netstatus) {
log.Noticef("deleted network instance %s", netstatus.Key())
} else {
// publish the changes to network instance status
publishNetworkInstanceStatus(ctx, netstatus)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

How do you know this isn't required?

Comment on lines +2357 to +2359
// may be multiple config entries, need not try scheduling again
// just return
return
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this change do in this PR?

@@ -1771,19 +1786,6 @@ func handleDelete(ctx *zedrouterContext, key string,

appNumFree(ctx, status.UUIDandVersion.UUID)
appNumsOnUNetFree(ctx, status)
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to explain to me the difference between the abstraction provided by ipaddronunet.go and appnumsonunet.go.
Presumably the former is layered on top of the later, in which case zedrouter.go should only call the former abstraction.

With your changes it is extremely hard to see where the freeing of various resources happen since there is no consistent abstraction. And if there is no such abstraction the easiest to read is the have the indivual calls at the top layer and not introduce intermediate functions; the functions should follow an intentional abstraction as supposed to just being collections of code.

status *types.AppNetworkStatus,
config types.AppNetworkConfig,
oldConfig types.AppNetworkConfig,
ipsets []string, force bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The forice argument is unused. Are there other unused arguments?

@rouming
Copy link
Contributor

rouming commented Nov 24, 2022

@eriknordmark can we please close?

@milan-zededa
Copy link
Contributor

This PR is obsolete - number allocators have been refactored and the rest of the zedrouter will be soon as well.

eriknordmark added a commit to eriknordmark/eve that referenced this pull request Apr 28, 2023
From lf-edge#2285

Signed-off-by: eriknordmark <erik@zededa.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request Apr 28, 2023
From comments in lf-edge#2285

Signed-off-by: eriknordmark <erik@zededa.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request May 1, 2023
From lf-edge#2285

Signed-off-by: eriknordmark <erik@zededa.com>
eriknordmark added a commit to eriknordmark/eve that referenced this pull request May 1, 2023
From comments in lf-edge#2285

Signed-off-by: eriknordmark <erik@zededa.com>
eriknordmark added a commit that referenced this pull request May 3, 2023
From #2285

Signed-off-by: eriknordmark <erik@zededa.com>
eriknordmark added a commit that referenced this pull request May 3, 2023
From comments in #2285

Signed-off-by: eriknordmark <erik@zededa.com>
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.

4 participants