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

Migrate the kickstart script commands #5739

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

adamkankovsky
Copy link
Contributor

@adamkankovsky adamkankovsky commented Jul 3, 2024

Working with: #5775
Thanks @rvykydal.

@pep8speaks
Copy link

pep8speaks commented Jul 3, 2024

Hello @adamkankovsky! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-09-19 14:31:42 UTC

@adamkankovsky adamkankovsky marked this pull request as draft July 3, 2024 06:22
@github-actions github-actions bot added the f41 label Jul 3, 2024
Copy link
Member

@jkonecny12 jkonecny12 left a comment

Choose a reason for hiding this comment

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

Otherwise looks good to me so far.

scriptsdir = $(pkgpyexecdir)/modules/runtime/scripts
dist_scripts_DATA = $(wildcard $(srcdir)/*.py)

MAINTAINERCLEANFILES = Makefile.in
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
MAINTAINERCLEANFILES = Makefile.in
MAINTAINERCLEANFILES = Makefile.in

Copy link
Member

Choose a reason for hiding this comment

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

Add missing newline at the end of the file.

# along with this program. If not, see <http://www.gnu.org/licenses/>.

pkgpyexecdir = $(pyexecdir)/py$(PACKAGE_NAME)
scriptsdir = $(pkgpyexecdir)/modules/runtime/scripts
Copy link
Member

Choose a reason for hiding this comment

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

I have a feeling that his will not work correctly. There is already scriptsdir variable (scripts/Makefile.am) and I have a feeling these are global. I'm not 100% sure how ti behaves so please make sure that your commit won't break automake and both directories are processed correctly by automake.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So far everything works as it should and there is no problem with the module

@rvykydal
Copy link
Contributor

rvykydal commented Jul 18, 2024

I'll just add link to my WIP before @adamkankovsky took over: #5775, may be useful for reference. (I used Katerina's WIP in the same way).
In my notes in 9d3fb85 I say %pre is most challenging, so maybe it is good to work on it first, like Adam does.

@adamkankovsky adamkankovsky marked this pull request as ready for review July 23, 2024 13:15
@adamkankovsky adamkankovsky changed the title Migrate the %pre script Migrate the kickstart script commands Jul 24, 2024
@adamkankovsky
Copy link
Contributor Author

/kickstart-test --testtype smoke

@adamkankovsky
Copy link
Contributor Author

/kickstart-test --testtype smoke

Copy link
Member

@jkonecny12 jkonecny12 left a comment

Choose a reason for hiding this comment

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

Looks great otherwise.
Also please take a look on coverage. I'm surprised that for such a change we don't have any new tests.

execution.
Output is logged by the program logger, the path specified by --log
or to /tmp/ks-script-\\*.log
# TODORV return
Copy link
Member

Choose a reason for hiding this comment

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

I guess this is leftover.

@@ -0,0 +1,80 @@
#
# Commond utilities for working with scripts
Copy link
Member

Choose a reason for hiding this comment

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

Commond is typo?

Comment on lines +94 to +95
self.scripts = []

Copy link
Member

Choose a reason for hiding this comment

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

Why is this required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because sections for scripts don't have a data parser like packages does, and sections themselves don't have an action to create an array for scitps. Therefore it is necessary to create it manually. It looks quite strange, but I spent a lot of time on this parsing and unfortunately I didn't come up with anything better using pykickstart

for script in self._scripts:
if script.type == self._script_type:
if script.type == KS_SCRIPT_POST:
script.run(conf.target.system_root)
Copy link
Member

Choose a reason for hiding this comment

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

If I'm reading this correctly then you are saying that post script is always run in chroot. That is not correct it depends on --nochroot parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is only the path which is used if --chroot is set. Default is always "/".

__all__ = ["ScriptsModule"]


class RunScriptsTask(Task):
Copy link
Member

Choose a reason for hiding this comment

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

Please separate this class into another file.

@adamkankovsky
Copy link
Contributor Author

/kickstart-test image-deployment-2

@rvykydal
Copy link
Contributor

rvykydal commented Sep 3, 2024

/kickstart-test image-deployment-2

@rvykydal
Copy link
Contributor

rvykydal commented Sep 3, 2024

/kickstart-test --skip-testtypes whatever

@rvykydal
Copy link
Contributor

rvykydal commented Sep 3, 2024

I wonder if we can (as a follow-up, not requiring in scope of this PR) add some kickstart tests testing the scripts. In general, post and pre would be perhaps well tested by existing tests as they are using them heavily, but we may want to test also

  • various options (as erroronfail)
  • if the scripts are logged, failures reported as expected
  • %onerror and %traceback
    It can be difficult with current kickstart tests capabilities but we could have at least MANUAL tests (checking the result, ie error dialog appearing by developer). For development, reference, and maybe future automation.

@rvykydal
Copy link
Contributor

rvykydal commented Sep 3, 2024

/kickstart-test --testtype smoke

@rvykydal
Copy link
Contributor

rvykydal commented Sep 3, 2024

/kickstart-test --testtype smoke

The tests are failing.

10:16:09,148 WARNING org.fedoraproject.Anaconda.Modules.Runtime:INFO:anaconda.core.threads:Thread Failed: AnaTaskThread-RunScriptsTask-2 (140199159924416)
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:ERROR:anaconda.modules.common.task.task:Thread AnaTaskThread-RunScriptsTask-2 has failed: Traceback (most recent call last):
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:  File "/usr/lib64/python3.13/site-packages/pyanaconda/core/threads.py", line 280, in run
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:    threading.Thread.run(self)
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:    ~~~~~~~~~~~~~~~~~~~~^^^^^^ 
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:  File "/usr/lib64/python3.13/threading.py", line 992, in run
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:    self._target(*self._args, **self._kwargs)
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:  File "/usr/lib64/python3.13/site-packages/pyanaconda/modules/common/task/task.py", line 94, in _thread_run_callback
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:    self._task_run_callback()
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:    ~~~~~~~~~~~~~~~~~~~~~~~^^
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:  File "/usr/lib64/python3.13/site-packages/pyanaconda/modules/common/task/task.py", line 107, in _task_run_callback
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:    self._set_result(self.run())
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:                     ~~~~~~~~^^
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:  File "/usr/lib64/python3.13/site-packages/pyanaconda/modules/runtime/scripts/runtime.py", line 51, in run
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:    lineno, err = script.run(conf.target.system_root)
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:    ^^^^^^^^^^^
10:16:09,176 WARNING org.fedoraproject.Anaconda.Modules.Runtime:TypeError: cannot unpack non-iterable NoneType object

@rvykydal
Copy link
Contributor

rvykydal commented Sep 3, 2024

I was also wondering if we should pass failing (erroronfail) script via return values and handle / raise in client rather then via dbus error / exception. But I am not deep enough in the matter to be able to give reasons.

@adamkankovsky
Copy link
Contributor Author

/kickstart-test --testtype smoke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

4 participants