Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <[email protected]>
  • Loading branch information
tolusha committed Aug 4, 2021
1 parent a3f9168 commit 6cf0d1b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
12 changes: 7 additions & 5 deletions controllers/che/checluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ var (
// CheServiceAccountName - service account name for che-server.
CheServiceAccountName = "che"

syncItems = []func(*deploy.DeployContext) (*ctrl.Result, error){
failedSyncItemName = ""
syncItems = []func(*deploy.DeployContext) (*ctrl.Result, error){
validateCheClusterCR,
readProxyConfiguration,
syncOpenShiftCertificates,
Expand Down Expand Up @@ -288,16 +289,17 @@ func (r *CheClusterReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)
for _, syncItem := range syncItems {
result, err := syncItem(deployContext)
if !util.IsTestMode() {
syncItemName := runtime.FuncForPC(reflect.ValueOf(syncItem).Pointer()).Name()
if err != nil {
funcName := runtime.FuncForPC(reflect.ValueOf(syncItem).Pointer()).Name()
logrus.Errorf("Failed to sync %s, cause: %v", funcName, err)
failedSyncItemName = syncItemName
logrus.Errorf("Failed to sync %s, cause: %v", failedSyncItemName, err)

// update the status with the error message'
if err := deploy.SetStatusDetails(deployContext, failedValidationReason, err.Error(), ""); err != nil {
return ctrl.Result{}, err
}
} else {
// clean up the status
} else if failedSyncItemName == syncItemName { // status must cleaned by the same item
failedSyncItemName = ""
if err := deploy.SetStatusDetails(deployContext, "", "", ""); err != nil {
return ctrl.Result{}, err
}
Expand Down
10 changes: 6 additions & 4 deletions pkg/deploy/identity-provider/deployment_keycloak.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,16 +775,18 @@ func updateSslRequiredForMasterRealm(cr *orgv1.CheCluster) error {
return err
}

func ProvisionKeycloakResources(deployContext *deploy.DeployContext) (bool, error) {
func ProvisionKeycloakResources(deployContext *deploy.DeployContext) error {
if !deployContext.CheCluster.Spec.Database.ExternalDb {
value, err := getSslRequiredForMasterRealm(deployContext.CheCluster)
if err != nil {
return false, err
return err
}

if value != "NONE" {
err := updateSslRequiredForMasterRealm(deployContext.CheCluster)
return err == nil, err
if err != nil {
return err
}
}
}

Expand All @@ -793,7 +795,7 @@ func ProvisionKeycloakResources(deployContext *deploy.DeployContext) (bool, erro
deploy.IdentityProviderName,
GetKeycloakProvisionCommand,
"create realm, client and user")
return err == nil, err
return err
}

// getImportCABundleScript returns string which contains bash function that imports ca-bundle into jks
Expand Down
6 changes: 4 additions & 2 deletions pkg/deploy/identity-provider/identity_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ func syncKeycloakResources(deployContext *deploy.DeployContext) (bool, error) {
if !util.IsTestMode() {
cr := deployContext.CheCluster
if !cr.Status.KeycloakProvisoned {
done, err := ProvisionKeycloakResources(deployContext)
if !done {
if err := ProvisionKeycloakResources(deployContext); err != nil {
return false, err
}

Expand All @@ -129,6 +128,9 @@ func syncKeycloakResources(deployContext *deploy.DeployContext) (bool, error) {
}
break
}

// provision keycloak resources requires to restart keycloak pod
return false, nil
}

// Updates keycloak if chehost has been changed
Expand Down
18 changes: 9 additions & 9 deletions pkg/deploy/kubernetes_image_puller.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func ReconcileImagePuller(ctx *DeployContext) (*reconcile.Result, error) {
// If the image puller should be installed but the APIServer doesn't know about PackageManifests/Subscriptions, log a warning and requeue
if ctx.CheCluster.Spec.ImagePuller.Enable && (!foundPackagesAPI || !foundOperatorsAPI) {
logrus.Infof("Couldn't find Operator Lifecycle Manager types to install the Kubernetes Image Puller Operator. Please install Operator Lifecycle Manager to install the operator or disable the image puller by setting spec.imagePuller.enable to false.")
return &reconcile.Result{Requeue: true}, nil
return &reconcile.Result{RequeueAfter: time.Second}, nil
}

if ctx.CheCluster.Spec.ImagePuller.Enable {
Expand All @@ -63,7 +63,7 @@ func ReconcileImagePuller(ctx *DeployContext) (*reconcile.Result, error) {
if err != nil {
if errors.IsNotFound(err) {
logrus.Infof("There is no PackageManifest for the Kubernetes Image Puller Operator. Install the Operator Lifecycle Manager and the Community Operators Catalog")
return &reconcile.Result{Requeue: true}, nil
return &reconcile.Result{RequeueAfter: time.Second}, nil
}
logrus.Errorf("Error getting packagemanifest: %v", err)
return &reconcile.Result{}, err
Expand All @@ -75,23 +75,23 @@ func ReconcileImagePuller(ctx *DeployContext) (*reconcile.Result, error) {
return &reconcile.Result{}, err
}
if createdOperatorGroup {
return &reconcile.Result{Requeue: true}, nil
return &reconcile.Result{RequeueAfter: time.Second}, nil
}
createdOperatorSubscription, err := CreateImagePullerSubscription(ctx, packageManifest)
if err != nil {
logrus.Infof("Error creating Subscription: %v", err)
return &reconcile.Result{}, err
}
if createdOperatorSubscription {
return &reconcile.Result{Requeue: true}, nil
return &reconcile.Result{RequeueAfter: time.Second}, nil
}

// Add the image puller finalizer
if !HasImagePullerFinalizer(ctx.CheCluster) {
if err := ReconcileImagePullerFinalizer(ctx); err != nil {
return &reconcile.Result{}, err
}
return &reconcile.Result{Requeue: true}, nil
return &reconcile.Result{RequeueAfter: time.Second}, nil
}
}

Expand All @@ -118,7 +118,7 @@ func ReconcileImagePuller(ctx *DeployContext) (*reconcile.Result, error) {
logrus.Errorf("Error updating CheCluster: %v", err)
return &reconcile.Result{}, err
}
return &reconcile.Result{Requeue: true}, nil
return &reconcile.Result{RequeueAfter: time.Second}, nil
}

if ctx.CheCluster.IsImagePullerImagesEmpty() {
Expand Down Expand Up @@ -162,7 +162,7 @@ func ReconcileImagePuller(ctx *DeployContext) (*reconcile.Result, error) {
logrus.Errorf("Error updating KubernetesImagePuller: %v", err)
return &reconcile.Result{}, err
}
return &reconcile.Result{Requeue: true}, nil
return &reconcile.Result{RequeueAfter: time.Second}, nil
}
} else {
logrus.Infof("Waiting 15 seconds for kubernetesimagepullers.che.eclipse.org API")
Expand All @@ -178,7 +178,7 @@ func ReconcileImagePuller(ctx *DeployContext) (*reconcile.Result, error) {
}

if removed {
return &reconcile.Result{Requeue: true}, nil
return &reconcile.Result{RequeueAfter: time.Second}, nil
}

if HasImagePullerFinalizer(ctx.CheCluster) {
Expand All @@ -187,7 +187,7 @@ func ReconcileImagePuller(ctx *DeployContext) (*reconcile.Result, error) {
logrus.Errorf("Error deleting finalizer: %v", err)
return &reconcile.Result{}, err
}
return &reconcile.Result{Requeue: true}, nil
return &reconcile.Result{RequeueAfter: time.Second}, nil
}
}
}
Expand Down

0 comments on commit 6cf0d1b

Please sign in to comment.