address comments
This commit is contained in:
parent
be00b42b3e
commit
93a667334b
|
|
@ -73,7 +73,7 @@ func reconcileTasks(nodes []corev1.Node, tasks *operatorv1.RuntimeTaskList) *tas
|
|||
|
||||
// Match the the current Task with desired Task (1 for each node in scope).
|
||||
for _, t := range tasks.Items {
|
||||
// in case a current objects has a corresponding desired object, match them
|
||||
// in case a current task has a corresponding desired task, match them
|
||||
// NB. if there are more that one match, we track this, but this is an inconsistency
|
||||
// (more that one Task for the same node)
|
||||
if v, ok := matchMap[t.Spec.NodeName]; ok {
|
||||
|
|
@ -82,7 +82,7 @@ func reconcileTasks(nodes []corev1.Node, tasks *operatorv1.RuntimeTaskList) *tas
|
|||
continue
|
||||
}
|
||||
|
||||
// in case a current objects does not have desired object, we track this, but this is an inconsistency
|
||||
// in case a current task does not have desired task, we track this, but this is an inconsistency
|
||||
// (a Task does not matching any existing node)
|
||||
matchMap[t.Spec.NodeName] = newTaskGroupChildProxy(nil, t)
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ func reconcileTasks(nodes []corev1.Node, tasks *operatorv1.RuntimeTaskList) *tas
|
|||
// ensure the list is sorted in a predictable way
|
||||
sort.Slice(matchList.all, func(i, j int) bool { return matchList.all[i].name < matchList.all[j].name })
|
||||
|
||||
// Build all the derived views, so we can have a quick glance at objects in different states
|
||||
// Build all the derived views, so we can have a quick glance at tasks in different states
|
||||
matchList.deriveViews()
|
||||
|
||||
return matchList
|
||||
|
|
@ -117,7 +117,7 @@ func (t *taskReconcileList) deriveViews() {
|
|||
case v.node != nil:
|
||||
switch len(v.tasks) {
|
||||
case 0:
|
||||
// If there is not Task for a Node, the task has to be created by this controller
|
||||
// If there is no Task for a Node, the task has to be created by this controller
|
||||
t.tobeCreated = append(t.tobeCreated, v)
|
||||
case 1:
|
||||
// Failed (and not recovering)
|
||||
|
|
@ -144,7 +144,7 @@ func (t *taskReconcileList) deriveViews() {
|
|||
t.invalid = append(t.invalid, v)
|
||||
}
|
||||
case v.node == nil:
|
||||
// if there Task without matching node, this is an invalid condition
|
||||
// if there is a Task without matching node, this is an invalid condition
|
||||
t.invalid = append(t.invalid, v)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ func (r *RuntimeTaskGroupReconciler) reconcileNormal(executionMode operatorv1.Op
|
|||
//TODO: add a signature so we can detect if someone/something changes the taskgroup while it is processed
|
||||
}
|
||||
|
||||
// if there are still Task to be created
|
||||
// if there are still Tasks to be created
|
||||
if len(tasks.tobeCreated) > 0 {
|
||||
//TODO: manage different deployment strategy e.g. parallel
|
||||
|
||||
|
|
@ -331,7 +331,7 @@ func (r *RuntimeTaskGroupReconciler) reconcilePhase(taskgroup *operatorv1.Runtim
|
|||
taskgroup.Status.SetTypedPhase(operatorv1.RuntimeTaskGroupPhaseSucceeded)
|
||||
}
|
||||
|
||||
// Set the phase to "failed" if any of Status.ErrorReason or Status.ErrorMessage is not-nil.
|
||||
// Set the phase to "failed" if any of Status.ErrorReason or Status.ErrorMessage is not nil.
|
||||
if taskgroup.Status.ErrorReason != nil || taskgroup.Status.ErrorMessage != nil {
|
||||
taskgroup.Status.SetTypedPhase(operatorv1.RuntimeTaskGroupPhaseFailed)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ func (m matchingSelector) ApplyToList(opts *client.ListOptions) {
|
|||
func listNodesBySelector(c client.Client, selector *metav1.LabelSelector) (*corev1.NodeList, error) {
|
||||
s, err := metav1.LabelSelectorAsSelector(selector)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to convert TaskGroup.Spec.NodeSelector to a map")
|
||||
return nil, errors.Wrap(err, "failed to convert TaskGroup.Spec.NodeSelector to a selector")
|
||||
}
|
||||
|
||||
o := matchingSelector{selector: s}
|
||||
|
|
@ -367,7 +367,7 @@ func filterNodes(nodes *corev1.NodeList, filter operatorv1.RuntimeTaskGroupNodeF
|
|||
return nodes.Items
|
||||
}
|
||||
|
||||
// in order to ensure a predictable results, nodes are sorted by name before applying the filter
|
||||
// in order to ensure a predictable result, nodes are sorted by name before applying the filter
|
||||
sort.Slice(nodes.Items, func(i, j int) bool { return nodes.Items[i].Name < nodes.Items[j].Name })
|
||||
|
||||
if filter == operatorv1.RuntimeTaskGroupNodeFilterHead {
|
||||
|
|
@ -381,7 +381,7 @@ func filterNodes(nodes *corev1.NodeList, filter operatorv1.RuntimeTaskGroupNodeF
|
|||
func listTasksBySelector(c client.Client, selector *metav1.LabelSelector) (*operatorv1.RuntimeTaskList, error) {
|
||||
selectorMap, err := metav1.LabelSelectorAsMap(selector)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to convert TaskGroup.Spec.Selector to a map")
|
||||
return nil, errors.Wrap(err, "failed to convert TaskGroup.Spec.Selector to a selector")
|
||||
}
|
||||
|
||||
tasks := &operatorv1.RuntimeTaskList{}
|
||||
|
|
|
|||
Loading…
Reference in New Issue