Skip to content

Commit

Permalink
refactor(crds)!: consistently use message field instead of error field (
Browse files Browse the repository at this point in the history
#1542)

Signed-off-by: Kent Rancourt <kent.rancourt@gmail.com>
  • Loading branch information
krancour authored Feb 27, 2024
1 parent 4eaa541 commit 5912e5a
Show file tree
Hide file tree
Showing 12 changed files with 181 additions and 180 deletions.
4 changes: 2 additions & 2 deletions api/v1alpha1/stage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,9 @@ type StageStatus struct {
History FreightReferenceStack `json:"history,omitempty"`
// Health is the Stage's last observed health.
Health *Health `json:"health,omitempty"`
// Error describes any errors that are preventing the Stage controller
// Message describes any errors that are preventing the Stage controller
// from assessing Stage health or from finding new Freight.
Error string `json:"error,omitempty"`
Message string `json:"message,omitempty"`
// ObservedGeneration represents the .metadata.generation that this Stage
// status was reconciled against.
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ message FreightReference {
message StageStatus {
optional FreightReference current_freight = 2 [json_name = "currentFreight"];
repeated FreightReference history = 3 [json_name = "history"];
string error = 4 [json_name = "error"];
string message = 4 [json_name = "message"];
optional Health health = 5 [json_name = "health"];
optional PromotionInfo current_promotion = 6 [json_name = "currentPromotion"];
string phase = 7 [json_name = "phase"];
Expand Down Expand Up @@ -296,7 +296,7 @@ message WarehouseSpec {
}

message WarehouseStatus {
string error = 1 [json_name = "error"];
string message = 1 [json_name = "message"];
int64 observed_generation = 2 [json_name = "observedGeneration"];
}

Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/warehouse_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ type ChartSubscription struct {

// WarehouseStatus describes a Warehouse's most recently observed state.
type WarehouseStatus struct {
// Error describes any errors that are preventing the Warehouse controller
// Message describes any errors that are preventing the Warehouse controller
// from polling repositories to discover new Freight.
Error string `json:"error,omitempty"`
Message string `json:"message,omitempty"`
// ObservedGeneration represents the .metadata.generation that this Warehouse
// was reconciled against.
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Expand Down
10 changes: 5 additions & 5 deletions charts/kargo/crds/kargo.akuity.io_stages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -844,11 +844,6 @@ spec:
- freight
- name
type: object
error:
description: |-
Error describes any errors that are preventing the Stage controller
from assessing Stage health or from finding new Freight.
type: string
health:
description: Health is the Stage's last observed health.
properties:
Expand Down Expand Up @@ -1056,6 +1051,11 @@ spec:
type: object
type: object
type: array
message:
description: |-
Message describes any errors that are preventing the Stage controller
from assessing Stage health or from finding new Freight.
type: string
observedGeneration:
description: |-
ObservedGeneration represents the .metadata.generation that this Stage
Expand Down
4 changes: 2 additions & 2 deletions charts/kargo/crds/kargo.akuity.io_warehouses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ spec:
status:
description: Status describes the Warehouse's most recently observed state.
properties:
error:
message:
description: |-
Error describes any errors that are preventing the Warehouse controller
Message describes any errors that are preventing the Warehouse controller
from polling repositories to discover new Freight.
type: string
observedGeneration:
Expand Down
6 changes: 3 additions & 3 deletions internal/api/types/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func FromStageStatusProto(s *v1alpha1.StageStatus) *kargoapi.StageStatus {
CurrentFreight: FromFreightReferenceProto(s.GetCurrentFreight()),
History: history,
Health: FromHealthProto(s.GetHealth()),
Error: s.GetError(),
Message: s.GetMessage(),
}
}

Expand Down Expand Up @@ -760,7 +760,7 @@ func ToStageProto(e kargoapi.Stage) *v1alpha1.Stage {
CurrentPromotion: currentPromotion,
History: history,
Health: health,
Error: e.Status.Error,
Message: e.Status.Message,
},
}
}
Expand Down Expand Up @@ -1082,7 +1082,7 @@ func ToWarehouseProto(w kargoapi.Warehouse) *v1alpha1.Warehouse {
var status *v1alpha1.WarehouseStatus
if w.GetStatus() != nil {
status = &v1alpha1.WarehouseStatus{
Error: w.GetStatus().Error,
Message: w.GetStatus().Message,
ObservedGeneration: w.GetStatus().ObservedGeneration,
}
}
Expand Down
6 changes: 3 additions & 3 deletions internal/controller/stages/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,12 +521,12 @@ func (r *reconciler) Reconcile(
newStatus, err = r.syncNormalStage(ctx, stage)
}
if err != nil {
newStatus.Error = err.Error()
logger.Errorf("error syncing Stage: %s", stage.Status.Error)
newStatus.Message = err.Error()
logger.Errorf("error syncing Stage: %s", stage.Status.Message)
} else {
// Be sure to blank this out in case there's an error in this field from
// the previous reconciliation
newStatus.Error = ""
newStatus.Message = ""
}

updateErr := kubeclient.PatchStatus(ctx, r.kargoClient, stage, func(status *kargoapi.StageStatus) {
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/warehouses/warehouses.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (r *reconciler) Reconcile(

newStatus, err := r.syncWarehouse(ctx, warehouse)
if err != nil {
newStatus.Error = err.Error()
newStatus.Message = err.Error()
logger.Errorf("error syncing Warehouse: %s", err)
}

Expand Down Expand Up @@ -236,7 +236,7 @@ func (r *reconciler) syncWarehouse(
) (kargoapi.WarehouseStatus, error) {
status := *warehouse.Status.DeepCopy()
status.ObservedGeneration = warehouse.Generation
status.Error = "" // Clear any previous error
status.Message = "" // Clear any previous error

logger := logging.LoggerFromContext(ctx)

Expand Down
Loading

0 comments on commit 5912e5a

Please sign in to comment.