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

fix(core): Unable to list project clusters #5361

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -299,7 +299,7 @@ static class ApplicationClusterModel {
new OptionalConsumer<>(
(DeployedBuild b) -> {
b.deployed = Math.max(b.deployed, serverGroup.getCreatedTime());
List images = getServerGroupBuildInfoImages(imageSummaries);
List<String> images = getServerGroupBuildInfoImages(imageSummaries);
if (images != null) {
images.forEach(
image -> {
Expand Down Expand Up @@ -376,9 +376,10 @@ static class DeployedBuild {
public String job;
public String buildNumber;
public Long deployed;
public List images;
public List<String> images;

public DeployedBuild(String host, String job, String buildNumber, Long deployed, List images) {
public DeployedBuild(
String host, String job, String buildNumber, Long deployed, List<String> images) {
this.host = host;
this.job = job;
this.buildNumber = buildNumber;
Expand Down Expand Up @@ -426,7 +427,7 @@ private static JenkinsBuildInfo extractJenkinsBuildInfo(
return new JenkinsBuildInfo(buildNumber, host, job);
}

private static List getServerGroupBuildInfoImages(
private static List<String> getServerGroupBuildInfoImages(
List<? extends ServerGroup.ImageSummary> imageSummaries) {
if (imageSummaries.isEmpty()) {
return null;
Expand All @@ -437,7 +438,17 @@ private static List getServerGroupBuildInfoImages(
return null;
}

return (List) buildInfo.get("images");
try {
// Some ImageSummary implementations use immutable image collections, so this needs to be
// copied to a mutable one. Notably, KubernetesImageSummary images are immutable.
return new ArrayList<>((List<String>) buildInfo.get("images"));
} catch (ClassCastException e) {
log.warn(
"Expected List<String> for buildInfo images list, but was not. serverGroup={}",
imageSummary.getServerGroupName(),
e);
return new ArrayList<>();
}
}

private static class OptionalConsumer<T> implements Consumer<Optional<T>> {
Expand Down