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

chore(matchexpr): refactor MatchExpression as its own resource #39

Merged
merged 28 commits into from
Aug 23, 2023
Merged

chore(matchexpr): refactor MatchExpression as its own resource #39

merged 28 commits into from
Aug 23, 2023

Conversation

andrewazores
Copy link
Member

@andrewazores andrewazores commented Jul 26, 2023

Based on #34
Depends on #34

Rebased on #44
Depends on #44

WIP


This defines MatchExpression as a resource of its own with its own Postgres table and a couple of API endpoints (not used in the web-client or anywhere yet) for listing all the expressions and seeing more details about individual ones, including the list of matching targets. Expressions are created automatically as linked resources when either Credentials or Rules are created, and when either of these are deleted their associated Expression is also deleted.

In practice this doesn't add or change much to the existing API for the other two resources that use expressions, though it does make it easier to share Expression-specific logic (ex. evaluation caching, pre-persist validation). In the future with some related web-client work I envision this being used so that server-side Expressions can be defined, listed, viewed, and deleted independently, and when creating a Rule or Credential the user can choose to either define a new Expression or choose to associate an existing Expression. This will have more performance advantages for caching and will let us build a better UX for match expressions so that they are not split between Rules and Credentials as they currently are.

@andrewazores andrewazores added the chore Refactor, rename, cleanup, etc. label Aug 2, 2023
@andrewazores
Copy link
Member Author

@tthvo review as well please, if you could

@maxcao13
Copy link
Member

maxcao13 commented Aug 9, 2023

I think I get a test failure after quarkus build.

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   MatchExpressionsTest.testPostWithoutTargets:65 1 expectation failed.
JSON path data.result doesn't match.
Expected: <{expression=true, targets=[]}>
  Actual: <{id=null, expression=true, targets=[]}>

[INFO] 
[ERROR] Tests run: 19, Failures: 1, Errors: 0, Skipped: 1

@maxcao13
Copy link
Member

maxcao13 commented Aug 9, 2023

I seem to get an error when I navigate to the Security tab after running smoketest.sh

