Skip to content

fix: remove pod delete web page dependent test #2061

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

Merged
merged 2 commits into from
Sep 18, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
Expand All @@ -15,16 +12,13 @@
import io.javaoperatorsdk.operator.sample.customresource.WebPage;

import static io.javaoperatorsdk.operator.sample.Utils.configMapName;
import static io.javaoperatorsdk.operator.sample.Utils.deploymentName;
import static io.javaoperatorsdk.operator.sample.WebPageManagedDependentsReconciler.SELECTOR;

// this annotation only activates when using managed dependents and is not otherwise needed
@KubernetesDependent(labelSelector = SELECTOR)
public class ConfigMapDependentResource
extends CRUDKubernetesDependentResource<ConfigMap, WebPage> {

private static final Logger log = LoggerFactory.getLogger(ConfigMapDependentResource.class);

public ConfigMapDependentResource() {
super(ConfigMap.class);
}
Expand All @@ -45,22 +39,4 @@ protected ConfigMap desired(WebPage webPage, Context<WebPage> context) {
.withData(data)
.build();
}

@Override
public ConfigMap update(ConfigMap actual, ConfigMap desired, WebPage primary,
Context<WebPage> context) {
var res = super.update(actual, desired, primary, context);
var ns = actual.getMetadata().getNamespace();
log.info("Restarting pods because HTML has changed in {}",
ns);
// not that this is not necessary, eventually mounted config map would be updated, just this way
// is much faster; what is handy for demo purposes.
// https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#mounted-configmaps-are-updated-automatically
getKubernetesClient()
.pods()
.inNamespace(ns)
.withLabel("app", deploymentName(primary))
.delete();
return res;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public abstract class WebPageOperatorAbstractTest {
public static final String TITLE1 = "Hello Operator World";
public static final String TITLE2 = "Hello Operator World Title 2";
public static final int WAIT_SECONDS = 20;
public static final int LONG_WAIT_SECONDS = 120;
public static final Duration POLL_INTERVAL = Duration.ofSeconds(1);

boolean isLocal() {
Expand Down Expand Up @@ -68,7 +69,7 @@ void testAddingWebPage() {
// update part: changing title
operator().replace(createWebPage(TITLE2));

await().atMost(Duration.ofSeconds(WAIT_SECONDS))
await().atMost(Duration.ofSeconds(LONG_WAIT_SECONDS))
.pollInterval(POLL_INTERVAL)
.untilAsserted(() -> {
String page = httpGetForWebPage(webPage);
Expand Down