Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align Eventing conditions with Serving conditions. #62

Merged
Merged
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
31 changes: 31 additions & 0 deletions pkg/apis/operator/v1alpha1/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright 2020 The Knative Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import "knative.dev/pkg/apis"

const (
// DependenciesInstalled is a Condition indicating that potential dependencies have
// been installed correctly.
DependenciesInstalled apis.ConditionType = "DependenciesInstalled"
// InstallSucceeded is a Condition indiciating that the installation of the component
// itself has been successful.
InstallSucceeded apis.ConditionType = "InstallSucceeded"
// DeploymentsAvailable is a Condition indicating whether or not the Deployments of
// the respective component have come up successfully.
DeploymentsAvailable apis.ConditionType = "DeploymentsAvailable"
)
62 changes: 44 additions & 18 deletions pkg/apis/operator/v1alpha1/knativeeventing_lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import (
)

var eventingCondSet = apis.NewLivingConditionSet(
EventingConditionReady,
DependenciesInstalled,
DeploymentsAvailable,
InstallSucceeded,
)

Expand All @@ -47,32 +48,57 @@ func (es *KnativeEventingStatus) IsReady() bool {
return eventingCondSet.Manage(es).IsHappy()
}

// MarkInstallationReady marks the InstallationSucceeded status as ready
func (es *KnativeEventingStatus) MarkInstallationReady() {
// MarkInstallSucceeded marks the InstallationSucceeded status as true.
func (es *KnativeEventingStatus) MarkInstallSucceeded() {
eventingCondSet.Manage(es).MarkTrue(InstallSucceeded)
if es.GetCondition(DependenciesInstalled).IsUnknown() {
// Assume deps are installed if we're not sure
es.MarkDependenciesInstalled()
}
}

// MarkInstallationNotReady marks the InstallationSucceeded status as ready == Unknown
func (es *KnativeEventingStatus) MarkInstallationNotReady(reason, message string) {
eventingCondSet.Manage(es).MarkUnknown(InstallSucceeded, reason, message)
// MarkInstallFailed marks the InstallationSucceeded status as false with the given
// message.
func (es *KnativeEventingStatus) MarkInstallFailed(msg string) {
eventingCondSet.Manage(es).MarkFalse(
InstallSucceeded,
"Error",
"Install failed with message: %s", msg)
}

// MarkInstallationFailed marks the InstallationSucceeded status as failed
func (es *KnativeEventingStatus) MarkInstallationFailed(reason, message string) {
eventingCondSet.Manage(es).MarkFalse(InstallSucceeded, reason, message)
// MarkDeploymentsAvailable marks the DeploymentsAvailable status as true.
func (es *KnativeEventingStatus) MarkDeploymentsAvailable() {
eventingCondSet.Manage(es).MarkTrue(DeploymentsAvailable)
}

// MarkEventingReady marks the KnativeEventing status as ready
func (es *KnativeEventingStatus) MarkEventingReady() {
eventingCondSet.Manage(es).MarkTrue(EventingConditionReady)
// MarkDeploymentsNotReady marks the DeploymentsAvailable status as false and calls out
// it's waiting for deployments.
func (es *KnativeEventingStatus) MarkDeploymentsNotReady() {
eventingCondSet.Manage(es).MarkFalse(
DeploymentsAvailable,
"NotReady",
"Waiting on deployments")
}

// MarkEventingNotReady marks the KnativeEventing status as ready == Unknown
func (es *KnativeEventingStatus) MarkEventingNotReady(reason, message string) {
eventingCondSet.Manage(es).MarkUnknown(EventingConditionReady, reason, message)
// MarkDependenciesInstalled marks the DependenciesInstalled status as true.
func (es *KnativeEventingStatus) MarkDependenciesInstalled() {
eventingCondSet.Manage(es).MarkTrue(DependenciesInstalled)
}

// MarkEventingFailed marks the KnativeEventing status as failed
func (es *KnativeEventingStatus) MarkEventingFailed(reason, message string) {
eventingCondSet.Manage(es).MarkFalse(EventingConditionReady, reason, message)
// MarkDependencyInstalling marks the DependenciesInstalled status as false with the
// given message.
func (es *KnativeEventingStatus) MarkDependencyInstalling(msg string) {
eventingCondSet.Manage(es).MarkFalse(
DependenciesInstalled,
"Installing",
"Dependency installing: %s", msg)
}

// MarkDependencyMissing marks the DependenciesInstalled status as false with the
// given message.
func (es *KnativeEventingStatus) MarkDependencyMissing(msg string) {
eventingCondSet.Manage(es).MarkFalse(
DependenciesInstalled,
"Error",
"Dependency missing: %s", msg)
}
Loading