cryostat_1            | 2023-08-09 20:52:47,254 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-12) HTTP Request to /api/v2.2/credentials failed, error id: b31a986a-bfa9-428c-98cb-061450da8686-7: org.hibernate.sql.exec.ExecutionException: A problem occurred in the SQL executor : Error advancing (next) ResultSet position [ResultSet is closed]
cryostat_1            |         at org.hibernate.sql.results.jdbc.internal.JdbcValuesResultSetImpl.makeExecutionException(JdbcValuesResultSetImpl.java:250)
cryostat_1            |         at org.hibernate.sql.results.jdbc.internal.JdbcValuesResultSetImpl.advanceNext(JdbcValuesResultSetImpl.java:207)
cryostat_1            |         at org.hibernate.sql.results.jdbc.internal.JdbcValuesResultSetImpl.processNext(JdbcValuesResultSetImpl.java:84)
cryostat_1            |         at org.hibernate.sql.results.jdbc.internal.AbstractJdbcValues.next(AbstractJdbcValues.java:29)
cryostat_1            |         at org.hibernate.sql.results.internal.RowProcessingStateStandardImpl.next(RowProcessingStateStandardImpl.java:66)
cryostat_1            |         at org.hibernate.internal.ScrollableResultsImpl.next(ScrollableResultsImpl.java:50)
cryostat_1            |         at org.hibernate.query.internal.ScrollableResultsIterator.hasNext(ScrollableResultsIterator.java:33)
cryostat_1            |         at java.base/java.util.Iterator.forEachRemaining(Iterator.java:132)
cryostat_1            |         at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
cryostat_1            |         at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
cryostat_1            |         at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
cryostat_1            |         at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
cryostat_1            |         at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
cryostat_1            |         at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
cryostat_1            |         at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622)
cryostat_1            |         at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627)
cryostat_1            |         at io.cryostat.credentials.Credentials.list(Credentials.java:64)
cryostat_1            |         at io.cryostat.credentials.Credentials_Subclass.list$$superforward(Unknown Source)
cryostat_1            |         at io.cryostat.credentials.Credentials_Subclass$$function$$2.apply(Unknown Source)
cryostat_1            |         at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:77)
cryostat_1            |         at io.quarkus.arc.impl.AroundInvokeInvocationContext$NextAroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:103)
cryostat_1            |         at io.quarkus.security.runtime.interceptor.SecurityHandler.handle(SecurityHandler.java:27)
cryostat_1            |         at io.quarkus.security.runtime.interceptor.RolesAllowedInterceptor.intercept(RolesAllowedInterceptor.java:29)
cryostat_1            |         at io.quarkus.security.runtime.interceptor.RolesAllowedInterceptor_Bean.intercept(Unknown Source)
cryostat_1            |         at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42)
cryostat_1            |         at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:74)
cryostat_1            |         at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:66)
cryostat_1            |         at io.quarkus.resteasy.reactive.server.runtime.StandardSecurityCheckInterceptor.intercept(StandardSecurityCheckInterceptor.java:44)
cryostat_1            |         at io.quarkus.resteasy.reactive.server.runtime.StandardSecurityCheckInterceptor_RolesAllowedInterceptor_Bean.intercept(Unknown Source)
cryostat_1            |         at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42)
cryostat_1            |         at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:34)
cryostat_1            |         at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:27)
cryostat_1            |         at io.cryostat.credentials.Credentials_Subclass.list(Unknown Source)
cryostat_1            |         at io.cryostat.credentials.Credentials$quarkusrestinvoker$list_ce6c13b83885b2c6f02955ea580a8e8e537fe383.invoke(Unknown Source)
cryostat_1            |         at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
cryostat_1            |         at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
cryostat_1            |         at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:145)
cryostat_1            |         at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:576)
cryostat_1            |         at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
cryostat_1            |         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
cryostat_1            |         at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
cryostat_1            |         at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
cryostat_1            |         at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
cryostat_1            |         at java.base/java.lang.Thread.run(Thread.java:833)
cryostat_1            | Caused by: org.hibernate.exception.GenericJDBCException: Error advancing (next) ResultSet position [ResultSet is closed] [n/a]
cryostat_1            |         at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:61)
cryostat_1            |         at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:108)
cryostat_1            |         at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:94)
cryostat_1            |         ... 44 more
cryostat_1            | Caused by: java.sql.SQLException: ResultSet is closed
cryostat_1            |         at io.agroal.pool.wrapper.ResultSetWrapper$1.invoke(ResultSetWrapper.java:52)
cryostat_1            |         at jdk.proxy3/jdk.proxy3.$Proxy94.next(Unknown Source)
cryostat_1            |         at io.agroal.pool.wrapper.ResultSetWrapper.next(ResultSetWrapper.java:88)
cryostat_1            |         at org.hibernate.sql.results.jdbc.internal.JdbcValuesResultSetImpl.advanceNext(JdbcValuesResultSetImpl.java:204)
cryostat_1            |         ... 42 more
cryostat_1            | 
cryostat_1            | 2023-08-09 20:52:47,255 INFO  [io.qua.htt.access-log] (executor-thread-12) 10.89.156.16 - user 09/Aug/2023:20:52:47 +0000 "GET /api/v2.2/credentials HTTP/1.1" 500 72

@maxcao13
Copy link
Member

maxcao13 commented Aug 9, 2023

I think since streamAll requires a transaction, we need that Transactional annotation? Interesting interaction, I guess reverting that change would work as well.

@maxcao13
Copy link
Member

maxcao13 commented Aug 9, 2023

When I use a query like this:

http --auth=user:pass POST :8181/api/beta/matchExpressions @match
# match
{
  "matchExpression": "true",
  "targets": [{
                        "agent": false,
                        "alias": "%2Fdeployments%2Fquarkus-run.jar",
                        "annotations": {
                            "cryostat": {
                                "HOST": "cryostat3",
                                "JAVA_MAIN": "/deployments/quarkus-run.jar",
                                "PORT": "9091",
                                "REALM": "JDP"
                            },
                            "platform": {}
                        },
                        "connectUrl": "service:jmx:rmi:///jndi/rmi://cryostat3:9091/jmxrmi",
                        "id": 3,
                        "jvmId": "pUdiUY49ca7esJTZJahealZpL5eGz0UnzhdfDneLgRg=",
                        "labels": {}
                    }]
                  }

with the correct jvmId and all that,

I get

{
    "data": {
        "result": {
            "expression": "true",
            "id": null,
            "targets": [
                {
                    "agent": false,
                    "alias": "%2Fdeployments%2Fquarkus-run.jar",
                    "annotations": {
                        "cryostat": {
                            "HOST": "cryostat3",
                            "JAVA_MAIN": "/deployments/quarkus-run.jar",
                            "PORT": "9091",
                            "REALM": "JDP"
                        },
                        "platform": {}
                    },
                    "connectUrl": "service:jmx:rmi:///jndi/rmi://cryostat3:9091/jmxrmi",
                    "id": 3,
                    "jvmId": "pUdiUY49ca7esJTZJahealZpL5eGz0UnzhdfDneLgRg=",
                    "labels": {}
                },
                {
                    "agent": false,
                    "alias": "compose_cryostat_1",
                    "annotations": {
                        "cryostat": {
                            "HOST": "localhost",
                            "PORT": "0",
                            "REALM": "Podman"
                        },
                        "platform": {}
                    },
                    "connectUrl": "service:jmx:rmi:///jndi/rmi://localhost:0/jmxrmi",
                    "id": 1,
                    "jvmId": "pUdiUY49ca7esJTZJahealZpL5eGz0UnzhdfDneLgRg=",
                    "labels": {
                        "architecture": "x86_64",
                        "build-date": "2023-02-07T17:20:49",
                        "com.docker.compose.config-hash": "7317e485fc87edbeec36bbce5abcf22e4107ab7c1dad9a6b799c294648013170",
                        "com.docker.compose.container-number": "1",
                        "com.docker.compose.oneoff": "False",
                        "com.docker.compose.project": "compose",
                        "com.docker.compose.project.config_files": "smoketest/compose/db.yml,smoketest/compose/s3-minio.yml,smoketest/compose/cryostat-grafana.yml,smoketest/compose/jfr-datasource.yml,smoketest/compose/sample-apps.yml,smoketest/compose/cryostat.yml",
                        "com.docker.compose.project.working_dir": "/home/mcao/workspace/cryostat3/smoketest/compose",
                        "com.docker.compose.service": "cryostat",
                        "com.docker.compose.version": "1.29.2",
                        "com.redhat.component": "openjdk-17-ubi8-container",
                        "com.redhat.license_terms": "https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI",
                        "description": "Source To Image (S2I) image for Red Hat OpenShift providing OpenJDK 17",
                        "distribution-scope": "public",
                        "io.buildah.version": "1.29.0",
                        "io.cekit.version": "3.11.0",
                        "io.cryostat.component": "cryostat3",
                        "io.cryostat.discovery": "true",
                        "io.cryostat.jmxHost": "localhost",
                        "io.cryostat.jmxPort": "0",
                        "io.cryostat.jmxUrl": "service:jmx:rmi:///jndi/rmi://localhost:0/jmxrmi",
                        "io.fabric8.s2i.version.maven": "3.6",
                        "io.k8s.description": "Platform for building and running plain Java applications (fat-jar and flat classpath)",
                        "io.k8s.display-name": "Java Applications",
                        "io.openshift.expose-services": "",
                        "io.openshift.s2i.destination": "/tmp",
                        "io.openshift.s2i.scripts-url": "image:///usr/local/s2i",
                        "io.openshift.tags": "builder,java",
                        "kompose.service.expose": "cryostat3",
                        "maintainer": "Red Hat OpenJDK <openjdk@redhat.com>",
                        "name": "ubi8/openjdk-17",
                        "org.jboss.container.deployments-dir": "/deployments",
                        "org.jboss.product": "openjdk",
                        "org.jboss.product.openjdk.version": "17",
                        "org.jboss.product.version": "17",
                        "release": "10.1675788279",
                        "summary": "Source To Image (S2I) image for Red Hat OpenShift providing OpenJDK 17",
                        "url": "https://access.redhat.com/containers/#/registry.access.redhat.com/ubi8/openjdk-17/images/1.14-10.1675788279",
                        "usage": "https://access.redhat.com/documentation/en-us/red_hat_jboss_middleware_for_openshift/3/html/red_hat_java_s2i_for_openshift/",
                        "vcs-ref": "26c4e5bd1ffe379b617c1bc35be67a640fe496ec",
                        "vcs-type": "git",
                        "vendor": "Red Hat, Inc.",
                        "version": "1.14"
                    }
                },
                {
                    "agent": false,
                    "alias": "compose_sample-app_1",
                    "annotations": {
                        "cryostat": {
                            "HOST": "sample-app",
                            "PORT": "9093",
                            "REALM": "Podman"
                        },
                        "platform": {}
                    },
                    "connectUrl": "service:jmx:rmi:///jndi/rmi://sample-app:9093/jmxrmi",
                    "id": 5,
                    "jvmId": "OhiClnUYNw9YmgyFWVpbAJsvIFVHbu9_lJsKkS_Eoxs=",
                    "labels": {
                        "architecture": "x86_64",
                        "build-date": "2023-07-19T16:14:53",
                        "com.docker.compose.config-hash": "092ea4bf74c81054694f3960c2aee76f579f00fd998411d5d2c7876a538c119b",
                        "com.docker.compose.container-number": "1",
                        "com.docker.compose.oneoff": "False",
                        "com.docker.compose.project": "compose",
                        "com.docker.compose.project.config_files": "smoketest/compose/db.yml,smoketest/compose/s3-minio.yml,smoketest/compose/cryostat-grafana.yml,smoketest/compose/jfr-datasource.yml,smoketest/compose/sample-apps.yml,smoketest/compose/cryostat.yml",
                        "com.docker.compose.project.working_dir": "/home/mcao/workspace/cryostat3/smoketest/compose",
                        "com.docker.compose.service": "sample-app",
                        "com.docker.compose.version": "1.29.2",
                        "com.redhat.component": "openjdk-17-ubi8-container",
                        "com.redhat.license_terms": "https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI",
                        "description": "Source To Image (S2I) image for Red Hat OpenShift providing OpenJDK 17",
                        "distribution-scope": "public",
                        "io.buildah.version": "1.29.0",
                        "io.cekit.version": "4.7.0",
                        "io.cryostat.discovery": "true",
                        "io.cryostat.jmxHost": "sample-app",
                        "io.cryostat.jmxPort": "9093",
                        "io.fabric8.s2i.version.maven": "3.8",
                        "io.k8s.description": "Platform for building and running plain Java applications (fat-jar and flat classpath)",
                        "io.k8s.display-name": "Java Applications",
                        "io.openshift.expose-services": "",
                        "io.openshift.s2i.destination": "/tmp",
                        "io.openshift.s2i.scripts-url": "image:///usr/local/s2i",
                        "io.openshift.tags": "builder,java",
                        "maintainer": "Red Hat OpenJDK <openjdk@redhat.com>",
                        "name": "ubi8/openjdk-17",
                        "org.jboss.container.deployments-dir": "/deployments",
                        "org.jboss.product": "openjdk",
                        "org.jboss.product.openjdk.version": "17",
                        "org.jboss.product.version": "17",
                        "release": "2",
                        "summary": "Source To Image (S2I) image for Red Hat OpenShift providing OpenJDK 17",
                        "url": "https://access.redhat.com/containers/#/registry.access.redhat.com/ubi8/openjdk-17/images/1.16-2",
                        "usage": "https://access.redhat.com/documentation/en-us/red_hat_jboss_middleware_for_openshift/3/html/red_hat_java_s2i_for_openshift/",
                        "vcs-ref": "f3b78885ddc4a0f11fad92c8c52c4e8366510b9d",
                        "vcs-type": "git",
                        "vendor": "Red Hat, Inc.",
                        "version": "1.16"
                    }
                },
                {
                    "agent": true,
                    "alias": "quarkus-test-agent",
                    "annotations": {
                        "cryostat": {
                            "HOST": "quarkus-test-agent",
                            "JAVA_MAIN": "/deployments/quarkus-run.jar",
                            "PID": "1",
                            "PORT": "9977",
                            "REALM": "quarkus-test-agent",
                            "START_TIME": "1691615019"
                        },
                        "platform": {
                            "INSTANCE_ID": "f8119383-381d-403c-9d87-e8ba9252c9f1"
                        }
                    },
                    "connectUrl": "http://quarkus-test-agent:9977/",
                    "id": 2,
                    "jvmId": "g-f7kZWnSFXrVWpUPatYlPzH3N1q0n3Ol-0jqRnvEkA=",
                    "labels": {}
                },
                {
                    "agent": true,
                    "alias": "vertx-fib-demo-1",
                    "annotations": {
                        "cryostat": {
                            "HOST": "vertx-fib-demo-1",
                            "JAVA_MAIN": "es.andrewazor.demo.Main -javaagent:/opt/jib-agents/cryostat-agent-0.3.0-SNAPSHOT.jar",
                            "PID": "1",
                            "PORT": "8910",
                            "REALM": "vertx-fib-demo-1",
                            "START_TIME": "1691615042"
                        },
                        "platform": {
                            "INSTANCE_ID": "74dde311-d0df-4402-a098-1a4c142c7fe1"
                        }
                    },
                    "connectUrl": "http://sample-app:8910/",
                    "id": 4,
                    "jvmId": "OhiClnUYNw9YmgyFWVpbAJsvIFVHbu9_lJsKkS_Eoxs=",
                    "labels": {}
                }
            ]
        }
    },
    "meta": {
        "status": "OK",
        "type": "application/json"
    }
}

but I think it should only give a response filtered from the list of targets in the json we supply?

@github-actions
Copy link

This PR/issue depends on:

@andrewazores
Copy link
Member Author

I guess PR CI doesn't work because the runner doesn't have permissions to the private fork repositories.

@maxcao13
Copy link
Member

maxcao13 commented Aug 21, 2023

if i have a query like this:

{
  "matchExpression": "true",
  "targets": [{
                        "agent": false,
                        "alias": "asdfasdf",
                        "annotations": {
                            "cryostat": {
                                "HOST": "asdf",
                                "JAVA_MAIN": "asdf",
                                "PORT": "asdf",
                                "REALM": "asdf"
                            },
                            "platform": {}
                        },
                        "connectUrl": "service:jmx:rmi:///jndi/rmi://sample-app:9093/jmxrmi",
                        "id": 9999,
                        "jvmId": "asdfasdf",
                        "labels": {}
                    }]
                  }

i get something like this:

{
    "data": {
        "result": {
            "expression": "true",
            "id": null,
            "targets": [
                {
                    "agent": false,
                    "alias": "asdfasdf",
                    "annotations": {
                        "cryostat": {
                            "HOST": "asdf",
                            "JAVA_MAIN": "asdf",
                            "PORT": "asdf",
                            "REALM": "asdf"
                        },
                        "platform": {}
                    },
                    "connectUrl": "service:jmx:rmi:///jndi/rmi://sample-app:9093/jmxrmi",
                    "id": 9999,
                    "jvmId": "asdfasdf",
                    "labels": {}
                }
            ]
        }
    },
    "meta": {
        "status": "OK",
        "type": "application/json"
    }
}

