-
Notifications
You must be signed in to change notification settings - Fork 775
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
Optimize Advanced DaemonSet internal new pod for imitating scheduling #1011
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,6 +223,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { | |
ds := e.Object.(*appsv1alpha1.DaemonSet) | ||
klog.V(4).Infof("Deleting DaemonSet %s/%s", ds.Namespace, ds.Name) | ||
dsc.expectations.DeleteExpectations(keyFunc(ds)) | ||
newPodForDSCache.Delete(ds.UID) | ||
return true | ||
}, | ||
}) | ||
|
@@ -449,13 +450,28 @@ func isControlledByDaemonSet(p *corev1.Pod, uuid types.UID) bool { | |
|
||
// NewPod creates a new pod | ||
func NewPod(ds *appsv1alpha1.DaemonSet, nodeName string) *corev1.Pod { | ||
// firstly load the cache before lock | ||
if pod := loadNewPodForDS(ds); pod != nil { | ||
return pod | ||
} | ||
|
||
newPodForDSLock.Lock() | ||
defer newPodForDSLock.Unlock() | ||
|
||
// load the cache again after locked | ||
if pod := loadNewPodForDS(ds); pod != nil { | ||
return pod | ||
} | ||
|
||
newPod := &corev1.Pod{Spec: ds.Spec.Template.Spec, ObjectMeta: ds.Spec.Template.ObjectMeta} | ||
newPod.Namespace = ds.Namespace | ||
newPod.Spec.NodeName = nodeName | ||
// no need to set nodeName | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since we're confident that pod for ds not exist here, plz consider using newPodForDSCache. LoadOrStore so that we don't have to maintain newPodForDSLock There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, only LoadOrStore might have multiple NewPod to be create and store, for this is not only called in reconcile, but also event handler. |
||
// newPod.Spec.NodeName = nodeName | ||
|
||
// Added default tolerations for DaemonSet pods. | ||
daemonsetutil.AddOrUpdateDaemonPodTolerations(&newPod.Spec) | ||
|
||
newPodForDSCache.Store(ds.UID, &newPodForDS{generation: ds.Generation, pod: newPod}) | ||
return newPod | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plz delete entry of ds.UID if daemonset is not found in the beginning of Reconcile()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emm.. I can't do that, for there is no UID since daemonset is not found. Delete handler should be enough.