Fix logs. Fix user deletion: first off all we should remove secret, then user, identity and update oauth.
Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>pull/597/head
parent
74ebb5e88c
commit
32301ac7d9
|
|
@ -387,15 +387,15 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
|
|||
if err := r.userHandler.DeleteOAuthInitialUser(deployContext); err != nil {
|
||||
logrus.Errorf("Unable to delete initial OpenShift OAuth user from a cluster. Cause: %s", err.Error())
|
||||
instance.Spec.Auth.InitialOpenShiftOAuthUser = nil
|
||||
err := r.UpdateCheCRSpec(instance, "InitialOpenShiftOAuthUser", "nil")
|
||||
err := r.UpdateCheCRSpec(instance, "initialOpenShiftOAuthUser", "nil")
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
|
||||
instance.Spec.Auth.OpenShiftoAuth = nil
|
||||
instance.Spec.Auth.InitialOpenShiftOAuthUser = nil
|
||||
updateFields := map[string]string{
|
||||
"OpenShiftoAuth": "nil",
|
||||
"InitialOpenShiftOAuthUser": "nil",
|
||||
"openShiftoAuth": "nil",
|
||||
"initialOpenShiftOAuthUser": "nil",
|
||||
}
|
||||
|
||||
if err := r.UpdateCheCRSpecByFields(instance, updateFields); err != nil {
|
||||
|
|
@ -1203,7 +1203,7 @@ func (r *ReconcileChe) autoEnableOAuth(deployContext *deploy.DeployContext, requ
|
|||
newOAuthValue := util.NewBoolPointer(oauth)
|
||||
if !util.CompareBoolPointers(newOAuthValue, cr.Spec.Auth.OpenShiftoAuth) {
|
||||
cr.Spec.Auth.OpenShiftoAuth = newOAuthValue
|
||||
if err := r.UpdateCheCRSpec(cr, "OpenShiftoAuth", strconv.FormatBool(oauth)); err != nil {
|
||||
if err := r.UpdateCheCRSpec(cr, "openShiftoAuth", strconv.FormatBool(oauth)); err != nil {
|
||||
return reconcile.Result{Requeue: true, RequeueAfter: time.Second * 1}, err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,6 +114,11 @@ func (iuh *OpenShiftOAuthUserOperatorHandler) DeleteOAuthInitialUser(deployConte
|
|||
|
||||
cr := deployContext.CheCluster
|
||||
userName := deploy.DefaultCheFlavor(cr)
|
||||
|
||||
if err := deploy.DeleteSecret(htpasswdSecretName, ocConfigNamespace, iuh.runtimeClient); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := deleteUser(iuh.runtimeClient, userName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -126,10 +131,6 @@ func (iuh *OpenShiftOAuthUserOperatorHandler) DeleteOAuthInitialUser(deployConte
|
|||
return err
|
||||
}
|
||||
|
||||
if err := deploy.DeleteSecret(htpasswdSecretName, ocConfigNamespace, iuh.runtimeClient); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := deploy.DeleteSecret(openShiftOAuthUserCredentialsSecret, cr.Namespace, iuh.runtimeClient); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ func (r *ReconcileChe) UpdateCheCRStatus(instance *orgv1.CheCluster, updatedFiel
|
|||
|
||||
// UpdateCheCRSpecByFields - updates Che CR "spec" fields by field map
|
||||
func (r *ReconcileChe) UpdateCheCRSpecByFields(instance *orgv1.CheCluster, fields map[string]string) (err error) {
|
||||
updateInfo := append([]string{}, fmt.Sprintf("Updating multiple CR %s fields: \n", instance.Name))
|
||||
updateInfo := []string{}
|
||||
for updatedField, value := range fields {
|
||||
updateInfo = append(updateInfo, fmt.Sprintf("%s: %s", updatedField, value))
|
||||
}
|
||||
logrus.Infof(strings.Join(updateInfo, ", "))
|
||||
logrus.Infof(fmt.Sprintf("Updating multiple CR %s fields: ", instance.Name) + strings.Join(updateInfo, ", "))
|
||||
|
||||
err = r.client.Update(context.TODO(), instance)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue