Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Race condition bug in the service creation #3

@naveensrinivasan

Description

@naveensrinivasan

Here in this code https://github.com/StatCan/mlflow-operator/blob/master/controllers/trackingserver_controller.go#L84..86 there could be an error while trying to create the service and could return with the error.

The next time the controller runs it will check if the deployment is not created which it would have and then ignore the service and the PVC creation.

found := &v1.Deployment{}
	err = r.Client.Get(context.TODO(), types.NamespacedName{Name: deployment.Name, Namespace: deployment.Namespace}, found)
	if err != nil && errors.IsNotFound(err) {
		reqLogger.Info("Creating a new Deployment", "Deployment.Namespace", deployment.Namespace, "Deployment.Name", deployment.Name)
		err = r.Client.Create(context.TODO(), deployment)
		if err != nil {
			return ctrl.Result{}, err
		}
		err2 := r.Client.Create(context.TODO(), svc)
		if err2 != nil {
			return ctrl.Result{}, err2
		}
		err3 := r.Client.Create(context.TODO(), pvc)
		if err3 != nil {
			return ctrl.Result{}, err3
		}
		return ctrl.Result{}, nil
		```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions