Skip to content

Commit

Permalink
Add error status if operator hasn't got permission to count users. (#208
Browse files Browse the repository at this point in the history
)

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

Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>

* Add proposed changes.

Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
  • Loading branch information
AndrienkoAleksandr authored Mar 25, 2020
1 parent d0ecec4 commit bceab0f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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
}
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

0 comments on commit bceab0f

Please sign in to comment.