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

[issue 168] Bump Infinispan operator CRDs #171

Merged
merged 4 commits into from
May 14, 2024
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
4 changes: 2 additions & 2 deletions docs/Operator-Based-Provisioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ extended easily, since Intersmash _provisioners_ are pluggable components.
| ActiveMQ Artemis | 1.0.11 | upstream | 1.0.15 | https://github.com/artemiscloud/activemq-artemis-operator | We are using a custom index image, i.e. quay.io/jbossqe-eap/intersmash-activemq-operator-catalog:v1.0.11, built as described in https://github.com/Intersmash/intersmash/issues/32 |
| Red Hat AMQ Broker | 7.11.2-opr-1 | 7.11.x | 7.11.z | https://github.com/rh-messaging/activemq-artemis-operator | As available on the OpenShift OperatorHub |
| Hyperfoil | 0.24.2 | alpha | 0.24.2 | https://github.com/Hyperfoil/hyperfoil-operator | We force the CRs version for the used Hyperfoil runtime to be 0.24.2, see https://github.com/Hyperfoil/hyperfoil-operator/issues/18 |
| Infinispan | 2.3.8 | 2.3.x | 14.0.24.Final | https://github.com/infinispan/infinispan-operator | As available on the OpenShift OperatorHub (community-operators) |
| Red Hat DataGrid | 8.4.14 | 8.4.x | 8.4.7.GA | https://github.com/infinispan/infinispan-operator | As available on the OpenShift OperatorHub |
| Infinispan | 2.4.0 | 2.4.x | 14.0.27.Final | https://github.com/infinispan/infinispan-operator | As available on the OpenShift OperatorHub (community-operators) |
| Red Hat DataGrid | 8.4.15 | 8.4.x | 8.4.8.GA | https://github.com/infinispan/infinispan-operator | As available on the OpenShift OperatorHub |
| Kafka provided by Strimzi | 0.38.0 | stable | 3.6.0 | https://github.com/strimzi/strimzi-kafka-operator | |
| Red Hat AMQ Streams | 2.6.0-0 | stable | 3.6.0 | https://github.com/strimzi/strimzi-kafka-operator | As available on the OpenShift OperatorHub |
| Keycloak | 24.0.1 | upstream | 24.0.1 | https://github.com/keycloak/keycloak/tree/main/operator | Latest Keycloak, based on Quarkus. Supports a limited number of CR (Keycloak and KeycloakRealmImport): more to come in upcoming versions |
Expand Down
3 changes: 0 additions & 3 deletions global-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,3 @@ intersmash.kafka.operators.channel=stable

intersmash.hyperfoil.operators.catalog_source=community-operators
intersmash.hyperfoil.operators.package_manifest=hyperfoil-bundle

intersmash.infinispan.operators.channel=2.3.x

Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,28 @@ public void deploy() {
ffCheck = FailFastUtils.getFailFastCheck(EventHelper.timeOfLastEventBMOrTestNamespaceOrEpoch(),
getApplication().getName());
subscribe();

// create custom resources
int replicas = getApplication().getInfinispan().getSpec().getReplicas();
// create Infinispan CR
tommaso-borgato marked this conversation as resolved.
Show resolved Hide resolved
final int replicas = getApplication().getInfinispan().getSpec().getReplicas();
infinispansClient().createOrReplace(getApplication().getInfinispan());
if (replicas > 0) {
new SimpleWaiter(() -> getInfinispanPods().size() == replicas).level(Level.DEBUG).waitFor();
}
// create Cache CR(s)
if (getApplication().getCaches().size() > 0) {
getApplication().getCaches().stream().forEach((i) -> cachesClient().resource(i).create());
}

// This might be a litle bit naive, but we need more use cases to see how will this behave and what other
// use-cases we have to cover wait for infinispan pods - look for "clusterName" in infinispan pod
if (replicas > 0) {
OpenShiftWaiters.get(OpenShiftProvisioner.openShift, ffCheck).areExactlyNPodsReady(
replicas, "clusterName", getApplication().getInfinispan().getMetadata().getName()).waitFor();
}
// wait for all resources to be ready
waitForResourceReadiness();
}

