[Actions] Add emitter-usages hydration (#24640)
* Move writeback migrations to 45 * Empty commit to trigger GitHub Actions * [Actions] Simplify emitter schema model emitter_action was dropped since emitters just have a singular action and the join table was unecessary. emitter_action.action_id columns moved onto emitter table. Dropped CardEmitter and DashboardEmitter pre-insert, pre-update, pre-delete since they were used in tests only and normal operation would see the emitter inserted first. Since previous code may have 'orphaned' emitters without an action, we delete emitters without action to be safe. * Handle flakiness with geojson java.net.UnknownHostException errors (#24523) * Handle flakiness with geojson java.net.UnknownHostException errors In CI seems like we are getting errant errors: ```clojure geojson.clj:62 It validates URLs and files appropriately http://0xc0000200 expected: (valid? geojson) actual: #error { :cause "Invalid IP address literal: 0xc0000200" :via [{:type clojure.lang.ExceptionInfo :message "Invalid GeoJSON file location: must either start with http:// or https:// or be a relative path to a file on the classpath. URLs referring to hosts that supply internal hosting metadata are prohibited." :data {:status-code 400, :url "http://0xc0000200"} :at [metabase.api.geojson$valid_url_QMARK_ invokeStatic "geojson.clj" 62]} {:type java.net.UnknownHostException :message "0xc0000200" :at [java.net.InetAddress getAllByName "InetAddress.java" 1340]} {:type java.lang.IllegalArgumentException :message "Invalid IP address literal: 0xc0000200" :at [sun.net.util.IPAddressUtil validateNumericFormatV4 "IPAddressUtil.java" 150]}] ``` Not clear if this change has a hope of fixing it: if it doesn't resolve once its possible it is cached somewhere in the network stack, or it won't resolve if you ask again. But gonna give it a shot. Set the property `"networkaddress.cache.negative.ttl"` to `"0"` > networkaddress.cache.negative.ttl (default: 10) > Indicates the caching policy for un-successful name lookups from the name service. The value is specified as an integer to indicate the number of seconds to cache the failure for un-successful lookups. > A value of 0 indicates "never cache". A value of -1 indicates "cache forever". From https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/net/InetAddress.html in the hopes that we can try multiple times. Restores the original value after the test completes so we don't inadvertently change behavior elsewhere. If we get an error of java.net.UnknownHostException we try again if we have attempts remaining. If we get a boolean it means the ip resolution worked so we can rely on the response (checking if it resolves locally or not) * add a delay * comment out test * [Actions] Add emitter-usages hydration This allows the front end to inform users of dashboards or cards that will be affected before deleting actions. Adds an `emitter-usages` hydration that shows emitters that reference a specific action or `is_write` card. The shape of `emitter-usages` is `[{:type "dashboard" :id 1 :name "Dashboard Name"} {:type "card" :id 2 :name "Card Name"}]`. * Add tests for new hydrations * add docstrings to 2 public emitter usage functions Co-authored-by:Cam Saul <github@camsaul.com> Co-authored-by:
dpsutton <dan@dpsutton.com> Co-authored-by:
Bryan Maass <bryan.maass@gmail.com>
Showing
- src/metabase/api/action.clj 5 additions, 4 deletionssrc/metabase/api/action.clj
- src/metabase/api/card.clj 10 additions, 4 deletionssrc/metabase/api/card.clj
- src/metabase/models/emitter.clj 52 additions, 0 deletionssrc/metabase/models/emitter.clj
- test/metabase/actions/test_util.clj 1 addition, 1 deletiontest/metabase/actions/test_util.clj
- test/metabase/models/emitter_test.clj 21 additions, 1 deletiontest/metabase/models/emitter_test.clj
Loading
Please register or sign in to comment