Small adjustments to CRD additional print columns
Change-Id: I3e5ed921118d7db8c1bf38d7f4931c704d9c3712 Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
This commit is contained in:
parent
0f3ef2a6c9
commit
97033111fe
@ -135,27 +135,14 @@ type ArmadaChartStatus struct {
|
||||
// +optional
|
||||
Conditions []metav1.Condition `json:"conditions,omitempty"`
|
||||
|
||||
// LastAppliedRevision is the revision of the last successfully applied source.
|
||||
// +optional
|
||||
LastAppliedRevision string `json:"lastAppliedRevision,omitempty"`
|
||||
|
||||
// LastAttemptedRevision is the revision of the last reconciliation attempt.
|
||||
// +optional
|
||||
LastAttemptedRevision string `json:"lastAttemptedRevision,omitempty"`
|
||||
|
||||
// LastAttemptedValuesChecksum is the SHA1 checksum of the values of the last
|
||||
// LastAppliedValuesChecksum is the SHA1 checksum of the values of the last
|
||||
// reconciliation attempt.
|
||||
// +optional
|
||||
LastAttemptedValuesChecksum string `json:"lastAttemptedValuesChecksum,omitempty"`
|
||||
LastAppliedValuesChecksum string `json:"lastAttemptedValuesChecksum,omitempty"`
|
||||
|
||||
// LastReleaseRevision is the revision of the last successful Helm release.
|
||||
// LastAppliedChartSource is the URL of chart of the last reconciliation attempt
|
||||
// +optional
|
||||
LastReleaseRevision int `json:"lastReleaseRevision,omitempty"`
|
||||
|
||||
// HelmChart is the namespaced name of the HelmChart resource created by
|
||||
// the controller for the ArmadaChart.
|
||||
// +optional
|
||||
HelmChart string `json:"helmChart,omitempty"`
|
||||
LastAppliedChartSource string `json:"lastAttemptedChartSource,omitempty"`
|
||||
|
||||
// Failures is the reconciliation failure count against the latest desired
|
||||
// state. It is reset after a successful reconciliation.
|
||||
@ -229,7 +216,6 @@ func ArmadaChartReady(ac ArmadaChart) ArmadaChart {
|
||||
Message: "Release reconciliation succeeded",
|
||||
}
|
||||
apimeta.SetStatusCondition(ac.GetStatusConditions(), newCondition)
|
||||
ac.Status.LastAppliedRevision = ac.Status.LastAttemptedRevision
|
||||
resetFailureCounts(&ac)
|
||||
setTested(&ac)
|
||||
return ac
|
||||
@ -299,13 +285,12 @@ func setConfigDefaults(config *rest.Config) error {
|
||||
|
||||
//+kubebuilder:object:root=true
|
||||
//+kubebuilder:subresource:status
|
||||
// +kubebuilder:printcolumn:name="Namespace",type=string,JSONPath=`.metadata.namespace`
|
||||
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
// +kubebuilder:printcolumn:name="Ready",type=boolean,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
|
||||
// +kubebuilder:printcolumn:name="Message",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].message`,priority=10
|
||||
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
|
||||
// +kubebuilder:printcolumn:name="Helm Status",type=string,JSONPath=`.status.helmStatus`
|
||||
// +kubebuilder:printcolumn:name="Wait Completed",type=boolean,JSONPath=`.status.waitCompleted`
|
||||
// +kubebuilder:printcolumn:name="Wait Done",type=boolean,JSONPath=`.status.waitCompleted`
|
||||
// +kubebuilder:printcolumn:name="Tested",type=boolean,JSONPath=`.status.tested`
|
||||
// +kubebuilder:printcolumn:name="Message",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].message`,priority=10
|
||||
|
||||
// ArmadaChart is the Schema for the armadacharts API
|
||||
type ArmadaChart struct {
|
||||
|
@ -69,7 +69,7 @@ func main() {
|
||||
opts.BindFlags(flag.CommandLine)
|
||||
flag.Parse()
|
||||
|
||||
managerLogger := zap.New()
|
||||
managerLogger := zap.New(zap.ConsoleEncoder())
|
||||
ctrl.SetLogger(managerLogger)
|
||||
klog.SetLoggerWithOptions(managerLogger.WithName("runtime"), klog.ContextualLogger(true))
|
||||
|
||||
|
@ -15,28 +15,25 @@ spec:
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- additionalPrinterColumns:
|
||||
- jsonPath: .metadata.namespace
|
||||
name: Namespace
|
||||
type: string
|
||||
- jsonPath: .metadata.creationTimestamp
|
||||
name: Age
|
||||
type: date
|
||||
- jsonPath: .status.conditions[?(@.type=="Ready")].status
|
||||
name: Ready
|
||||
type: boolean
|
||||
- jsonPath: .status.conditions[?(@.type=="Ready")].message
|
||||
name: Message
|
||||
priority: 10
|
||||
type: string
|
||||
- jsonPath: .status.helmStatus
|
||||
name: Helm Status
|
||||
type: string
|
||||
- jsonPath: .status.waitCompleted
|
||||
name: Wait Completed
|
||||
name: Wait Done
|
||||
type: boolean
|
||||
- jsonPath: .status.tested
|
||||
name: Tested
|
||||
type: boolean
|
||||
- jsonPath: .status.conditions[?(@.type=="Ready")].message
|
||||
name: Message
|
||||
priority: 10
|
||||
type: string
|
||||
name: v1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
@ -219,10 +216,6 @@ spec:
|
||||
the latest desired state. It is reset after a successful reconciliation.
|
||||
format: int64
|
||||
type: integer
|
||||
helmChart:
|
||||
description: HelmChart is the namespaced name of the HelmChart resource
|
||||
created by the controller for the ArmadaChart.
|
||||
type: string
|
||||
helmStatus:
|
||||
description: HelmStatus describes the status of helm release
|
||||
type: string
|
||||
@ -231,22 +224,14 @@ spec:
|
||||
the latest desired state. It is reset after a successful reconciliation.
|
||||
format: int64
|
||||
type: integer
|
||||
lastAppliedRevision:
|
||||
description: LastAppliedRevision is the revision of the last successfully
|
||||
applied source.
|
||||
type: string
|
||||
lastAttemptedRevision:
|
||||
description: LastAttemptedRevision is the revision of the last reconciliation
|
||||
attempt.
|
||||
lastAttemptedChartSource:
|
||||
description: LastAppliedChartSource is the URL of chart of the last
|
||||
reconciliation attempt
|
||||
type: string
|
||||
lastAttemptedValuesChecksum:
|
||||
description: LastAttemptedValuesChecksum is the SHA1 checksum of the
|
||||
description: LastAppliedValuesChecksum is the SHA1 checksum of the
|
||||
values of the last reconciliation attempt.
|
||||
type: string
|
||||
lastReleaseRevision:
|
||||
description: LastReleaseRevision is the revision of the last successful
|
||||
Helm release.
|
||||
type: integer
|
||||
observedGeneration:
|
||||
description: ObservedGeneration is the last observed generation.
|
||||
format: int64
|
||||
|
@ -189,6 +189,9 @@ func (r *ArmadaChartReconciler) reconcileChart(ctx context.Context,
|
||||
if rel.Info.Status.IsPending() {
|
||||
log.Info("warning: release in pending state, unlocking")
|
||||
rel.SetStatus(release.StatusFailed, fmt.Sprintf("release unlocked from stale state"))
|
||||
if err = run.UpdateReleaseStatus(rel); err != nil {
|
||||
return armadav1.ArmadaChartNotReady(ac, "UpdateHelmStatusFailed", err.Error()), err
|
||||
}
|
||||
} else {
|
||||
for _, delRes := range ac.Spec.Upgrade.PreUpgrade.Delete {
|
||||
log.Info(fmt.Sprintf("deleting all %ss in %s ns with labels %v", delRes.Type, ac.Spec.Namespace, delRes.Labels))
|
||||
@ -221,6 +224,7 @@ func (r *ArmadaChartReconciler) reconcileChart(ctx context.Context,
|
||||
return armadav1.ArmadaChartNotReady(ac, "InstallUpgradeFailed", err.Error()), err
|
||||
}
|
||||
ac.Status.HelmStatus = string(rel.Info.Status)
|
||||
ac.Status.LastAppliedChartSource = ac.Spec.Source.Location
|
||||
if err := r.patchStatus(ctx, &ac); err != nil {
|
||||
log.Error(err, "unable to update armadachart status")
|
||||
}
|
||||
@ -241,7 +245,6 @@ func (r *ArmadaChartReconciler) waitRelease(ctx context.Context, restCfg *rest.C
|
||||
log := ctrl.LoggerFrom(ctx)
|
||||
|
||||
if hr.Status.WaitCompleted {
|
||||
log.Info("wait has been already completed")
|
||||
return hr, nil
|
||||
}
|
||||
|
||||
@ -430,11 +433,6 @@ func isUpdateRequired(ctx context.Context, release *release.Release, chrt *chart
|
||||
log.Info(cmp.Diff(release.Chart.Templates, chrt.Templates))
|
||||
return true
|
||||
|
||||
//case !cmp.Equal(release.Chart.Values, chrt.Values, cmpopts.EquateEmpty()):
|
||||
// log.Info("There are CHART DEF VALUES diffs")
|
||||
// log.Info(cmp.Diff(release.Chart.Values, chrt.Values, cmpopts.EquateEmpty()))
|
||||
// return true
|
||||
|
||||
case !cmp.Equal(release.Config, vals.AsMap(), cmpopts.EquateEmpty()):
|
||||
log.Info("There are chart values diffs found")
|
||||
log.Info(cmp.Diff(release.Config, vals.AsMap(), cmpopts.EquateEmpty()))
|
||||
|
@ -157,6 +157,11 @@ func (r *Runner) ObserveLastRelease(ac armadav1.ArmadaChart) (*release.Release,
|
||||
return rel, err
|
||||
}
|
||||
|
||||
// UpdateReleaseStatus sets the new status for release
|
||||
func (r *Runner) UpdateReleaseStatus(rel *release.Release) error {
|
||||
return r.config.Releases.Update(rel)
|
||||
}
|
||||
|
||||
func wrapActionErr(log *LogBuffer, err error) error {
|
||||
if err == nil {
|
||||
return err
|
||||
|
@ -120,6 +120,11 @@ func processEvent(logger logr.Logger, event watch.Event, minReady *MinReady) (St
|
||||
return Error, errors.New(fmt.Sprintf("resource %s: got error event %s", metaObj.GetName(), event.Object))
|
||||
}
|
||||
|
||||
if event.Type == "DELETED" {
|
||||
logger.Info("Resource %s: removed from tracking", metaObj.GetName())
|
||||
return Skipped, nil
|
||||
}
|
||||
|
||||
status := getObjectStatus(event.Object, minReady)
|
||||
logger.Info(fmt.Sprintf("object type: %T, status: %s", event.Object, status.Msg))
|
||||
return status.StatusType, nil
|
||||
@ -384,7 +389,7 @@ func (c *WaitOptions) Wait(parent context.Context) error {
|
||||
}
|
||||
|
||||
cfu := func(event watch.Event) (bool, error) {
|
||||
if ready, err := processEvent(c.Logger, event, minReady); ready != Ready || err != nil {
|
||||
if ready, err := processEvent(c.Logger, event, minReady); (ready != Ready && ready != Skipped) || err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user