I think it's only caring about matching the connectUrl? Other fields seem to not matter.

If that's intended, then I guess it makes sense, since we are deprecating to match on ids in the future and ignoring all these other fields anyways?

@andrewazores
Copy link
Member Author

I don't think I understand the example. The query has matchExpression: "true" - how do you figure the connectUrl is significant?

@maxcao13
Copy link
Member

maxcao13 commented Aug 22, 2023

I don't think I understand the example. The query has matchExpression: "true" - how do you figure the connectUrl is significant?

Sorry I meant that in the query: the other fields that I enter do not matter at all.

I can have alias: anything or jvmId: 1234567890987654331 which may or may not be the actual alias/jvmId of any existing target, but if I change the connectUrl to something like localhost:0, it response will not return any matching targets (assuming there is no actual target with this connectUrl in the db).

@andrewazores
Copy link
Member Author

andrewazores commented Aug 22, 2023

Ah, I see what you mean, thanks. I'll take a look tomorrow. My initial thought is that this probably makes sense - I think the client should only be able to ask the server to check against all targets, or against a subset of already-known targets, and in the latter case it makes sense to just provide a unique ID for them. Though, this should probably be the numeric database ID and not the connection URL. This would also need supporting changes on the client side however. This would mean the endpoint is not usable as a connection test endpoint for custom targets, though.

