-
Notifications
You must be signed in to change notification settings - Fork 228
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
set ClusterOperator.Status #72
set ClusterOperator.Status #72
Conversation
@@ -83,27 +85,34 @@ func (r *ReconcileClusterConfig) Reconcile(request reconcile.Request) (reconcile | |||
} | |||
// Error reading the object - requeue the request. | |||
log.Println(err) | |||
// FIXME: operator status? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, tough to know what to do. If it weren't a transient failure, then I suppose we would treat this the same as invalid input. This seems very unlikely though.
func (r *ReconcileDaemonSets) Reconcile(request reconcile.Request) (reconcile.Result, error) { | ||
found := false | ||
for _, ds := range r.daemonSets { | ||
if ds.Namespace == request.Namespace && ds.Name == request.Name { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annoying that the operator-sdk doesn't support mixed-scope watches, AFAICT.
ds := &appsv1.DaemonSet{} | ||
if err := status.client.Get(context.TODO(), dsName, ds); err != nil { | ||
if errors.IsNotFound(err) { | ||
return status.SetFailing("NoDaemonSet", fmt.Errorf("DaemonSet %q does not exist", dsName.String())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it useful to know if more than one daemonset is missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, probably
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, probably not; this would normally just be a transient failure during the first few moments of the cluster's existence, and no one will ever actually see it. (And if we're going to combine errors then what if we're missing the Namespace for one DaemonSet and the DaemonSet for another, etc?)
for _, condition := range conditions { | ||
co.Status.Conditions = SetStatusCondition(co.Status.Conditions, condition) | ||
} | ||
co.Status.Version = status.version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the latest API (openshift/api#176) changes how version is reported. This field is now an array.
In the interest of getting this out the door, let's just drop this line, revendor api, and merge the PR, then figure out the operand stuff afterwards.
A few minor things, but this looks awesome. I'll play around with it tomorrow. Implementing the operand versioning will probably require a bit more sophistication in the daemonset watcher, but I don't think we'll be sad if we merge this before. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
FYI, ovn has one daemonset and one deployment.
/retest Please review the full test history for this PR and help us cut down flakes. |
|
||
// SetStatusCondition returns the result of setting the specified condition in | ||
// the given slice of conditions. | ||
func SetStatusCondition(oldConditions []configv1.ClusterOperatorStatusCondition, condition *configv1.ClusterOperatorStatusCondition) []configv1.ClusterOperatorStatusCondition { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi, I think these exist here: https://github.com/openshift/library-go/blob/master/pkg/config/clusteroperator/v1helpers/status.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's based on the updated ClusterOperator so would require an openshift/api bump too. We'll grab that in the next update after we get the initial version committed.
0bddaa6
to
05ccc35
Compare
repushed with a StatusManager unit test |
05ccc35
to
65f4ead
Compare
65f4ead
to
80eb989
Compare
/hold |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: danwinship, pecameron, squeed The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Somebody Else's Problem! :-) |
/retest |
/hold cancel |
OK, this may still need a bit of testing/finishing but it's at least ready for review.
Failing
,Progressing
, andAvailable
should beTrue
, though we'd talked at least in passing about, eg, making the cluster be bothFailing
andAvailable
if the requested configuration is bad but the deployed configuration is good.network.Render()
result, and pass them to the DaemonSet reconciler, which will then update the operator status based on the status of those DaemonSets rather than / in addition to the openshift-sdn ones. (Although at some point we'll probably need to add Deployment-reconciling support in addition to the DaemonSet support.)StatusManager
exists mostly to deal with the fact that we need three separate Reconcilers, but they have to coordinate the resulting operator status. In particular, if the configuration is invalid, and then a DaemonSet's status changes, we don't want that to result in the operator status becoming Available, soStatusManager.SetFromDaemonSets()
needs to be able to know not to change the status.StatusManager
is intended to eventually be useful to other operators (which is why it takes the operator name and version as constructor arguments).