Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for DataScienceCluster to finish reconciling #117

Merged
merged 3 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/io/odh/test/OdhConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ private OdhConstants() { }
private static final String RHOAI_MONITORING_NAMESPACE = "redhat-ods-monitoring";

// Public part
public static final String DSC_CREATION_SUCCESSFUL_EVENT_NAME = "DataScienceClusterCreationSuccessful";

public static final String CODEFLARE_DEPLOYMENT_NAME = "codeflare-operator-manager";
public static final String DS_PIPELINES_OPERATOR = "data-science-pipelines-operator-controller-manager";
public static final String ETCD = "etcd";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
package io.odh.test.framework.manager.resources;

import io.fabric8.kubernetes.api.model.KubernetesResourceList;
import io.fabric8.kubernetes.api.model.events.v1.Event;
import io.fabric8.kubernetes.client.dsl.EventingAPIGroupDSL;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.odh.test.OdhConstants;
Expand All @@ -18,6 +20,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Objects;

public class DataScienceClusterResource implements ResourceType<DataScienceCluster> {

private static final Logger LOGGER = LoggerFactory.getLogger(DataScienceClusterResource.class);
Expand Down Expand Up @@ -105,6 +110,25 @@ public boolean waitForReadiness(DataScienceCluster resource) {
// dscReady = dscReady && pipelinesStatus.equals("True");
// }

// Check that DSC reconciliation has been successfully finalized
// https://github.com/red-hat-data-services/rhods-operator/blob/rhoai-2.8/controllers/datasciencecluster/datasciencecluster_controller.go#L257

// Wait for ReconcileComplete condition (for the whole DSC)
String reconcileStatus = KubeUtils.getDscConditionByType(dsc.getStatus().getConditions(), "ReconcileComplete").getStatus();
LOGGER.debug("DataScienceCluster {} ReconcileComplete status: {}", resource.getMetadata().getName(), reconcileStatus);
dscReady = dscReady && reconcileStatus.equals("True");

// Wait for DataScienceClusterCreationSuccessful event
EventingAPIGroupDSL eventsClient = ResourceManager.getKubeClient().getClient().events();
List<Event> resourceEvents = eventsClient.v1().events().inAnyNamespace().withNewFilter()
.withField("regarding.name", resource.getMetadata().getName())
.withField("regarding.uid", resource.getMetadata().getUid())
.endFilter().list().getItems();
LOGGER.debug("DataScienceCluster {} events: {}", resource.getMetadata().getName(), resourceEvents.stream().map(Event::getReason).toList());
boolean hasCreationSuccessfulEvent = resourceEvents.stream()
.anyMatch(resourceEvent -> Objects.equals(resourceEvent.getReason(), OdhConstants.DSC_CREATION_SUCCESSFUL_EVENT_NAME));
dscReady = dscReady && hasCreationSuccessfulEvent;

return dscReady;
}, () -> { });

Expand Down
Loading