Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func startControllers(ctx *controllerContext) error {
overrideDirectory,
ctx.ResyncPeriod(),
ctx.InformerFactory.Config().V1().ClusterVersions(),
ctx.InformerFactory.Operatorstatus().V1().ClusterOperators(),
ctx.InformerFactory.Config().V1().ClusterOperators(),
ctx.ClientBuilder.RestConfig(),
ctx.ClientBuilder.ClientOrDie(componentName),
ctx.ClientBuilder.KubeClientOrDie(componentName),
Expand All @@ -264,7 +264,7 @@ func startControllers(ctx *controllerContext) error {
go autoupdate.New(
componentNamespace, componentName,
ctx.InformerFactory.Config().V1().ClusterVersions(),
ctx.InformerFactory.Operatorstatus().V1().ClusterOperators(),
ctx.InformerFactory.Config().V1().ClusterOperators(),
ctx.ClientBuilder.ClientOrDie(componentName),
ctx.ClientBuilder.KubeClientOrDie(componentName),
).Run(2, ctx.Stop)
Expand Down
2 changes: 1 addition & 1 deletion hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ ${PROJECT_ROOT}/vendor/k8s.io/code-generator/generate-groups.sh \
all \
github.com/openshift/cluster-version-operator/pkg/generated \
github.com/openshift/cluster-version-operator/pkg/apis \
"config.openshift.io:v1 operatorstatus.openshift.io:v1" \
"config.openshift.io:v1" \
$@ \
30 changes: 15 additions & 15 deletions lib/resourcemerge/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (
"k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

osv1 "github.com/openshift/cluster-version-operator/pkg/apis/operatorstatus.openshift.io/v1"
cvv1 "github.com/openshift/cluster-version-operator/pkg/apis/config.openshift.io/v1"
)

func EnsureClusterOperatorStatus(modified *bool, existing *osv1.ClusterOperator, required osv1.ClusterOperator) {
func EnsureClusterOperatorStatus(modified *bool, existing *cvv1.ClusterOperator, required cvv1.ClusterOperator) {
EnsureObjectMeta(modified, &existing.ObjectMeta, required.ObjectMeta)
ensureClusterOperatorStatus(modified, &existing.Status, required.Status)
}

func ensureClusterOperatorStatus(modified *bool, existing *osv1.ClusterOperatorStatus, required osv1.ClusterOperatorStatus) {
func ensureClusterOperatorStatus(modified *bool, existing *cvv1.ClusterOperatorStatus, required cvv1.ClusterOperatorStatus) {
if !equality.Semantic.DeepEqual(existing.Conditions, required.Conditions) {
*modified = true
existing.Conditions = required.Conditions
Expand All @@ -33,9 +33,9 @@ func ensureClusterOperatorStatus(modified *bool, existing *osv1.ClusterOperatorS
}
}

func SetOperatorStatusCondition(conditions *[]osv1.ClusterOperatorStatusCondition, newCondition osv1.ClusterOperatorStatusCondition) {
func SetOperatorStatusCondition(conditions *[]cvv1.ClusterOperatorStatusCondition, newCondition cvv1.ClusterOperatorStatusCondition) {
if conditions == nil {
conditions = &[]osv1.ClusterOperatorStatusCondition{}
conditions = &[]cvv1.ClusterOperatorStatusCondition{}
}
existingCondition := FindOperatorStatusCondition(*conditions, newCondition.Type)
if existingCondition == nil {
Expand All @@ -53,11 +53,11 @@ func SetOperatorStatusCondition(conditions *[]osv1.ClusterOperatorStatusConditio
existingCondition.Message = newCondition.Message
}

func RemoveOperatorStatusCondition(conditions *[]osv1.ClusterOperatorStatusCondition, conditionType osv1.ClusterStatusConditionType) {
func RemoveOperatorStatusCondition(conditions *[]cvv1.ClusterOperatorStatusCondition, conditionType cvv1.ClusterStatusConditionType) {
if conditions == nil {
conditions = &[]osv1.ClusterOperatorStatusCondition{}
conditions = &[]cvv1.ClusterOperatorStatusCondition{}
}
newConditions := []osv1.ClusterOperatorStatusCondition{}
newConditions := []cvv1.ClusterOperatorStatusCondition{}
for _, condition := range *conditions {
if condition.Type != conditionType {
newConditions = append(newConditions, condition)
Expand All @@ -67,7 +67,7 @@ func RemoveOperatorStatusCondition(conditions *[]osv1.ClusterOperatorStatusCondi
*conditions = newConditions
}

func FindOperatorStatusCondition(conditions []osv1.ClusterOperatorStatusCondition, conditionType osv1.ClusterStatusConditionType) *osv1.ClusterOperatorStatusCondition {
func FindOperatorStatusCondition(conditions []cvv1.ClusterOperatorStatusCondition, conditionType cvv1.ClusterStatusConditionType) *cvv1.ClusterOperatorStatusCondition {
for i := range conditions {
if conditions[i].Type == conditionType {
return &conditions[i]
Expand All @@ -77,15 +77,15 @@ func FindOperatorStatusCondition(conditions []osv1.ClusterOperatorStatusConditio
return nil
}

func IsOperatorStatusConditionTrue(conditions []osv1.ClusterOperatorStatusCondition, conditionType osv1.ClusterStatusConditionType) bool {
return IsOperatorStatusConditionPresentAndEqual(conditions, conditionType, osv1.ConditionTrue)
func IsOperatorStatusConditionTrue(conditions []cvv1.ClusterOperatorStatusCondition, conditionType cvv1.ClusterStatusConditionType) bool {
return IsOperatorStatusConditionPresentAndEqual(conditions, conditionType, cvv1.ConditionTrue)
}

func IsOperatorStatusConditionFalse(conditions []osv1.ClusterOperatorStatusCondition, conditionType osv1.ClusterStatusConditionType) bool {
return IsOperatorStatusConditionPresentAndEqual(conditions, conditionType, osv1.ConditionFalse)
func IsOperatorStatusConditionFalse(conditions []cvv1.ClusterOperatorStatusCondition, conditionType cvv1.ClusterStatusConditionType) bool {
return IsOperatorStatusConditionPresentAndEqual(conditions, conditionType, cvv1.ConditionFalse)
}

func IsOperatorStatusConditionPresentAndEqual(conditions []osv1.ClusterOperatorStatusCondition, conditionType osv1.ClusterStatusConditionType, status osv1.ConditionStatus) bool {
func IsOperatorStatusConditionPresentAndEqual(conditions []cvv1.ClusterOperatorStatusCondition, conditionType cvv1.ClusterStatusConditionType, status cvv1.ConditionStatus) bool {
for _, condition := range conditions {
if condition.Type == conditionType {
return condition.Status == status
Expand All @@ -94,7 +94,7 @@ func IsOperatorStatusConditionPresentAndEqual(conditions []osv1.ClusterOperatorS
return false
}

func IsOperatorStatusConditionNotIn(conditions []osv1.ClusterOperatorStatusCondition, conditionType osv1.ClusterStatusConditionType, status ...osv1.ConditionStatus) bool {
func IsOperatorStatusConditionNotIn(conditions []cvv1.ClusterOperatorStatusCondition, conditionType cvv1.ClusterStatusConditionType, status ...cvv1.ConditionStatus) bool {
for _, condition := range conditions {
if condition.Type == conditionType {
for _, s := range status {
Expand Down
3 changes: 0 additions & 3 deletions pkg/apis/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@ package apis

// ClusterVersionGroupName defines the API group for clusterversion.
const ClusterVersionGroupName = "config.openshift.io"

// OperatorStatusGroupName defines the API group for operatorstatus.
const OperatorStatusGroupName = "operatorstatus.openshift.io"
2 changes: 2 additions & 0 deletions pkg/apis/config.openshift.io/v1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&ClusterVersion{},
&ClusterVersionList{},
&ClusterOperator{},
&ClusterOperatorList{},
)

metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
Expand Down
115 changes: 107 additions & 8 deletions pkg/apis/config.openshift.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

osv1 "github.com/openshift/cluster-version-operator/pkg/apis/operatorstatus.openshift.io/v1"
"k8s.io/apimachinery/pkg/runtime"
)

// ClusterVersionList is a list of ClusterVersion resources.
Expand Down Expand Up @@ -109,7 +108,7 @@ type ClusterVersionStatus struct {
// by a temporary or permanent error. Conditions are only valid for the
// current desiredUpdate when metadata.generation is equal to
// status.generation.
Conditions []osv1.ClusterOperatorStatusCondition `json:"conditions"`
Conditions []ClusterOperatorStatusCondition `json:"conditions"`

// AvailableUpdates contains the list of updates that are appropriate
// for this cluster. This list may be empty if no updates are recommended,
Expand Down Expand Up @@ -148,8 +147,108 @@ type Update struct {
Payload string `json:"payload"`
}

// RetrievedUpdates reports whether available updates have been retrieved from
// the upstream update server. The condition is Unknown before retrieval, False
// if the updates could not be retrieved or recently failed, or True if the
// availableUpdates field is accurate and recent.
const RetrievedUpdates osv1.ClusterStatusConditionType = "RetrievedUpdates"
// ClusterOperatorList is a list of OperatorStatus resources.
// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type ClusterOperatorList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

Items []ClusterOperator `json:"items"`
}

// ClusterOperator is the Custom Resource object which holds the current state
// of an operator. This object is used by operators to convey their state to
// the rest of the cluster.
// +genclient
// +k8s:deepcopy-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type ClusterOperator struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`

// Spec hold the intent of how this operator should behave.
Spec ClusterOperatorSpec `json:"spec"`

// status holds the information about the state of an operator. It is consistent with status information across
// the kube ecosystem.
Status ClusterOperatorStatus `json:"status"`
}

// ClusterOperatorSpec is empty for now, but you could imagine holding information like "pause".
type ClusterOperatorSpec struct {
}

// ClusterOperatorStatus provides information about the status of the operator.
// +k8s:deepcopy-gen=true
type ClusterOperatorStatus struct {
// conditions describes the state of the operator's reconciliation functionality.
// +patchMergeKey=type
// +patchStrategy=merge
Conditions []ClusterOperatorStatusCondition `json:"conditions"`

// version indicates which version of the operator updated the current
// status object.
Version string `json:"version"`

// extension contains any additional status information specific to the
// operator which owns this status object.
Extension runtime.RawExtension `json:"extension,omitempty"`
}

type ConditionStatus string

// These are valid condition statuses. "ConditionTrue" means a resource is in the condition.
// "ConditionFalse" means a resource is not in the condition. "ConditionUnknown" means kubernetes
// can't decide if a resource is in the condition or not. In the future, we could add other
// intermediate conditions, e.g. ConditionDegraded.
const (
ConditionTrue ConditionStatus = "True"
ConditionFalse ConditionStatus = "False"
ConditionUnknown ConditionStatus = "Unknown"
)

// ClusterOperatorStatusCondition represents the state of the operator's
// reconciliation functionality.
// +k8s:deepcopy-gen=true
type ClusterOperatorStatusCondition struct {
// type specifies the state of the operator's reconciliation functionality.
Type ClusterStatusConditionType `json:"type"`

// Status of the condition, one of True, False, Unknown.
Status ConditionStatus `json:"status"`

// LastTransitionTime is the time of the last update to the current status object.
LastTransitionTime metav1.Time `json:"lastTransitionTime"`

// reason is the reason for the condition's last transition. Reasons are CamelCase
Reason string `json:"reason,omitempty"`

// message provides additional information about the current condition.
// This is only to be consumed by humans.
Message string `json:"message,omitempty"`
}

// ClusterStatusConditionType is the state of the operator's reconciliation functionality.
type ClusterStatusConditionType string

const (
// OperatorAvailable indicates that the binary maintained by the operator (eg: openshift-apiserver for the
// openshift-apiserver-operator), is functional and available in the cluster.
OperatorAvailable ClusterStatusConditionType = "Available"

// OperatorProgressing indicates that the operator is actively making changes to the binary maintained by the
// operator (eg: openshift-apiserver for the openshift-apiserver-operator).
OperatorProgressing ClusterStatusConditionType = "Progressing"

// OperatorFailing indicates that the operator has encountered an error that is preventing it from working properly.
// The binary maintained by the operator (eg: openshift-apiserver for the openshift-apiserver-operator) may still be
// available, but the user intent cannot be fulfilled.
OperatorFailing ClusterStatusConditionType = "Failing"

// RetrievedUpdates reports whether available updates have been retrieved from
// the upstream update server. The condition is Unknown before retrieval, False
// if the updates could not be retrieved or recently failed, or True if the
// availableUpdates field is accurate and recent.
RetrievedUpdates ClusterStatusConditionType = "RetrievedUpdates"
)
105 changes: 103 additions & 2 deletions pkg/apis/config.openshift.io/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading