m88i / nexus-operator

Sonatype Nexus OSS Kubernetes Operator based on Operator SDK
http://operatorhub.io/operator/nexus-operator-m88i
Apache License 2.0
50 stars 15 forks source link

Update Nexus CR Status to use the Conditions API #213

Open ricardozanini opened 3 years ago

ricardozanini commented 3 years ago

Is your feature request related to a problem? Please describe. Right now we are not keeping the entire history of the CR status in the Nexus object, what we have is:

// NexusStatus defines the observed state of Nexus
// +k8s:openapi-gen=true
type NexusStatus struct {
    // Condition status for the Nexus deployment
    // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
    // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors.displayName="appsv1.DeploymentStatus"
    DeploymentStatus v1.DeploymentStatus `json:"deploymentStatus,omitempty"`
    // Will be "OK" when this Nexus instance is up
    // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
    NexusStatus NexusStatusType `json:"nexusStatus,omitempty"`
    // Gives more information about a failure status
    // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
    Reason string `json:"reason,omitempty"`
    // Route for external service access
    // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
    NexusRoute string `json:"nexusRoute,omitempty"`
    // Conditions reached during an update
    // +listType=atomic
    // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true
    // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors.displayName="Update Conditions"
    UpdateConditions []string `json:"updateConditions,omitempty"`
    // ServerOperationsStatus describes the general status for the operations performed in the Nexus server instance
    ServerOperationsStatus OperationsStatus `json:"serverOperationsStatus,omitempty"`
}

Although is interesting to reflect the internal Deployment status, ideally we would carry the conditions array ourselves. See an example: https://medium.com/swlh/advanced-kubernetes-operators-development-988edad5f58a (Set Status Conditions section)

Describe the solution you'd like To add the Status.Conditions[] field to the Nexus CR.

Describe alternatives you've considered Right now we have only the latest "condition" described in our CR

Additional context This article brings a glimpse about this implementation. But we can also see Knative CRs for other references.

LCaparelli commented 3 years ago

Some previous experience:

ricardozanini commented 3 years ago

this is a bit subjective, but IMO it makes sense to simply overwrite the timestamp of the most recent condition if we're about to report the same exact condition again

Yup. The idea is to have each condition in the array with the latest status and the status set to true for those we currently are. It's a state diagram-like implementation.