Merge pull request #759 from fluxcd/log-on-new-artifact
Log on new artifact and failure recovery
This commit is contained in:
commit
ea1bab5a73
|
@ -370,13 +370,13 @@ func (r *BucketReconciler) reconcile(ctx context.Context, obj *sourcev1.Bucket,
|
|||
res = sreconcile.LowestRequeuingResult(res, recResult)
|
||||
}
|
||||
|
||||
r.notify(oldObj, obj, index, res, resErr)
|
||||
r.notify(ctx, oldObj, obj, index, res, resErr)
|
||||
|
||||
return res, resErr
|
||||
}
|
||||
|
||||
// notify emits notification related to the reconciliation.
|
||||
func (r *BucketReconciler) notify(oldObj, newObj *sourcev1.Bucket, index *etagIndex, res sreconcile.Result, resErr error) {
|
||||
func (r *BucketReconciler) notify(ctx context.Context, oldObj, newObj *sourcev1.Bucket, index *etagIndex, res sreconcile.Result, resErr error) {
|
||||
// Notify successful reconciliation for new artifact and recovery from any
|
||||
// failure.
|
||||
if resErr == nil && res == sreconcile.ResultSuccess && newObj.Status.Artifact != nil {
|
||||
|
@ -396,10 +396,12 @@ func (r *BucketReconciler) notify(oldObj, newObj *sourcev1.Bucket, index *etagIn
|
|||
if oldChecksum != newObj.GetArtifact().Checksum {
|
||||
r.AnnotatedEventf(newObj, annotations, corev1.EventTypeNormal,
|
||||
"NewArtifact", message)
|
||||
ctrl.LoggerFrom(ctx).Info(message)
|
||||
} else {
|
||||
if sreconcile.FailureRecovery(oldObj, newObj, bucketFailConditions) {
|
||||
r.AnnotatedEventf(newObj, annotations, corev1.EventTypeNormal,
|
||||
meta.SucceededReason, message)
|
||||
ctrl.LoggerFrom(ctx).Info(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1264,7 +1264,7 @@ func TestBucketReconciler_notify(t *testing.T) {
|
|||
"bbb": "ddd",
|
||||
},
|
||||
}
|
||||
reconciler.notify(oldObj, newObj, index, tt.res, tt.resErr)
|
||||
reconciler.notify(ctx, oldObj, newObj, index, tt.res, tt.resErr)
|
||||
|
||||
select {
|
||||
case x, ok := <-recorder.Events:
|
||||
|
|
|
@ -286,13 +286,13 @@ func (r *GitRepositoryReconciler) reconcile(ctx context.Context, obj *sourcev1.G
|
|||
res = sreconcile.LowestRequeuingResult(res, recResult)
|
||||
}
|
||||
|
||||
r.notify(oldObj, obj, commit, res, resErr)
|
||||
r.notify(ctx, oldObj, obj, commit, res, resErr)
|
||||
|
||||
return res, resErr
|
||||
}
|
||||
|
||||
// notify emits notification related to the result of reconciliation.
|
||||
func (r *GitRepositoryReconciler) notify(oldObj, newObj *sourcev1.GitRepository, commit git.Commit, res sreconcile.Result, resErr error) {
|
||||
func (r *GitRepositoryReconciler) notify(ctx context.Context, oldObj, newObj *sourcev1.GitRepository, commit git.Commit, res sreconcile.Result, resErr error) {
|
||||
// Notify successful reconciliation for new artifact, no-op reconciliation
|
||||
// and recovery from any failure.
|
||||
if r.shouldNotify(oldObj, newObj, res, resErr) {
|
||||
|
@ -319,10 +319,12 @@ func (r *GitRepositoryReconciler) notify(oldObj, newObj *sourcev1.GitRepository,
|
|||
if oldChecksum != newObj.GetArtifact().Checksum {
|
||||
r.AnnotatedEventf(newObj, annotations, corev1.EventTypeNormal,
|
||||
"NewArtifact", message)
|
||||
ctrl.LoggerFrom(ctx).Info(message)
|
||||
} else {
|
||||
if sreconcile.FailureRecovery(oldObj, newObj, gitRepositoryFailConditions) {
|
||||
r.AnnotatedEventf(newObj, annotations, corev1.EventTypeNormal,
|
||||
meta.SucceededReason, message)
|
||||
ctrl.LoggerFrom(ctx).Info(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1928,7 +1928,7 @@ func TestGitRepositoryReconciler_notify(t *testing.T) {
|
|||
EventRecorder: recorder,
|
||||
features: features.FeatureGates(),
|
||||
}
|
||||
reconciler.notify(oldObj, newObj, tt.commit, tt.res, tt.resErr)
|
||||
reconciler.notify(ctx, oldObj, newObj, tt.commit, tt.res, tt.resErr)
|
||||
|
||||
select {
|
||||
case x, ok := <-recorder.Events:
|
||||
|
|
|
@ -287,13 +287,13 @@ func (r *HelmChartReconciler) reconcile(ctx context.Context, obj *sourcev1.HelmC
|
|||
res = sreconcile.LowestRequeuingResult(res, recResult)
|
||||
}
|
||||
|
||||
r.notify(oldObj, obj, &build, res, resErr)
|
||||
r.notify(ctx, oldObj, obj, &build, res, resErr)
|
||||
|
||||
return res, resErr
|
||||
}
|
||||
|
||||
// notify emits notification related to the reconciliation.
|
||||
func (r *HelmChartReconciler) notify(oldObj, newObj *sourcev1.HelmChart, build *chart.Build, res sreconcile.Result, resErr error) {
|
||||
func (r *HelmChartReconciler) notify(ctx context.Context, oldObj, newObj *sourcev1.HelmChart, build *chart.Build, res sreconcile.Result, resErr error) {
|
||||
// Notify successful reconciliation for new artifact and recovery from any
|
||||
// failure.
|
||||
if resErr == nil && res == sreconcile.ResultSuccess && newObj.Status.Artifact != nil {
|
||||
|
@ -311,10 +311,12 @@ func (r *HelmChartReconciler) notify(oldObj, newObj *sourcev1.HelmChart, build *
|
|||
if oldChecksum != newObj.GetArtifact().Checksum {
|
||||
r.AnnotatedEventf(newObj, annotations, corev1.EventTypeNormal,
|
||||
reasonForBuild(build), build.Summary())
|
||||
ctrl.LoggerFrom(ctx).Info(build.Summary())
|
||||
} else {
|
||||
if sreconcile.FailureRecovery(oldObj, newObj, helmChartFailConditions) {
|
||||
r.AnnotatedEventf(newObj, annotations, corev1.EventTypeNormal,
|
||||
reasonForBuild(build), build.Summary())
|
||||
ctrl.LoggerFrom(ctx).Info(build.Summary())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1917,7 +1917,7 @@ func TestHelmChartReconciler_notify(t *testing.T) {
|
|||
Path: "some/path",
|
||||
Packaged: true,
|
||||
}
|
||||
reconciler.notify(oldObj, newObj, build, tt.res, tt.resErr)
|
||||
reconciler.notify(ctx, oldObj, newObj, build, tt.res, tt.resErr)
|
||||
|
||||
select {
|
||||
case x, ok := <-recorder.Events:
|
||||
|
|
|
@ -250,13 +250,13 @@ func (r *HelmRepositoryReconciler) reconcile(ctx context.Context, obj *sourcev1.
|
|||
res = sreconcile.LowestRequeuingResult(res, recResult)
|
||||
}
|
||||
|
||||
r.notify(oldObj, obj, chartRepo, res, resErr)
|
||||
r.notify(ctx, oldObj, obj, chartRepo, res, resErr)
|
||||
|
||||
return res, resErr
|
||||
}
|
||||
|
||||
// notify emits notification related to the reconciliation.
|
||||
func (r *HelmRepositoryReconciler) notify(oldObj, newObj *sourcev1.HelmRepository, chartRepo repository.ChartRepository, res sreconcile.Result, resErr error) {
|
||||
func (r *HelmRepositoryReconciler) notify(ctx context.Context, oldObj, newObj *sourcev1.HelmRepository, chartRepo repository.ChartRepository, res sreconcile.Result, resErr error) {
|
||||
// Notify successful reconciliation for new artifact and recovery from any
|
||||
// failure.
|
||||
if resErr == nil && res == sreconcile.ResultSuccess && newObj.Status.Artifact != nil {
|
||||
|
@ -281,11 +281,13 @@ func (r *HelmRepositoryReconciler) notify(oldObj, newObj *sourcev1.HelmRepositor
|
|||
if oldChecksum != newObj.GetArtifact().Checksum {
|
||||
r.AnnotatedEventf(newObj, annotations, corev1.EventTypeNormal,
|
||||
"NewArtifact", message)
|
||||
ctrl.LoggerFrom(ctx).Info(message)
|
||||
} else {
|
||||
if sreconcile.FailureRecovery(oldObj, newObj, helmRepositoryFailConditions) {
|
||||
r.AnnotatedEventf(newObj, annotations, corev1.EventTypeNormal,
|
||||
meta.SucceededReason, message)
|
||||
}
|
||||
ctrl.LoggerFrom(ctx).Info(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -229,11 +229,11 @@ func (r *HelmRepositoryOCIReconciler) reconcile(ctx context.Context, obj *v1beta
|
|||
ready := conditions.Get(obj, meta.ReadyCondition)
|
||||
// Became ready from not ready.
|
||||
if !conditions.IsReady(oldObj) && conditions.IsReady(obj) {
|
||||
r.Eventf(obj, corev1.EventTypeNormal, ready.Reason, ready.Message)
|
||||
r.eventLogf(ctx, obj, corev1.EventTypeNormal, ready.Reason, ready.Message)
|
||||
}
|
||||
// Became not ready from ready.
|
||||
if conditions.IsReady(oldObj) && !conditions.IsReady(obj) {
|
||||
r.Eventf(obj, corev1.EventTypeWarning, ready.Reason, ready.Message)
|
||||
r.eventLogf(ctx, obj, corev1.EventTypeWarning, ready.Reason, ready.Message)
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
|
@ -1069,7 +1069,7 @@ func TestHelmRepositoryReconciler_notify(t *testing.T) {
|
|||
chartRepo := repository.ChartRepository{
|
||||
URL: "some-address",
|
||||
}
|
||||
reconciler.notify(oldObj, newObj, chartRepo, tt.res, tt.resErr)
|
||||
reconciler.notify(ctx, oldObj, newObj, chartRepo, tt.res, tt.resErr)
|
||||
|
||||
select {
|
||||
case x, ok := <-recorder.Events:
|
||||
|
|
Loading…
Reference in New Issue