-
Notifications
You must be signed in to change notification settings - Fork 64
Address race condition in XController variable #330
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e647952
Update Dockerfile:
z103cb adb00ee
Updates to ensure that docker builds flags are used
z103cb 09f6ae4
Updates to e2e script and travis for log level
z103cb 62ef8f8
Merge branch 'main' into issue-320
z103cb 95c0f95
Reverted needless changes.
z103cb ea18fcc
Documentation updates.
z103cb 8bbb054
Fixed bug in docker file
z103cb 0ce06f8
Fixed potential regression.
z103cb 10ad95e
Merge branch 'main' into issue-320
z103cb 710adf8
Added back Dockerfile
z103cb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,3 +125,6 @@ kubernetes.tar.gz | |
/bazel-* | ||
*.pyc | ||
|
||
# .devcontainer files | ||
.devcontainer | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package queuejob | ||
|
||
import ( | ||
"strings" | ||
"sync" | ||
|
||
arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" | ||
) | ||
|
||
// ActiveAppWrapper is current scheduling AppWrapper in the XController struct. | ||
// Its sole purpose is provide a thread safe way to for use the XController logic | ||
type ActiveAppWrapper struct { | ||
activeAW *arbv1.AppWrapper | ||
activeAWMutex *sync.RWMutex | ||
} | ||
|
||
// NewActiveAppWrapper | ||
func NewActiveAppWrapper() *ActiveAppWrapper { | ||
return &ActiveAppWrapper{ | ||
asm582 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
activeAW: nil, | ||
activeAWMutex: &sync.RWMutex{}, | ||
} | ||
} | ||
|
||
// AtomicSet as is name implies, atomically sets the activeAW to the new value | ||
func (aw *ActiveAppWrapper) AtomicSet(newValue *arbv1.AppWrapper) { | ||
aw.activeAWMutex.Lock() | ||
defer aw.activeAWMutex.Unlock() | ||
aw.activeAW = newValue | ||
} | ||
|
||
// IsActiveAppWrapper safely performs the comparison that was done inside the if block | ||
// at line 1977 in the queuejob_controller_ex.go | ||
// The code looked like this: | ||
// | ||
// if !qj.Status.CanRun && qj.Status.State == arbv1.AppWrapperStateEnqueued && | ||
// !cc.qjqueue.IfExistUnschedulableQ(qj) && !cc.qjqueue.IfExistActiveQ(qj) { | ||
// // One more check to ensure AW is not the current active schedule object | ||
// if cc.schedulingAW == nil || | ||
// (strings.Compare(cc.schedulingAW.Namespace, qj.Namespace) != 0 && | ||
// strings.Compare(cc.schedulingAW.Name, qj.Name) != 0) { | ||
// cc.qjqueue.AddIfNotPresent(qj) | ||
// klog.V(3).Infof("[manageQueueJob] Recovered AppWrapper %s%s - added to active queue, Status=%+v", | ||
// qj.Namespace, qj.Name, qj.Status) | ||
// return nil | ||
// } | ||
// } | ||
func (aw *ActiveAppWrapper) IsActiveAppWrapper(name, namespace string) bool { | ||
aw.activeAWMutex.RLock() | ||
defer aw.activeAWMutex.RUnlock() | ||
return aw.activeAW == nil || | ||
(strings.Compare(aw.activeAW.Namespace, namespace) != 0 && | ||
strings.Compare(aw.activeAW.Name, name) != 0) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.