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

deps: fix: bump Kubernetes Client to 6.6.0 (fixes issues when trace-logging OpenShift builds) #2150

Merged
merged 1 commit into from
May 8, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Usage:
```
### 1.13-SNAPSHOT
* Fix #1478: Should detect and warn the user if creating ingress and ingress controller not available
* Fix #2150: Bump Kubernetes Client to 6.6.0 (fixes issues when trace-logging OpenShift builds)

### 1.12.0 (2023-04-03)
* Fix #1179: Move storageClass related functionality out of VolumePermissionEnricher to PersistentVolumeClaimStorageClassEnricher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
class OpenShiftApplyTaskTest {

@RegisterExtension
private final TaskEnvironmentExtension taskEnvironment = new TaskEnvironmentExtension();
public final TaskEnvironmentExtension taskEnvironment = new TaskEnvironmentExtension();

private MockedConstruction<ClusterAccess> clusterAccessMockedConstruction;
private MockedConstruction<ApplyService> applyServiceMockedConstruction;
Expand All @@ -54,8 +54,7 @@ void setUp() {
final OpenShiftClient openShiftClient = mock(OpenShiftClient.class);
when(mock.createDefaultClient()).thenReturn(openShiftClient);
when(openShiftClient.getMasterUrl()).thenReturn(new URL("http://openshiftapps-com-cluster:6443"));
when(openShiftClient.adapt(OpenShiftClient.class)).thenReturn(openShiftClient);
when(openShiftClient.isSupported()).thenReturn(true);
when(openShiftClient.hasApiGroup("openshift.io", false)).thenReturn(true);
});
applyServiceMockedConstruction = mockConstruction(ApplyService.class);
extension = new TestOpenShiftExtension();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
class OpenShiftUndeployTaskTest {

@RegisterExtension
private final TaskEnvironmentExtension taskEnvironment = new TaskEnvironmentExtension();
public final TaskEnvironmentExtension taskEnvironment = new TaskEnvironmentExtension();

private MockedConstruction<OpenshiftUndeployService> openshiftUndeployServiceMockedConstruction;
private MockedConstruction<ClusterAccess> clusterAccessMockedConstruction;
Expand All @@ -54,8 +54,7 @@ void setUp() {
clusterAccessMockedConstruction = mockConstruction(ClusterAccess.class, (mock, ctx) -> {
final OpenShiftClient openShiftClient = mock(OpenShiftClient.class);
when(mock.createDefaultClient()).thenReturn(openShiftClient);
when(openShiftClient.adapt(OpenShiftClient.class)).thenReturn(openShiftClient);
when(openShiftClient.isSupported()).thenReturn(true);
when(openShiftClient.hasApiGroup("openshift.io", false)).thenReturn(true);
});
openshiftUndeployServiceMockedConstruction = mockConstruction(OpenshiftUndeployService.class);
extension = new TestOpenShiftExtension();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static OpenShiftClient asOpenShiftClient(KubernetesClient client) {
}

public static boolean isOpenShift(KubernetesClient client) {
return client.adapt(OpenShiftClient.class).isSupported();
return client.hasApiGroup(OpenShiftClient.BASE_API_GROUP, false);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void testAsOpenShiftClientWithNoOpenShift() {
@Test
void testOpenShiftClientWithAdaptableToOpenShift() {
// Given
when(oc.isSupported()).thenReturn(true);
when(kc.hasApiGroup("openshift.io", false)).thenReturn(true);
doReturn(oc).when(kc).adapt(OpenShiftClient.class);
//When
OpenShiftClient result = OpenshiftHelper.asOpenShiftClient(kc);
Expand All @@ -74,8 +74,7 @@ void testOpenShiftClientWithOpenShift() {
@Test
void testIsOpenShiftWhenSupported() {
// Given
doReturn(oc).when(kc).adapt(OpenShiftClient.class);
when(oc.isSupported()).thenReturn(true);
when(kc.hasApiGroup("openshift.io", false)).thenReturn(true);
//When
boolean result = OpenshiftHelper.isOpenShift(kc);
//Then
Expand All @@ -85,8 +84,7 @@ void testIsOpenShiftWhenSupported() {
@Test
void testIsOpenShiftNotSupported() {
// Given
doReturn(oc).when(kc).adapt(OpenShiftClient.class);
when(oc.isSupported()).thenReturn(false);
when(kc.hasApiGroup("openshift.io", false)).thenReturn(false);
//When
boolean result = OpenshiftHelper.isOpenShift(kc);
//Then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public boolean isOpenShift() {
String prefix = cause instanceof UnknownHostException ? "Unknown host " : "";
kitLogger.warn("Cannot access cluster for detecting mode: %s%s",
prefix,
cause != null ? cause.getMessage() : exp.getMessage());
cause != null && cause.getMessage() != null ? cause.getMessage() : exp.getMessage());
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void isOpenShiftThrowsExceptionShouldReturnFalse() {
// Then
assertThat(result).isFalse();
verify(logger, times(1))
.warn(startsWith("Cannot access cluster for detecting mode"), eq(""), contains("unknown.example.com"));
.warn(startsWith("Cannot access cluster for detecting mode"), eq(""), eq("An error has occurred."));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void getUndeployServiceInOpenShiftWithValidClient() {
// Given
jKubeServiceHubBuilder.platformMode(RuntimeMode.OPENSHIFT);
try (JKubeServiceHub jKubeServiceHub = jKubeServiceHubBuilder.build()) {
when(openShiftClient.isSupported()).thenReturn(true);
when(openShiftClient.hasApiGroup("openshift.io", false)).thenReturn(true);
// When
final UndeployService result = jKubeServiceHub.getUndeployService();
// Then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ void getManifestsToUndeploy() {
// Given
final OpenShiftClient client = mock(OpenShiftClient.class);
when(mockServiceHub.getClient()).thenReturn(client);
when(client.adapt(OpenShiftClient.class)).thenReturn(client);
when(client.isSupported()).thenReturn(true);
when(client.hasApiGroup("openshift.io", false)).thenReturn(true);
// When
final List<File> result = undeployMojo.getManifestsToUndeploy();
// Then
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<version.jmockit>1.49</version.jmockit>
<version.json-smart>2.4.10</version.json-smart> <!-- Transitive dependency required by citrus -->
<version.junit5>5.9.2</version.junit5>
<version.kubernetes-client>6.5.1</version.kubernetes-client>
<version.kubernetes-client>6.6.0</version.kubernetes-client>
<version.license-maven-plugin>4.2</version.license-maven-plugin>
<version.lombok-maven-plugin>1.18.20.0</version.lombok-maven-plugin>
<version.maven-compiler-plugin>3.8.1</version.maven-compiler-plugin>
Expand Down