Skip to content

add logging to help identify issue with failing e2e test #2095

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
Oct 23, 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 @@ -123,6 +123,7 @@ public void onAdd(R newResource) {

@Override
public void onUpdate(R oldObject, R newObject) {
log.debug("On updated with old: {} \n new: {}", oldObject, newObject);
if (log.isDebugEnabled()) {
log.debug(
"On update event received for resource id: {} type: {} version: {} old version: {} ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ public UpdateControl<WebPage> reconcile(WebPage webPage, Context<WebPage> contex
"Creating or updating ConfigMap {} in {}",
desiredHtmlConfigMap.getMetadata().getName(),
ns);
kubernetesClient.configMaps().inNamespace(ns).resource(desiredHtmlConfigMap)
var res = kubernetesClient.configMaps().inNamespace(ns).resource(desiredHtmlConfigMap)
.createOrReplace();
log.debug("Updated config map: {}", res);
}

var existingDeployment = context.getSecondaryResource(Deployment.class).orElse(null);
Expand Down Expand Up @@ -181,10 +182,14 @@ private boolean match(Service desiredService, Service service) {
}

private boolean match(ConfigMap desiredHtmlConfigMap, ConfigMap existingConfigMap) {
log.debug("Actual config map: {}, desired configMap: {}", existingConfigMap,
desiredHtmlConfigMap);
if (existingConfigMap == null) {
return false;
} else {
return desiredHtmlConfigMap.getData().equals(existingConfigMap.getData());
var matched = desiredHtmlConfigMap.getData().equals(existingConfigMap.getData());
log.debug("Matched config map: {}", matched);
return matched;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
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 @@ -19,12 +22,15 @@
public class ConfigMapDependentResource
extends CRUDKubernetesDependentResource<ConfigMap, WebPage> {

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

public ConfigMapDependentResource() {
super(ConfigMap.class);
}

@Override
protected ConfigMap desired(WebPage webPage, Context<WebPage> context) {
log.debug("Web page spec: {}", webPage.getSpec().getHtml());
Map<String, String> data = new HashMap<>();
data.put("index.html", webPage.getSpec().getHtml());
Map<String, String> labels = new HashMap<>();
Expand All @@ -39,4 +45,15 @@ protected ConfigMap desired(WebPage webPage, Context<WebPage> context) {
.withData(data)
.build();
}

@Override
public Result<ConfigMap> match(ConfigMap actualResource, WebPage primary,
Context<WebPage> context) {
var matched = super.match(actualResource, primary, context);
log.debug("Match for config map {} res: {}", actualResource.getMetadata().getName(),
matched.matched());
return matched;
}


}