@andrewazores
Copy link
Member Author

Looks like I had left this FIXME in the code:

    // FIXME in a later API version this request should not accept full target objects from the
    // client but instead only a list of IDs, which will then be pulled from the target discovery
    // database for testing

so I guess what you're describing is (currently) expected behaviour 😁

I'll file a follow-up issue to fix this later. Either after 2.4.0 is out and this repo becomes the main focus, and -web is either retargeted for this or rolled into this, or at some other point when we have a strategy for making -web updates for 2.x vs 3.0 API differences.

@andrewazores
Copy link
Member Author

Reading through the implementation I'm not actually sure how it's only the connection URL that is treated as significant, however. This should end up just deserializing the request data as a List<Target> where Target is the database model type and should properly implement hashCode() / equals(). The match expression evaluation isn't doing anything particularly complicated here, it just applies the provided expression to the provided list of targets. Hmm...

@maxcao13
Copy link
Member

maxcao13 commented Aug 23, 2023

Reading through the implementation I'm not actually sure how it's only the connection URL that is treated as significant, however. This should end up just deserializing the request data as a List<Target> where Target is the database model type and should properly implement hashCode() / equals(). The match expression evaluation isn't doing anything particularly complicated here, it just applies the provided expression to the provided list of targets. Hmm...

Hm... I'm guessing when we supply the json to the endpoint, somewhere it doesn't care about if the targets are actually real, and only cares if it fits the Target specification (in this case whatever the db schema is for Target). So when we pass a target in, it executes the script correctly, just that the target may or may not be real.

@andrewazores
Copy link
Member Author

That is true, it just deserializes the Targets passed in the request, and doesn't actually do any checking against the database right now. I guess that would be one potential enhancement but I'm not sure it's worthwhile to do right now since the plan (before 3.0 is out, hopefully) is to revamp this to just accept that list of DB IDs anyway.

@maxcao13
Copy link
Member

Looks fine to me then, the enhancement of using ids will make this obsolete.

Copy link
Member

@maxcao13 maxcao13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@andrewazores andrewazores merged commit b598524 into cryostatio:main Aug 23, 2023
4 of 6 checks passed
@andrewazores andrewazores deleted the expression-resource branch August 23, 2023 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Refactor, rename, cleanup, etc.
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants