Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions pkg/reconciler/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,16 @@ func (r *Reconciler) propagateDependencyReadiness(dependencyObjRef corev1.Object
return fmt.Errorf("getting the dependency: %v", err)
}
dependency := dependencyObj.(*duckv1alpha1.KResource)
// Temporarily comment it until we figure out whether we update Status.ObservedGeneration when KResource changes
// From manual testing, it looks like we never update Status.ObservedGeneration
//if dependency.GetGeneration() != dependency.Status.ObservedGeneration {
// logging.FromContext(ctx).Error("The ObjectMeta Generation of dependency is not equal to the observedGeneration of status",
// zap.Any("ObjectMeta Generation of dependency", dependency.GetGeneration()),
// zap.Any("ObservedGeneration of status", dependency.Status.ObservedGeneration))
// t.Status.MarkDependencyUnknown("GenerationNotEqual", "The ObjectMeta Generation of dependency %d is not equal to the ObservedGeneration of status %d", dependency.GetGeneration(), dependency.Status.ObservedGeneration)
// return nil
//}

// The dependency hasn't yet reconciled our latest changes to
// its desired state, so its conditions are outdated.
if dependency.GetGeneration() != dependency.Status.ObservedGeneration {
logging.FromContext(ctx).Info("The ObjectMeta Generation of dependency is not equal to the observedGeneration of status",
zap.Any("objectMetaGeneration", dependency.GetGeneration()),
zap.Any("statusObservedGeneration", dependency.Status.ObservedGeneration))
t.Status.MarkDependencyUnknown("GenerationNotEqual", "The dependency's metadata.generation, %q, is not equal to its status.observedGeneration, %q.", dependency.GetGeneration(), dependency.Status.ObservedGeneration)
return nil
}
t.Status.PropagateDependencyStatus(dependency)
return nil
}
Expand Down
41 changes: 41 additions & 0 deletions pkg/reconciler/trigger/trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ const (
testSchedule = "*/2 * * * *"
testData = "data"
sinkName = "testsink"

currentGeneration = 1
outdatedGeneration = 0
)

var (
Expand Down Expand Up @@ -568,6 +571,37 @@ func TestAllCases(t *testing.T) {
),
}},
}, {
Name: "Dependency generation not equal",
Key: triggerKey,
Objects: []runtime.Object{
makeReadyBroker(),
makeBrokerFilterService(),
makeReadySubscription(),
makeGenerationNotEqualCronJobSource(),
reconciletesting.NewTrigger(triggerName, testNS, brokerName,
reconciletesting.WithTriggerUID(triggerUID),
reconciletesting.WithTriggerSubscriberURI(subscriberURI),
reconciletesting.WithInitTriggerConditions,
reconciletesting.WithDependencyAnnotation(dependencyAnnotation),
),
},
WantErr: false,
WantEvents: []string{
Eventf(corev1.EventTypeNormal, "TriggerReconciled", "Trigger reconciled")},
WantStatusUpdates: []clientgotesting.UpdateActionImpl{{
Object: reconciletesting.NewTrigger(triggerName, testNS, brokerName,
reconciletesting.WithTriggerUID(triggerUID),
reconciletesting.WithTriggerSubscriberURI(subscriberURI),
// The first reconciliation will initialize the status conditions.
reconciletesting.WithInitTriggerConditions,
reconciletesting.WithDependencyAnnotation(dependencyAnnotation),
reconciletesting.WithTriggerBrokerReady(),
reconciletesting.WithTriggerSubscribed(),
reconciletesting.WithTriggerStatusSubscriberURI(subscriberURI),
reconciletesting.WithTriggerDependencyUnknown("GenerationNotEqual", fmt.Sprintf("The dependency's metadata.generation, %q, is not equal to its status.observedGeneration, %q.", currentGeneration, outdatedGeneration))),
}},
},
{
Name: "Dependency ready",
Key: triggerKey,
Objects: []runtime.Object{
Expand Down Expand Up @@ -761,6 +795,13 @@ func makeNotReadyCronJobSource() *sourcesv1alpha1.CronJobSource {
return NewCronJobSource(cronJobSourceName, testNS, WithCronJobApiVersion(cronJobSourceAPIVersion), WithCronJobSourceSinkNotFound)
}

func makeGenerationNotEqualCronJobSource() *sourcesv1alpha1.CronJobSource {
c := makeNotReadyCronJobSource()
c.Generation = currentGeneration
c.Status.ObservedGeneration = outdatedGeneration
return c
}

func makeReadyCronJobSource() *sourcesv1alpha1.CronJobSource {
return NewCronJobSource(cronJobSourceName, testNS,
WithCronJobApiVersion(cronJobSourceAPIVersion),
Expand Down