Skip to content

Conversation

LimKianAn
Copy link
Contributor

zalando.Postgresql was the first peripheral resources we implemented. The logic of its creation and update scattered in func Reconcile. This chaos slows down the development speed and seems odd as compared with other peripheral resources. Moreover, there was a bug in the old func createZalandoPostgresql which returns ctrl.Resul{}, nil and finishes the reconciliation. After the implementation, now we have a clear workflow in func Reconcile:

	// Check if zalando dependencies are installed. If not, install them.
	if err := r.ensureZalandoDependencies(ctx, instance); err != nil {
		return ctrl.Result{}, fmt.Errorf("error while ensuring Zalando dependencies: %v", err)
	}

	if err := r.createOrUpdateZalandoPostgresql(ctx, instance, log); err != nil {
		return ctrl.Result{}, fmt.Errorf("failed to create or update zalando postgresql: %w", err)
	}

	if err := r.CreateSvcLBIfNone(ctx, instance); err != nil {
		return ctrl.Result{}, err
	}

	// Check if socket port is ready
	port := instance.Status.Socket.Port
	if port == 0 {
		log.Info("socket port not ready")
		return ctrl.Result{Requeue: true}, nil
	}

	// Update status will be handled by the StatusReconciler, based on the Zalando Status
	if err := r.createOrUpdateCWNP(ctx, instance, int(port)); err != nil {
		return ctrl.Result{}, fmt.Errorf("unable to create or update corresponding CRD ClusterwideNetworkPolicy: %W", err)
	}

@LimKianAn LimKianAn requested a review from eberlep February 18, 2021 14:08
Copy link
Collaborator

@eberlep eberlep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks alright

@eberlep eberlep merged commit 2dfd897 into main Feb 19, 2021
@majst01 majst01 deleted the create-or-update-zalando-postgresql branch February 22, 2021 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants