status: record progressing

Set ready condition to unknown while the reconciliation is progressing.
This allows other operators to wait for a sync to complete.
This commit is contained in:
stefanprodan 2020-04-27 11:16:10 +03:00
parent 9af721f431
commit 8071dadbf0
8 changed files with 76 additions and 2 deletions

View File

@ -69,4 +69,8 @@ const (
// VerificationFailedReason represents the fact that the cryptographic provenance
// verification for the source failed.
VerificationFailedReason string = "VerificationFailed"
// ProgressingReason represents the fact that a source reconciliation
// is underway.
ProgressingReason string = "Progressing"
)

View File

@ -113,7 +113,7 @@ const (
)
// GitRepositoryReady sets the given artifact and url on the
// HelmRepository and resets the conditions to SourceCondition of
// GitRepository and resets the conditions to SourceCondition of
// type Ready with status true and the given reason and message.
// It returns the modified GitRepository.
func GitRepositoryReady(repository GitRepository, artifact Artifact, url, reason, message string) GitRepository {
@ -139,7 +139,23 @@ func GitRepositoryReady(repository GitRepository, artifact Artifact, url, reason
return repository
}
// GitRepositoryNotReady resets the conditions of the HelmRepository
// GitRepositoryProgressing resets the conditions of the GitRepository
// to SourceCondition of type Ready with status unknown and
// progressing reason and message. It returns the modified GitRepository.
func GitRepositoryProgressing(repository GitRepository) GitRepository {
repository.Status.Conditions = []SourceCondition{
{
Type: ReadyCondition,
Status: corev1.ConditionUnknown,
LastTransitionTime: metav1.Now(),
Reason: ProgressingReason,
Message: "reconciliation in progress",
},
}
return repository
}
// GitRepositoryNotReady resets the conditions of the GitRepository
// to SourceCondition of type Ready with status false and the given
// reason and message. It returns the modified GitRepository.
func GitRepositoryNotReady(repository GitRepository, reason, message string) GitRepository {

View File

@ -93,6 +93,22 @@ func HelmChartReady(chart HelmChart, artifact Artifact, url, reason, message str
return chart
}
// HelmChartProgressing resets the conditions of the HelmChart
// to SourceCondition of type Ready with status unknown and
// progressing reason and message. It returns the modified HelmChart.
func HelmChartProgressing(chart HelmChart) HelmChart {
chart.Status.Conditions = []SourceCondition{
{
Type: ReadyCondition,
Status: corev1.ConditionUnknown,
LastTransitionTime: metav1.Now(),
Reason: ProgressingReason,
Message: "reconciliation in progress",
},
}
return chart
}
// HelmChartNotReady resets the conditions of the HelmChart to
// SourceCondition of type Ready with status false and the given
// reason and message. It returns the modified HelmChart.

View File

@ -92,6 +92,22 @@ func HelmRepositoryReady(repository HelmRepository, artifact Artifact, url, reas
return repository
}
// HelmRepositoryProgressing resets the conditions of the HelmRepository
// to SourceCondition of type Ready with status unknown and
// progressing reason and message. It returns the modified HelmRepository.
func HelmRepositoryProgressing(repository HelmRepository) HelmRepository {
repository.Status.Conditions = []SourceCondition{
{
Type: ReadyCondition,
Status: corev1.ConditionUnknown,
LastTransitionTime: metav1.Now(),
Reason: ProgressingReason,
Message: "reconciliation in progress",
},
}
return repository
}
// HelmRepositoryNotReady resets the conditions of the HelmRepository
// to SourceCondition of type Ready with status false and the given
// reason and message. It returns the modified HelmRepository.

View File

@ -68,6 +68,12 @@ func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
log.Error(err, "unable to update GitRepository status")
return ctrl.Result{Requeue: true}, err
}
} else {
repo = sourcev1.GitRepositoryProgressing(repo)
if err := r.Status().Update(ctx, &repo); err != nil {
log.Error(err, "unable to update GitRepository status")
return ctrl.Result{Requeue: true}, err
}
}
// try to remove old artifacts

View File

@ -68,6 +68,12 @@ func (r *HelmChartReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
log.Error(err, "unable to update HelmChart status")
return ctrl.Result{Requeue: true}, err
}
} else {
chart = sourcev1.HelmChartProgressing(chart)
if err := r.Status().Update(ctx, &chart); err != nil {
log.Error(err, "unable to update HelmChart status")
return ctrl.Result{Requeue: true}, err
}
}
// try to remove old artifacts

View File

@ -70,6 +70,12 @@ func (r *HelmRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err
log.Error(err, "unable to update HelmRepository status")
return ctrl.Result{Requeue: true}, err
}
} else {
repository = sourcev1.HelmRepositoryProgressing(repository)
if err := r.Status().Update(ctx, &repository); err != nil {
log.Error(err, "unable to update HelmRepository status")
return ctrl.Result{Requeue: true}, err
}
}
// try to remove old artifacts

View File

@ -138,6 +138,10 @@ const (
// VerificationFailedReason represents the fact that the cryptographic provenance
// verification for the source failed.
VerificationFailedReason string = "VerificationFailed"
// ProgressingReason represents the fact that a source reconciliation
// is underway.
ProgressingReason string = "Progressing"
)
```