Skip to content

Commit 7a3a593

Browse files
committed
Mark resources as progressing on spec changes
1 parent 42706a3 commit 7a3a593

10 files changed

+78
-3
lines changed

api/v1alpha1/gitrepository_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ type GitRepositoryVerification struct {
9999

100100
// GitRepositoryStatus defines the observed state of a Git repository.
101101
type GitRepositoryStatus struct {
102+
// ObservedGeneration is the last observed generation.
103+
// +optional
104+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
105+
106+
// Conditions holds the conditions for the GitRepository.
102107
// +optional
103108
Conditions []SourceCondition `json:"conditions,omitempty"`
104109

@@ -126,6 +131,7 @@ const (
126131
// to SourceCondition of type Ready with status unknown and
127132
// progressing reason and message. It returns the modified GitRepository.
128133
func GitRepositoryProgressing(repository GitRepository) GitRepository {
134+
repository.Status.ObservedGeneration = repository.Generation
129135
repository.Status.URL = ""
130136
repository.Status.Artifact = nil
131137
repository.Status.Conditions = []SourceCondition{}

api/v1alpha1/helmchart_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ type LocalHelmChartSourceReference struct {
6262

6363
// HelmChartStatus defines the observed state of the HelmChart.
6464
type HelmChartStatus struct {
65+
// ObservedGeneration is the last observed generation.
66+
// +optional
67+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
68+
69+
// Conditions holds the conditions for the HelmChart.
6570
// +optional
6671
Conditions []SourceCondition `json:"conditions,omitempty"`
6772

@@ -95,6 +100,7 @@ const (
95100
// HelmChartProgressing resets any failures and registers progress toward reconciling the given HelmChart
96101
// by setting the ReadyCondition to ConditionUnknown for ProgressingReason.
97102
func HelmChartProgressing(chart HelmChart) HelmChart {
103+
chart.Status.ObservedGeneration = chart.Generation
98104
chart.Status.URL = ""
99105
chart.Status.Artifact = nil
100106
chart.Status.Conditions = []SourceCondition{}

api/v1alpha1/helmrepository_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ type HelmRepositorySpec struct {
5454

5555
// HelmRepositoryStatus defines the observed state of the HelmRepository.
5656
type HelmRepositoryStatus struct {
57+
// ObservedGeneration is the last observed generation.
58+
// +optional
59+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
60+
61+
// Conditions holds the conditions for the HelmRepository.
5762
// +optional
5863
Conditions []SourceCondition `json:"conditions,omitempty"`
5964

@@ -80,6 +85,7 @@ const (
8085
// to SourceCondition of type Ready with status unknown and
8186
// progressing reason and message. It returns the modified HelmRepository.
8287
func HelmRepositoryProgressing(repository HelmRepository) HelmRepository {
88+
repository.Status.ObservedGeneration = repository.Generation
8389
repository.Status.URL = ""
8490
repository.Status.Artifact = nil
8591
repository.Status.Conditions = []SourceCondition{}

config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ spec:
153153
- url
154154
type: object
155155
conditions:
156+
description: Conditions holds the conditions for the GitRepository.
156157
items:
157158
description: SourceCondition contains condition information for
158159
a source.
@@ -182,6 +183,10 @@ spec:
182183
- type
183184
type: object
184185
type: array
186+
observedGeneration:
187+
description: ObservedGeneration is the last observed generation.
188+
format: int64
189+
type: integer
185190
url:
186191
description: URL is the download link for the artifact output of the
187192
last repository sync.

config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ spec:
125125
- url
126126
type: object
127127
conditions:
128+
description: Conditions holds the conditions for the HelmChart.
128129
items:
129130
description: SourceCondition contains condition information for
130131
a source.
@@ -154,6 +155,10 @@ spec:
154155
- type
155156
type: object
156157
type: array
158+
observedGeneration:
159+
description: ObservedGeneration is the last observed generation.
160+
format: int64
161+
type: integer
157162
url:
158163
description: URL is the download link for the last chart pulled.
159164
type: string

config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ spec:
105105
- url
106106
type: object
107107
conditions:
108+
description: Conditions holds the conditions for the HelmRepository.
108109
items:
109110
description: SourceCondition contains condition information for
110111
a source.
@@ -134,6 +135,10 @@ spec:
134135
- type
135136
type: object
136137
type: array
138+
observedGeneration:
139+
description: ObservedGeneration is the last observed generation.
140+
format: int64
141+
type: integer
137142
url:
138143
description: URL is the download link for the last index fetched.
139144
type: string

controllers/gitrepository_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ func (r *GitRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
9999
}
100100

101101
// set initial status
102-
if repository.Generation == 0 || repository.GetArtifact() != nil && !r.Storage.ArtifactExist(*repository.GetArtifact()) {
102+
if repository.Generation != repository.Status.ObservedGeneration ||
103+
repository.GetArtifact() != nil && !r.Storage.ArtifactExist(*repository.GetArtifact()) {
103104
repository = sourcev1.GitRepositoryProgressing(repository)
104105
if err := r.Status().Update(ctx, &repository); err != nil {
105106
log.Error(err, "unable to update status")

controllers/helmchart_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ func (r *HelmChartReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
104104
}
105105

106106
// set initial status
107-
if chart.Generation == 0 || chart.GetArtifact() != nil && !r.Storage.ArtifactExist(*chart.GetArtifact()) {
107+
if chart.Generation != chart.Status.ObservedGeneration ||
108+
chart.GetArtifact() != nil && !r.Storage.ArtifactExist(*chart.GetArtifact()) {
108109
chart = sourcev1.HelmChartProgressing(chart)
109110
if err := r.Status().Update(ctx, &chart); err != nil {
110111
log.Error(err, "unable to update status")

controllers/helmrepository_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ func (r *HelmRepositoryReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err
104104
}
105105

106106
// set initial status
107-
if repository.Generation == 0 || repository.GetArtifact() != nil && !r.Storage.ArtifactExist(*repository.GetArtifact()) {
107+
if repository.Generation != repository.Status.ObservedGeneration ||
108+
repository.GetArtifact() != nil && !r.Storage.ArtifactExist(*repository.GetArtifact()) {
108109
repository = sourcev1.HelmRepositoryProgressing(repository)
109110
if err := r.Status().Update(ctx, &repository); err != nil {
110111
log.Error(err, "unable to update status")

docs/api/source.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,18 @@ are.</p>
744744
<tbody>
745745
<tr>
746746
<td>
747+
<code>observedGeneration</code><br>
748+
<em>
749+
int64
750+
</em>
751+
</td>
752+
<td>
753+
<em>(Optional)</em>
754+
<p>ObservedGeneration is the last observed generation.</p>
755+
</td>
756+
</tr>
757+
<tr>
758+
<td>
747759
<code>conditions</code><br>
748760
<em>
749761
<a href="#source.toolkit.fluxcd.io/v1alpha1.SourceCondition">
@@ -753,6 +765,7 @@ are.</p>
753765
</td>
754766
<td>
755767
<em>(Optional)</em>
768+
<p>Conditions holds the conditions for the GitRepository.</p>
756769
</td>
757770
</tr>
758771
<tr>
@@ -921,6 +934,18 @@ Kubernetes meta/v1.Duration
921934
<tbody>
922935
<tr>
923936
<td>
937+
<code>observedGeneration</code><br>
938+
<em>
939+
int64
940+
</em>
941+
</td>
942+
<td>
943+
<em>(Optional)</em>
944+
<p>ObservedGeneration is the last observed generation.</p>
945+
</td>
946+
</tr>
947+
<tr>
948+
<td>
924949
<code>conditions</code><br>
925950
<em>
926951
<a href="#source.toolkit.fluxcd.io/v1alpha1.SourceCondition">
@@ -930,6 +955,7 @@ Kubernetes meta/v1.Duration
930955
</td>
931956
<td>
932957
<em>(Optional)</em>
958+
<p>Conditions holds the conditions for the HelmChart.</p>
933959
</td>
934960
</tr>
935961
<tr>
@@ -1059,6 +1085,18 @@ Kubernetes meta/v1.Duration
10591085
<tbody>
10601086
<tr>
10611087
<td>
1088+
<code>observedGeneration</code><br>
1089+
<em>
1090+
int64
1091+
</em>
1092+
</td>
1093+
<td>
1094+
<em>(Optional)</em>
1095+
<p>ObservedGeneration is the last observed generation.</p>
1096+
</td>
1097+
</tr>
1098+
<tr>
1099+
<td>
10621100
<code>conditions</code><br>
10631101
<em>
10641102
<a href="#source.toolkit.fluxcd.io/v1alpha1.SourceCondition">
@@ -1068,6 +1106,7 @@ Kubernetes meta/v1.Duration
10681106
</td>
10691107
<td>
10701108
<em>(Optional)</em>
1109+
<p>Conditions holds the conditions for the HelmRepository.</p>
10711110
</td>
10721111
</tr>
10731112
<tr>

0 commit comments

Comments
 (0)