foreman icon indicating copy to clipboard operation
foreman copied to clipboard

Fixes #37664 - switch to using js-cookie

Open MariaAga opened this issue 1 year ago • 6 comments

replaces jquery.cookie with js-cookie, as jquery.cookie has moved to js-cookie

MariaAga avatar Jul 18 '24 18:07 MariaAga

Should I try to create a packaging PR as well for this? @theforeman/packaging

MariaAga avatar Jul 18 '24 18:07 MariaAga

Added packaging pr https://github.com/theforeman/foreman-packaging/pull/11048

MariaAga avatar Jul 22 '24 10:07 MariaAga

Added it to tfm as well as some plugins are using it

MariaAga avatar Jul 22 '24 13:07 MariaAga

Yeah I see test_0002_correctly override global params fail on some prs and cant reproduce it locally

MariaAga avatar Jul 23 '24 07:07 MariaAga

I bet it'll turn out to be some nasty race condition or https://github.com/theforeman/actions/issues/53

ekohl avatar Jul 23 '24 07:07 ekohl

Rebased

MariaAga avatar Sep 03 '24 14:09 MariaAga

/packit build

adamruzicka avatar Oct 22 '24 07:10 adamruzicka

The packit build failures will probably need more changes here

+ /usr/bin/rake webpack:compile DATABASE_URL=nulldb://nohost
2024-10-22T07:28:51 [I|app|] Rails cache backend: File
2024-10-22T07:28:51 [W|app|] You are trying to replace import_subnets from . Adding allowed actions from plugin permissions to the existing one.
npx --max_old_space_size=2048 webpack --config /builddir/build/BUILD/foreman-3.13.0/config/webpack.config.js --bail
[webpack-cli] ModuleNotFoundError: Module not found: Error: Can't resolve 'js-cookie' in '/builddir/build/BUILD/foreman-3.13.0/webpack/assets/javascripts'
    at /usr/lib/node_modules/webpack/lib/Compilation.js:2029:28
    at /usr/lib/node_modules/webpack/lib/NormalModuleFactory.js:817:13
    at eval (eval at create (/usr/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
    at /usr/lib/node_modules/webpack/lib/NormalModuleFactory.js:275:22
    at eval (eval at create (/usr/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
    at /usr/lib/node_modules/webpack/lib/NormalModuleFactory.js:448:22
    at /usr/lib/node_modules/webpack/lib/NormalModuleFactory.js:118:11
    at /usr/lib/node_modules/webpack/lib/NormalModuleFactory.js:689:25
    at /usr/lib/node_modules/webpack/lib/NormalModuleFactory.js:893:8
    at /usr/lib/node_modules/webpack/lib/NormalModuleFactory.js:1013:5
    at /usr/lib/node_modules/webpack/node_modules/neo-async/async.js:6883:13
    at /usr/lib/node_modules/webpack/lib/NormalModuleFactory.js:996:45
    at finishWithoutResolve (/usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:372:11)
    at /usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:461:15
    at /usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:519:5
    at eval (eval at create (/usr/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at /usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:519:5
    at eval (eval at create (/usr/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
    at /usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:89:43
    at /usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:519:5
    at eval (eval at create (/usr/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
    at /usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/forEachBail.js:39:13
    at /usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/AliasPlugin.js:148:14
    at next (/usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/forEachBail.js:35:3)
    at forEachBail (/usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/forEachBail.js:49:9)
    at /usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/AliasPlugin.js:61:5
    at _next0 (eval at create (/usr/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:8:1)
    at eval (eval at create (/usr/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:30:1)
    at /usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:519:5
    at eval (eval at create (/usr/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
    at /usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:519:5
    at eval (eval at create (/usr/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
    at /usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:519:5
    at eval (eval at create (/usr/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
    at /usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:89:43
    at /usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:519:5
    at eval (eval at create (/usr/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
    at /usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/Resolver.js:519:5
    at eval (eval at create (/usr/lib/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
    at /usr/lib/node_modules/webpack/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js:41:15
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)
resolve 'js-cookie' in '/builddir/build/BUILD/foreman-3.13.0/webpack/assets/javascripts'
  Parsed request is a module
  using description file: /builddir/build/BUILD/foreman-3.13.0/package.json (relative path: ./webpack/assets/javascripts)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      /builddir/build/BUILD/foreman-3.13.0/webpack/assets/javascripts/node_modules doesn't exist or is not a directory
      /builddir/build/BUILD/foreman-3.13.0/webpack/assets/node_modules doesn't exist or is not a directory
      /builddir/build/BUILD/foreman-3.13.0/webpack/node_modules doesn't exist or is not a directory
      looking for modules in /builddir/build/BUILD/foreman-3.13.0/node_modules
        single file module
          using description file: /builddir/build/BUILD/foreman-3.13.0/package.json (relative path: ./node_modules/js-cookie)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /builddir/build/BUILD/foreman-3.13.0/node_modules/js-cookie doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /builddir/build/BUILD/foreman-3.13.0/node_modules/js-cookie.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /builddir/build/BUILD/foreman-3.13.0/node_modules/js-cookie.json doesn't exist
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              /builddir/build/BUILD/foreman-3.13.0/node_modules/js-cookie.wasm doesn't exist
        /builddir/build/BUILD/foreman-3.13.0/node_modules/js-cookie doesn't exist
      /builddir/build/BUILD/node_modules doesn't exist or is not a directory
      /builddir/build/node_modules doesn't exist or is not a directory
      /builddir/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
rake aborted!
Command failed with status (2): [npx --max_old_space_size=2048 webpack --co...]
/builddir/build/BUILD/foreman-3.13.0/lib/tasks/webpack_compile.rake:18:in `block (2 levels) in <top (required)>'
/usr/share/gems/gems/rake-13.0.3/exe/rake:27:in `<top (required)>'
Tasks: TOP => webpack:compile
(See full trace by running task with --trace)
error: Bad exit status from /var/tmp/rpm-tmp.0uyi44 (%build)
    Bad exit status from /var/tmp/rpm-tmp.0uyi44 (%build)

adamruzicka avatar Oct 22 '24 07:10 adamruzicka

This change will require a specfile update (new dependency), and thus I don't think the packit build step will ever pass on the PR.

ehelms avatar Oct 23 '24 13:10 ehelms

@ehelms doesnt the packaging update (was merged already) take care of that?

MariaAga avatar Oct 23 '24 13:10 MariaAga

@ehelms doesnt the packaging update (was merged already) take care of that?

The packaging PR (https://github.com/theforeman/foreman-packaging/pull/11048/files) adds the package but does not update Foreman to require the package. Thus it does not get pulled in during build time and the above error occurs. This is a bit of a chicken and egg problem. We do not update the spec with new dependencies until the code has the dependency merged, but RPM builds will fail until we update the spec with the new build. We tend to just accept that packit will fail in this case and that's OK.

ehelms avatar Oct 23 '24 13:10 ehelms

The packaging PR (https://github.com/theforeman/foreman-packaging/pull/11048/files) adds the package but does not update Foreman to require the package. Thus it does not get pulled in during build time and the above error occurs. This is a bit of a chicken and egg problem. We do not update the spec with new dependencies until the code has the dependency merged, but RPM builds will fail until we update the spec with the new build. We tend to just accept that packit will fail in this case and that's OK.

https://github.com/theforeman/foreman-packaging/pull/8414 intends to solve that by dynamically generating the build requires. We're working on dropping EL8, which was a blocker to using this. I also need to write the NodeJS side of it, but I don't expect to wrap that up in time for this PR.

ekohl avatar Oct 23 '24 15:10 ekohl

Also, plugins will still be able to use it the old way until we drop jquery completely, correct?

adamruzicka avatar Nov 12 '24 13:11 adamruzicka

Yes, but I tried to catch the only plugin that used it here: https://github.com/theforeman/foreman_openscap/pull/576

MariaAga avatar Nov 12 '24 14:11 MariaAga

Thank you everyone

adamruzicka avatar Nov 26 '24 09:11 adamruzicka