make sure to update resource status
Signed-off-by: dddddai <dddwq@foxmail.com>
This commit is contained in:
parent
eff23524d7
commit
5743cebab0
|
@ -72,7 +72,7 @@ func (e *DefaultInterpreter) HookEnabled(kind schema.GroupVersionKind, operation
|
||||||
func (e *DefaultInterpreter) GetReplicas(object *unstructured.Unstructured) (int32, *workv1alpha2.ReplicaRequirements, error) {
|
func (e *DefaultInterpreter) GetReplicas(object *unstructured.Unstructured) (int32, *workv1alpha2.ReplicaRequirements, error) {
|
||||||
handler, exist := e.replicaHandlers[object.GroupVersionKind()]
|
handler, exist := e.replicaHandlers[object.GroupVersionKind()]
|
||||||
if !exist {
|
if !exist {
|
||||||
return 0, &workv1alpha2.ReplicaRequirements{}, fmt.Errorf("defalut %s interpreter for %q not found", configv1alpha1.InterpreterOperationInterpretReplica, object.GroupVersionKind())
|
return 0, &workv1alpha2.ReplicaRequirements{}, fmt.Errorf("default %s interpreter for %q not found", configv1alpha1.InterpreterOperationInterpretReplica, object.GroupVersionKind())
|
||||||
}
|
}
|
||||||
return handler(object)
|
return handler(object)
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ func (e *DefaultInterpreter) GetReplicas(object *unstructured.Unstructured) (int
|
||||||
func (e *DefaultInterpreter) ReviseReplica(object *unstructured.Unstructured, replica int64) (*unstructured.Unstructured, error) {
|
func (e *DefaultInterpreter) ReviseReplica(object *unstructured.Unstructured, replica int64) (*unstructured.Unstructured, error) {
|
||||||
handler, exist := e.reviseReplicaHandlers[object.GroupVersionKind()]
|
handler, exist := e.reviseReplicaHandlers[object.GroupVersionKind()]
|
||||||
if !exist {
|
if !exist {
|
||||||
return nil, fmt.Errorf("defalut %s interpreter for %q not found", configv1alpha1.InterpreterOperationReviseReplica, object.GroupVersionKind())
|
return nil, fmt.Errorf("default %s interpreter for %q not found", configv1alpha1.InterpreterOperationReviseReplica, object.GroupVersionKind())
|
||||||
}
|
}
|
||||||
return handler(object, replica)
|
return handler(object, replica)
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ func (e *DefaultInterpreter) Retain(desired *unstructured.Unstructured, observed
|
||||||
func (e *DefaultInterpreter) AggregateStatus(object *unstructured.Unstructured, aggregatedStatusItems []workv1alpha2.AggregatedStatusItem) (*unstructured.Unstructured, error) {
|
func (e *DefaultInterpreter) AggregateStatus(object *unstructured.Unstructured, aggregatedStatusItems []workv1alpha2.AggregatedStatusItem) (*unstructured.Unstructured, error) {
|
||||||
handler, exist := e.aggregateStatusHandlers[object.GroupVersionKind()]
|
handler, exist := e.aggregateStatusHandlers[object.GroupVersionKind()]
|
||||||
if !exist {
|
if !exist {
|
||||||
return nil, fmt.Errorf("defalut %s interpreter for %q not found", configv1alpha1.InterpreterOperationAggregateStatus, object.GroupVersionKind())
|
return nil, fmt.Errorf("default %s interpreter for %q not found", configv1alpha1.InterpreterOperationAggregateStatus, object.GroupVersionKind())
|
||||||
}
|
}
|
||||||
return handler(object, aggregatedStatusItems)
|
return handler(object, aggregatedStatusItems)
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ func (e *DefaultInterpreter) AggregateStatus(object *unstructured.Unstructured,
|
||||||
func (e *DefaultInterpreter) GetDependencies(object *unstructured.Unstructured) (dependencies []configv1alpha1.DependentObjectReference, err error) {
|
func (e *DefaultInterpreter) GetDependencies(object *unstructured.Unstructured) (dependencies []configv1alpha1.DependentObjectReference, err error) {
|
||||||
handler, exist := e.dependenciesHandlers[object.GroupVersionKind()]
|
handler, exist := e.dependenciesHandlers[object.GroupVersionKind()]
|
||||||
if !exist {
|
if !exist {
|
||||||
return dependencies, fmt.Errorf("defalut interpreter for operation %s not found", configv1alpha1.InterpreterOperationInterpretDependency)
|
return dependencies, fmt.Errorf("default interpreter for operation %s not found", configv1alpha1.InterpreterOperationInterpretDependency)
|
||||||
}
|
}
|
||||||
return handler(object)
|
return handler(object)
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,11 +146,6 @@ func (i *customResourceInterpreterImpl) Retain(desired *unstructured.Unstructure
|
||||||
func (i *customResourceInterpreterImpl) AggregateStatus(object *unstructured.Unstructured, aggregatedStatusItems []workv1alpha2.AggregatedStatusItem) (*unstructured.Unstructured, error) {
|
func (i *customResourceInterpreterImpl) AggregateStatus(object *unstructured.Unstructured, aggregatedStatusItems []workv1alpha2.AggregatedStatusItem) (*unstructured.Unstructured, error) {
|
||||||
klog.V(4).Infof("Begin to aggregate status for object: %v %s/%s.", object.GroupVersionKind(), object.GetNamespace(), object.GetName())
|
klog.V(4).Infof("Begin to aggregate status for object: %v %s/%s.", object.GroupVersionKind(), object.GetNamespace(), object.GetName())
|
||||||
|
|
||||||
// If status has not been collected, there is no need to aggregate.
|
|
||||||
if len(aggregatedStatusItems) == 0 {
|
|
||||||
return object, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
obj, hookEnabled, err := i.customizedInterpreter.Patch(context.TODO(), &webhook.RequestAttributes{
|
obj, hookEnabled, err := i.customizedInterpreter.Patch(context.TODO(), &webhook.RequestAttributes{
|
||||||
Operation: configv1alpha1.InterpreterOperationAggregateStatus,
|
Operation: configv1alpha1.InterpreterOperationAggregateStatus,
|
||||||
Object: object.DeepCopy(),
|
Object: object.DeepCopy(),
|
||||||
|
|
|
@ -67,7 +67,9 @@ func ParsingJobStatus(obj *batchv1.Job, status []workv1alpha2.AggregatedStatusIt
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if successfulJobs == len(status) {
|
// aggregated status can be empty when the binding is just created
|
||||||
|
// in which case we should not set the job status to complete
|
||||||
|
if successfulJobs == len(status) && successfulJobs > 0 {
|
||||||
newStatus.Conditions = append(newStatus.Conditions, batchv1.JobCondition{
|
newStatus.Conditions = append(newStatus.Conditions, batchv1.JobCondition{
|
||||||
Type: batchv1.JobComplete,
|
Type: batchv1.JobComplete,
|
||||||
Status: corev1.ConditionTrue,
|
Status: corev1.ConditionTrue,
|
||||||
|
|
Loading…
Reference in New Issue