Skip to content

Commit

Permalink
fix #2718 minor changes related to readiness
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins authored and manusa committed Jun 19, 2023
1 parent 8b7f467 commit 8707825
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Fix #5133: Support for using TokenRequest for existing ServiceAccount

#### _**Note**_: Breaking changes
* Fix #2718: KubernetesResourceUtil.isResourceReady was deprecated. Use

### 6.7.2 (2023-06-15)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ default GracePeriodConfigurable<? extends Deletable> cascading(boolean enabled)

/**
* Check if the resource is ready. If no readiness check exists, this is just an existence check.
* <p>
* Note: for resources other than Node, Deployment, ReplicaSet, StatefulSet, Pod, ReplicationController, and DeploymentConfig
* readiness is simply an existence check.
* <p>
* Also note this obtains the latest version of the resource from the server even if the context item
* is present.
*
* @return true if the resource exists and is ready.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@

public interface Waitable<T, P> {

/**
* For resources other than Node, Deployment, ReplicaSet, StatefulSet, Pod, ReplicationController, and DeploymentConfig
* readiness is simply an existence check.
* <br>
* Consider using the more general {@link #waitUntilCondition(Predicate, long, TimeUnit)} when dealing with
* more complex situations or other types.
*/
T waitUntilReady(long amount, TimeUnit timeUnit);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,10 @@ public static List<EnvVar> convertMapToEnvVarList(Map<String, String> envVarMap)
*
* @param item item which needs to be checked
* @return boolean value indicating it's status
*
* @deprecated use client.resource(item).isReady() or Readiness.getInstance().isReady(item) instead
*/
@Deprecated
public static boolean isResourceReady(HasMetadata item) {
return Readiness.getInstance().isReady(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import io.fabric8.kubernetes.client.dsl.NamespaceableResource;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.dsl.Waitable;
import io.fabric8.kubernetes.client.readiness.Readiness;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -72,7 +71,8 @@ public NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl(Clie

@Override
public List<HasMetadata> waitUntilReady(final long amount, final TimeUnit timeUnit) {
return waitUntilCondition(resource -> Objects.nonNull(resource) && getReadiness().isReady(resource), amount, timeUnit);
return waitUntilCondition(resource -> Objects.nonNull(resource) && context.getConfig().getReadiness().isReady(resource),
amount, timeUnit);
}

List<HasMetadata> getItems() {
Expand Down Expand Up @@ -230,10 +230,6 @@ public ListVisitFromServerGetDeleteRecreateWaitApplicable<HasMetadata> withPropa
return newInstance(context.withPropagationPolicy(propagationPolicy));
}

protected Readiness getReadiness() {
return Readiness.getInstance();
}

protected List<HasMetadata> asHasMetadata(Object item) {
List<HasMetadata> result = new ArrayList<>();
if (item instanceof KubernetesResourceList) {
Expand Down

0 comments on commit 8707825

Please sign in to comment.