@Override
public void undeploy() {
// delete custom resources
// delete Cache CR(s)
caches().forEach(keycloakUser -> keycloakUser.withPropagationPolicy(DeletionPropagation.FOREGROUND).delete());
// delete Infinispan CR
infinispan().withPropagationPolicy(DeletionPropagation.FOREGROUND).delete();

// wait for 0 pods
// wait for 0 pods, and here it waits for no pods to exist with the `clusterName=<INFINISPAN_APP_NAME>` label,
// since all CRs have been deleted
OpenShiftWaiters.get(OpenShiftProvisioner.openShift, ffCheck)
.areExactlyNPodsReady(0, "clusterName", getApplication().getInfinispan().getMetadata().getName())
.level(Level.DEBUG)
Expand All @@ -107,32 +104,15 @@ public void undeploy() {

@Override
public void scale(int replicas, boolean wait) {
StatefulSet statefulSet = OpenShiftProvisioner.openShift.getStatefulSet(getApplication().getName());
tommaso-borgato marked this conversation as resolved.
Show resolved Hide resolved
if (Objects.isNull(statefulSet)) {
throw new IllegalStateException(String.format(
"Impossible to scale non existent StatefulSet with name=\"%s\" to replicas=%d",
getApplication().getName(),
replicas));
}
String controllerRevisionHash = statefulSet.getStatus().getUpdateRevision();
Infinispan tmpInfinispan = infinispan().get();
tmpInfinispan.getSpec().setReplicas(replicas);
infinispan().replace(tmpInfinispan);
if (wait) {
OpenShiftWaiters.get(OpenShiftProvisioner.openShift, ffCheck)
.areExactlyNPodsReady(replicas, "controller-revision-hash", controllerRevisionHash)
.level(Level.DEBUG)
.waitFor();
}
if (replicas > 0) {
// see https://github.com/kubernetes/apimachinery/blob/v0.20.4/pkg/apis/meta/v1/types.go#L1289
new SimpleWaiter(
() -> infinispan().get().getStatus().getConditions().stream()
.anyMatch(c -> c.getType()
.equals(InfinispanConditionBuilder.ConditionType.ConditionWellFormed.getValue())
&& c.getStatus().equals("True")))
.reason("Wait for infinispan resource to be ready").level(Level.DEBUG).waitFor();
// waits for the correct number of Pods representing the Infinispan CR replicas to be ready
new SimpleWaiter(() -> getInfinispanPods().size() == replicas).level(Level.DEBUG).waitFor();
}
// wait for all resources to be ready
waitForResourceReadiness();
}

@Override
Expand All @@ -144,6 +124,19 @@ public List<Pod> getPods() {
: Lists.emptyList();
}

public List<Pod> getInfinispanPods() {
return getInfinispanPods(getApplication().getName());
}

public static List<Pod> getInfinispanPods(final String clusterName) {
return OpenShiftProvisioner.openShift.inNamespace(OpenShiftConfig.namespace()).pods().list().getItems().stream().filter(
p -> p.getMetadata().getLabels().entrySet().stream()
tommaso-borgato marked this conversation as resolved.
Show resolved Hide resolved
.anyMatch(tl -> "app".equals(tl.getKey()) && "infinispan-pod".equals(tl.getValue())
&& p.getMetadata().getLabels().entrySet().stream().anyMatch(
cnl -> "clusterName".equals(cnl.getKey()) && clusterName.equals(cnl.getValue()))))
.collect(Collectors.toList());
}

@Override
protected String getOperatorCatalogSource() {
return IntersmashConfig.infinispanOperatorCatalogSource();
Expand Down Expand Up @@ -174,15 +167,13 @@ public URL getURL() {
final Expose.Type exposedType = getApplication().getInfinispan().getSpec().getExpose().getType();
switch (exposedType) {
case NodePort:
// TODO - check
// see see https://github.com/infinispan/infinispan-operator/blob/2.0.x/pkg/apis/infinispan/v1/infinispan_types.go#L107
externalUrl = "http://"
+ OpenShiftProvisioner.openShift.getService(getApplication().getName() + "-external").getSpec()
.getClusterIP()
+ getApplication().getInfinispan().getSpec().getExpose().getNodePort();
break;
case LoadBalancer:
// TODO - check
// see https://github.com/infinispan/infinispan-operator/blob/2.0.x/pkg/apis/infinispan/v1/infinispan_types.go#L111
externalUrl = "http://"
+ OpenShiftProvisioner.openShift.getService(getApplication().getName() + "-external").getSpec()
Expand All @@ -205,8 +196,6 @@ public URL getURL() {
}
}

// infinispans.infinispan.org

/**
* Get a client capable of working with {@link #INFINISPAN_RESOURCE} custom resource.
*
Expand Down Expand Up @@ -289,14 +278,16 @@ public List<Resource<Cache>> caches() {
}

private void waitForResourceReadiness() {
// see https://github.com/kubernetes/apimachinery/blob/v0.20.4/pkg/apis/meta/v1/types.go#L1289
// it must be well-formed
// see https://github.com/kubernetes/apimachinery/blob/v0.20.4/pkg/apis/meta/v1/types.go#L1289
new SimpleWaiter(
() -> infinispan().get().getStatus().getConditions().stream()
.anyMatch(
c -> c.getType().equals(InfinispanConditionBuilder.ConditionType.ConditionWellFormed.getValue())
&& c.getStatus().equals("True")))
.reason("Wait for infinispan resource to be ready").level(Level.DEBUG)
.waitFor();
// and with the expected number of Cache CR(s)
if (getApplication().getCaches().size() > 0)
new SimpleWaiter(() -> cachesClient().list().getItems().size() == caches().size())
.reason("Wait for caches to be ready.").level(Level.DEBUG).waitFor(); // no isReady() for cache
Expand Down
11 changes: 7 additions & 4 deletions provisioners/src/main/resources/crds/infinispan.org_backups.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@

---
# See https://raw.githubusercontent.com/k8s-operatorhub/community-operators/main/operators/infinispan/2.4.1/manifests/infinispan.org_backups.yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
cert-manager.io/inject-ca-from: infinispan-operator-system/infinispan-operator-serving-cert
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
labels:
app.kubernetes.io/name: infinispan-operator
name: backups.infinispan.org
spec:
group: infinispan.org
Expand Down Expand Up @@ -126,5 +129,5 @@ status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
conditions: null
storedVersions: null
11 changes: 7 additions & 4 deletions provisioners/src/main/resources/crds/infinispan.org_batches.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@

---
# See https://raw.githubusercontent.com/k8s-operatorhub/community-operators/main/operators/infinispan/2.4.1/manifests/infinispan.org_batches.yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
cert-manager.io/inject-ca-from: infinispan-operator-system/infinispan-operator-serving-cert
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
labels:
app.kubernetes.io/name: infinispan-operator
name: batches.infinispan.org
spec:
group: infinispan.org
Expand Down Expand Up @@ -74,5 +77,5 @@ status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
conditions: null
storedVersions: null
13 changes: 9 additions & 4 deletions provisioners/src/main/resources/crds/infinispan.org_caches.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@

---
# See https://raw.githubusercontent.com/k8s-operatorhub/community-operators/main/operators/infinispan/2.4.1/manifests/infinispan.org_caches.yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
cert-manager.io/inject-ca-from: infinispan-operator-system/infinispan-operator-serving-cert
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
labels:
app.kubernetes.io/name: infinispan-operator
name: caches.infinispan.org
spec:
group: infinispan.org
Expand Down Expand Up @@ -59,6 +62,7 @@ spec:
required:
- key
type: object
x-kubernetes-map-type: atomic
secretName:
description: The secret that contains user credentials.
type: string
Expand All @@ -81,6 +85,7 @@ spec:
required:
- key
type: object
x-kubernetes-map-type: atomic
type: object
clusterName:
description: Infinispan cluster name
Expand Down Expand Up @@ -147,5 +152,5 @@ status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
conditions: null
storedVersions: null
Loading
Loading