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

Add error status if operator hasn't got permission to count users. #208

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
7 changes: 7 additions & 0 deletions pkg/controller/che/che_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ const (
failedNoOpenshiftUserReason = "InstallOrUpdateFailed"
failedNoOpenshiftUserMessage = "No real user exists in the OpenShift cluster." +
" Either disable OpenShift OAuth integration or add at least one user (details in the Help link)"
failedUnableToGetOpenshiftUsers = "Unable to get users on the OpenShift cluster."
howToCreateAUserLinkOS4 = "https://docs.openshift.com/container-platform/4.1/authentication/understanding-identity-provider.html#identity-provider-overview_understanding-identity-provider"
howToCreateAUserLinkOS3 = "https://docs.openshift.com/container-platform/3.11/install_config/configuring_authentication.html"
)
Expand Down Expand Up @@ -352,8 +353,14 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
users := &userv1.UserList{}
listOptions := &client.ListOptions{}
if err := r.nonCachedClient.List(context.TODO(), listOptions, users); err != nil {
getUsersErrMsg := failedUnableToGetOpenshiftUsers + " Cause: " + err.Error()
logrus.Errorf(getUsersErrMsg)
if err := r.SetStatusDetails(instance, request, failedNoOpenshiftUserReason, getUsersErrMsg, ""); err != nil {
return reconcile.Result{}, err
}
AndrienkoAleksandr marked this conversation as resolved.
Show resolved Hide resolved
return reconcile.Result{}, err
}

if len(users.Items) < 1 {
helpLink := ""
if isOpenShift4 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/che/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (r *ReconcileChe) UpdateCheCRStatus(instance *orgv1.CheCluster, updatedFiel
logrus.Infof("Updating %s CR with %s: %s", instance.Name, updatedField, value)
err = r.client.Status().Update(context.TODO(), instance)
if err != nil {
logrus.Warnf("Failed to update %s CR. Fetching the latest CR version: %s", instance.Name, err)
logrus.Errorf("Failed to update %s CR. Fetching the latest CR version: %s", instance.Name, err)
return err
}
logrus.Infof("Custom resource %s updated", instance.Name)
Expand All @@ -42,7 +42,7 @@ func (r *ReconcileChe) UpdateCheCRSpec(instance *orgv1.CheCluster, updatedField
logrus.Infof("Updating %s CR with %s: %s", instance.Name, updatedField, value)
err = r.client.Update(context.TODO(), instance)
if err != nil {
logrus.Warnf("Failed to update %s CR: %s", instance.Name, err)
logrus.Errorf("Failed to update %s CR: %s", instance.Name, err)
return err
}
logrus.Infof("Custom resource %s updated", instance.Name)
Expand Down