From 1e00081991edb614de78f7f68b8ea2447ceaa835 Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Feb 10 2022 14:44:04 +0000 Subject: [PATCH 1/4] refactor exceptions to koji.exceptions Move Koji's custom exceptions classes to a dedicated koji.exceptions library. This organizes the code so it's easier to maintain, and matches patterns in other well-known projects, like requests.exceptions or cryptography.exceptions. --- diff --git a/koji/__init__.py b/koji/__init__.py index fa89f3b..8160b9f 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -76,6 +76,34 @@ from . import _version __version__ = _version.__version__ __version_info__ = _version.__version_info__ +from koji.exceptions import ( + PythonImportError, + GenericError, + LockError, + AuthError, + TagError, + ActionNotAllowed, + BuildError, + AuthLockError, + AuthExpired, + SequenceError, + RetryError, + PreBuildError, + PostBuildError, + BuildrootError, + FunctionDeprecated, + ServerOffline, + LiveCDError, + PluginError, + CallbackError, + ApplianceError, + ParameterError, + ImportError, + ConfigurationError, + LiveMediaError, + GSSAPIAuthError, +) + try: import requests_gssapi as reqgssapi except ImportError: # pragma: no cover @@ -292,145 +320,6 @@ PRIO_DEFAULT = 20 DEFAULT_REQUEST_TIMEOUT = 60 * 60 * 12 DEFAULT_AUTH_TIMEOUT = 60 -# BEGIN kojikamid dup # - -# Exceptions -PythonImportError = ImportError # will be masked by koji's one - - -class GenericError(Exception): - """Base class for our custom exceptions""" - faultCode = 1000 - fromFault = False - - def __str__(self): - try: - return str(self.args[0]['args'][0]) - except Exception: - try: - return str(self.args[0]) - except Exception: - return str(self.__dict__) -# END kojikamid dup # - - -class LockError(GenericError): - """Raised when there is a lock conflict""" - faultCode = 1001 - - -class AuthError(GenericError): - """Raised when there is an error in authentication""" - faultCode = 1002 - - -class TagError(GenericError): - """Raised when a tagging operation fails""" - faultCode = 1003 - - -class ActionNotAllowed(GenericError): - """Raised when the session does not have permission to take some action""" - faultCode = 1004 - -# BEGIN kojikamid dup # - - -class BuildError(GenericError): - """Raised when a build fails""" - faultCode = 1005 -# END kojikamid dup # - - -class AuthLockError(AuthError): - """Raised when a lock prevents authentication""" - faultCode = 1006 - - -class AuthExpired(AuthError): - """Raised when a session has expired""" - faultCode = 1007 - - -class SequenceError(AuthError): - """Raised when requests are received out of sequence""" - faultCode = 1008 - - -class RetryError(AuthError): - """Raised when a request is received twice and cannot be rerun""" - faultCode = 1009 - - -class PreBuildError(BuildError): - """Raised when a build fails during pre-checks""" - faultCode = 1010 - - -class PostBuildError(BuildError): - """Raised when a build fails during post-checks""" - faultCode = 1011 - - -class BuildrootError(BuildError): - """Raised when there is an error with the buildroot""" - faultCode = 1012 - - -class FunctionDeprecated(GenericError): - """Raised by a deprecated function""" - faultCode = 1013 - - -class ServerOffline(GenericError): - """Raised when the server is offline""" - faultCode = 1014 - - -class LiveCDError(GenericError): - """Raised when LiveCD Image creation fails""" - faultCode = 1015 - - -class PluginError(GenericError): - """Raised when there is an error with a plugin""" - faultCode = 1016 - - -class CallbackError(PluginError): - """Raised when there is an error executing a callback""" - faultCode = 1017 - - -class ApplianceError(GenericError): - """Raised when Appliance Image creation fails""" - faultCode = 1018 - - -class ParameterError(GenericError): - """Raised when an rpc call receives incorrect arguments""" - faultCode = 1019 - - -class ImportError(GenericError): - """Raised when an import fails""" - faultCode = 1020 - - -class ConfigurationError(GenericError): - """Raised when load of koji configuration fails""" - faultCode = 1021 - - -class LiveMediaError(GenericError): - """Raised when LiveMedia Image creation fails""" - faultCode = 1022 - - -class GSSAPIAuthError(AuthError): - """Raised when GSSAPI issue in authentication""" - faultCode = 1023 - class NameValidationError(GenericError): """Raised when name validation fails diff --git a/koji/exceptions.py b/koji/exceptions.py new file mode 100644 index 0000000..67f2a08 --- /dev/null +++ b/koji/exceptions.py @@ -0,0 +1,132 @@ +# Exceptions +PythonImportError = ImportError # will be masked by koji's one + + +class GenericError(Exception): + """Base class for our custom exceptions""" + faultCode = 1000 + fromFault = False + + def __str__(self): + try: + return str(self.args[0]['args'][0]) + except Exception: + try: + return str(self.args[0]) + except Exception: + return str(self.__dict__) + + +class LockError(GenericError): + """Raised when there is a lock conflict""" + faultCode = 1001 + + +class AuthError(GenericError): + """Raised when there is an error in authentication""" + faultCode = 1002 + + +class TagError(GenericError): + """Raised when a tagging operation fails""" + faultCode = 1003 + + +class ActionNotAllowed(GenericError): + """Raised when the session does not have permission to take some action""" + faultCode = 1004 + + +class BuildError(GenericError): + """Raised when a build fails""" + faultCode = 1005 + + +class AuthLockError(AuthError): + """Raised when a lock prevents authentication""" + faultCode = 1006 + + +class AuthExpired(AuthError): + """Raised when a session has expired""" + faultCode = 1007 + + +class SequenceError(AuthError): + """Raised when requests are received out of sequence""" + faultCode = 1008 + + +class RetryError(AuthError): + """Raised when a request is received twice and cannot be rerun""" + faultCode = 1009 + + +class PreBuildError(BuildError): + """Raised when a build fails during pre-checks""" + faultCode = 1010 + + +class PostBuildError(BuildError): + """Raised when a build fails during post-checks""" + faultCode = 1011 + + +class BuildrootError(BuildError): + """Raised when there is an error with the buildroot""" + faultCode = 1012 + + +class FunctionDeprecated(GenericError): + """Raised by a deprecated function""" + faultCode = 1013 + + +class ServerOffline(GenericError): + """Raised when the server is offline""" + faultCode = 1014 + + +class LiveCDError(GenericError): + """Raised when LiveCD Image creation fails""" + faultCode = 1015 + + +class PluginError(GenericError): + """Raised when there is an error with a plugin""" + faultCode = 1016 + + +class CallbackError(PluginError): + """Raised when there is an error executing a callback""" + faultCode = 1017 + + +class ApplianceError(GenericError): + """Raised when Appliance Image creation fails""" + faultCode = 1018 + + +class ParameterError(GenericError): + """Raised when an rpc call receives incorrect arguments""" + faultCode = 1019 + + +class ImportError(GenericError): + """Raised when an import fails""" + faultCode = 1020 + + +class ConfigurationError(GenericError): + """Raised when load of koji configuration fails""" + faultCode = 1021 + + +class LiveMediaError(GenericError): + """Raised when LiveMedia Image creation fails""" + faultCode = 1022 + + +class GSSAPIAuthError(AuthError): + """Raised when GSSAPI issue in authentication""" + faultCode = 1023 From 3ff8eef322e9481609106945db83cc5bfe5bd5d9 Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Feb 10 2022 14:44:04 +0000 Subject: [PATCH 2/4] add "NoSuch" custom exceptions Add more custom exception classes. This will allow to programmatically determine the error causes from complex RPCs. This commit simply defines the new classes and fault codes. Nothing in Koji's codebase uses these exceptions yet. We'll begin to raise these exceptions after this is widely deployed for clients in the field. --- diff --git a/koji/exceptions.py b/koji/exceptions.py index 67f2a08..d5f1537 100644 --- a/koji/exceptions.py +++ b/koji/exceptions.py @@ -130,3 +130,51 @@ class LiveMediaError(GenericError): class GSSAPIAuthError(AuthError): """Raised when GSSAPI issue in authentication""" faultCode = 1023 + + +class NoSuchArchive(object): + faultCode = 1024 + + +class NoSuchBuild(object): + faultCode = 1025 + + +class NoSuchChannel(object): + faultCode = 1026 + + +class NoSuchContentGenerator(object): + faultCode = 1027 + + +class NoSuchPackage(object): + faultCode = 1028 + + +class NoSuchPermission(object): + faultCode = 1029 + + +class NoSuchRPM(object): + faultCode = 1030 + + +class NoSuchRepo(object): + faultCode = 1031 + + +class NoSuchTag(object): + faultCode = 1032 + + +class NoSuchTarget(object): + faultCode = 1033 + + +class NoSuchTask(object): + faultCode = 1034 + + +class NoSuchUser(object): + faultCode = 1035 From 7081ce90dbb2b86b799c790cbfa147d3082ae530 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Feb 10 2022 14:45:01 +0000 Subject: [PATCH 3/4] Koji 1.28.0 release notes Fixes: https://pagure.io/koji/issue/3224 --- diff --git a/docs/source/migrations/migrating_to_1.28.rst b/docs/source/migrations/migrating_to_1.28.rst new file mode 100644 index 0000000..0a4df81 --- /dev/null +++ b/docs/source/migrations/migrating_to_1.28.rst @@ -0,0 +1,22 @@ +Migrating to Koji 1.28 +====================== + +You should consider the following changes when migrating to 1.28: + +DB Updates +---------- + +There is a simple schema change adding descriptions to individual permissions. + +As in previous releases, we provide a migration script that updates the database. + +:: + + # psql koji koji < /usr/share/doc/koji/docs/schema-upgrade-1.27-1.28.sql + + +Other changes +------------- + +There are numerous other changes in 1.28 that should not have a direct impact on migration. For +details see: :doc:`../release_notes/release_notes_1.28` diff --git a/docs/source/migrations/migrations.rst b/docs/source/migrations/migrations.rst index a6a7c22..88f8d49 100644 --- a/docs/source/migrations/migrations.rst +++ b/docs/source/migrations/migrations.rst @@ -5,6 +5,7 @@ Migrations .. toctree:: :maxdepth: 1 + migrating_to_1.28 migrating_to_1.27 migrating_to_1.26 migrating_to_1.25 diff --git a/docs/source/release_notes/release_notes.rst b/docs/source/release_notes/release_notes.rst index b66552c..b5001ca 100644 --- a/docs/source/release_notes/release_notes.rst +++ b/docs/source/release_notes/release_notes.rst @@ -5,6 +5,7 @@ Release Notes .. toctree:: :maxdepth: 1 + release_notes_1.28 release_notes_1.27.1 release_notes_1.27 release_notes_1.26.1 diff --git a/docs/source/release_notes/release_notes_1.28.rst b/docs/source/release_notes/release_notes_1.28.rst new file mode 100644 index 0000000..1467241 --- /dev/null +++ b/docs/source/release_notes/release_notes_1.28.rst @@ -0,0 +1,201 @@ +Koji 1.28.0 Release notes +========================= + +All changes can be found in `the roadmap `_. +Most important changes are listed here. + + +Migrating from Koji 1.27/1.27.1 +------------------------------- + +For details on migrating see :doc:`../migrations/migrating_to_1.28` + + +Security Fixes +-------------- + +None + + +Client Changes +-------------- +**Deprecated --paths option in list-buildroot** + +| PR: https://pagure.io/koji/pull-request/3105 + +This option doesn't have any effect, so it should be removed in the near future. + +**Remove rename-channel CLI and use editChannel in renameChannel** + +| PR: https://pagure.io/koji/pull-request/3108 + +As we've extended ``edit-channel`` command this one is a redundant now. Same can +be achieved with ``edit-channel --name``. + +**mock-config: if topdir option is used, remove topurl** + +| PR: https://pagure.io/koji/pull-request/3146 + +``--topdir`` option is treated as a superior to ``--topurl``. Specifying both +doesn't have semantical value, so we're overriding the second one. + + +API Changes +----------- +**Deprecated force option in groupPackageListRemove call** + +| PR: https://pagure.io/koji/pull-request/3145 + +``force`` doesn't affect the call and as such can be confusing. User could +expect something which is not really happening (e.g. overriding some locks). +We're going to remove this option in near future. + +**Deprecated remove-channel CLI and removeChannel API** + +| PR: https://pagure.io/koji/pull-request/3158 + +``edit-channel`` and ``editChannel`` can do the same now. + +**listPackages has now default with_blocked=True** + +| PR: https://pagure.io/koji/pull-request/3196 + +It is more a regression fix and returning to original behaviour with this new +option. + + +Builder Changes +--------------- +**AuthExpire returns code 1 in kojid** + +| PR: https://pagure.io/koji/pull-request/3119 + +For automation of ``kojid`` restarts it is useful to retun exit code instead of +raising an exception. + +System Changes +-------------- +**Add limits on name values** + +| PR: https://pagure.io/koji/pull-request/3028 + +Historically we were not casting any limits on names used throughout the koji. +We've trusted admins to create meaningful names. Nevertheless, some automation +tools are now having permissions which allow them to create tags, targets, etc. +As we're not able to control their code, we've introduced name templates which +can be used to limit which characters (via regexps) can be part of names. For +details see the documentation for hub options ``RegexNameInternal``, +``RegexUserName`` and ``MaxNameLengthInternal``. + +**RLIMIT_OFILE alias for RLIMIT_NOFILE** + +| PR: https://pagure.io/koji/pull-request/3116 + +``RLIMIT_OFILE`` is an old deprecated name, so we're using it as an alias for +now. + +**Deprecated hub option DisableGSSAPIProxyDNFallback** + +| PR: https://pagure.io/koji/pull-request/3117 + +Option doesn't affect anything anymore. + +**Centralize name/id lookup clauses** + +| PR: https://pagure.io/koji/pull-request/3123 + +Code improvement to make SQL layer more consistent. + +**only raise error when authtype is not proxyauthtype** + +| PR: https://pagure.io/koji/pull-request/3164 + +Fixing regression for webUIs having same authentication mechanism as user. + +**Add description for permissions** + +| PR: https://pagure.io/koji/pull-request/3214 + +All permissions now can have description visible via ``list-permissions``, so +they can be documented inside the koji not in external docs. + +**Provide meaningful message when importing image files fails** + +| PR: https://pagure.io/koji/pull-request/3223 + +More verbose error message for file types non-existent in the db. + +**Allow password in SCM url with new builder option** + +| PR: https://pagure.io/koji/pull-request/3212 + +Token/password can now be part of SCM url when submitting the build. Note, that +this will be visible everywhere and should be used only with caution (public +tokens). Otherwise, it can quite easily leak passwords. For the same reason this +behaviour must be explicitly allowed via ``allow_password_in_scm_url`` kojid +option. + +**lib: refactor variables in is_conn_err()** + +| PR: https://pagure.io/koji/pull-request/3204 + +Simple code cleanup + +Web +--- +**Rpminfo/fileinfo/imageinfo/archiveinfo page shows human-readable filesize** + +| PR: https://pagure.io/koji/pull-request/3137 + +**Taginfo page shows packages with/without blocked** + +| PR: https://pagure.io/koji/pull-request/3159 + +**Show total builds and add two more date options** + +| PR: https://pagure.io/koji/pull-request/3215 + +Buildsbystatus wep page is showing a bit more information now. + + +Plugins +------- +**protonmsg: allow users to specify router-specific topic prefixes** + +| PR: https://pagure.io/koji/pull-request/3168 + +**kiwi** + +Kiwi plugin for building images based on XML description files was extended and +refactored a bit, so it is now almost production-ready. We expect that in one or +two releases we can flip it to first-class plugin. + +**kiwi: implant releasever into kiwi description** + +| PR: https://pagure.io/koji/pull-request/3205 + +**kiwi: save modified .kiwi files per arch** + +| PR: https://pagure.io/koji/pull-request/3211 + +Documentation +------------- +**Explain IMA signing vs usual RPM signing** + +| PR: https://pagure.io/koji/pull-request/3206 + +**Improve multicall documentation** + +| PR: https://pagure.io/koji/pull-request/3226 + +**Additional explanations for RPM signatures** + +| PR: https://pagure.io/koji/pull-request/3218 + +**Link to koji overview video** + +| PR: https://pagure.io/koji/pull-request/3195 + +**Drop RHEL6 references** + +| PR: https://pagure.io/koji/pull-request/3177 diff --git a/koji.spec b/koji.spec index e5ab3c9..77cb84a 100644 --- a/koji.spec +++ b/koji.spec @@ -83,7 +83,7 @@ %define release %{baserelease} %endif Name: koji -Version: 1.27.1 +Version: 1.28.0 Release: %{release}%{?dist} License: LGPLv2 and GPLv2+ # the included arch lib from yum's rpmUtils is GPLv2+ @@ -644,6 +644,36 @@ rm -rf $RPM_BUILD_ROOT %endif %changelog +* Wed Feb 2 2022 Tomas Kopecek - 1.28.0-1 +- PR#3028: Add limits on name values +- PR#3105: Deprecated --paths option in list-buildroot +- PR#3108: Remove rename-channel CLI and use editChannel in renameChannel +- PR#3116: RLIMIT_OFILE alias for RLIMIT_NOFILE +- PR#3117: Deprecated hub option DisableGSSAPIProxyDNFallback +- PR#3119: AuthExpire returns code 1 in kojid +- PR#3123: Centralize name/id lookup clauses +- PR#3137: www: rpminfo/fileinfo/imageinfo/archiveinfo page shows human-readable filesize +- PR#3145: Deprecated force option in groupPackageListRemove call +- PR#3146: CLI mock-config: when topdir option, remove topurl value +- PR#3158: Deprecated remove-channel CLI and removeChannel API +- PR#3159: Taginfo page shows packages with/without blocked +- PR#3164: [hub] only raise error when authtype is not proxyauthtype +- PR#3168: protonmsg: allow users to specify router-specific topic prefixes +- PR#3177: Drop RHEL6 references +- PR#3192: Release notes 1.27.1 +- PR#3195: Link to overview video +- PR#3196: hub: default with_blocked=True in listPackages +- PR#3204: lib: refactor variables in is_conn_err() +- PR#3205: Implant releasever into kiwi description +- PR#3206: doc: explain IMA signing vs usual RPM signing +- PR#3211: save modified .kiwi files per arch +- PR#3212: Allow password in SCM url with new builder option +- PR#3214: Add description for permissions +- PR#3215: Show total builds and add two more date options +- PR#3218: doc: additional explanations for RPM signatures +- PR#3223: Provide meaningful message when importing image files fails +- PR#3226: doc: improve multicall documentation + * Tue Dec 21 2021 Tomas Kopecek - 1.27.1-1 - PR#3098: Add all options to hub_conf.rst - PR#3104: Make setup.py executable diff --git a/koji/_version.py b/koji/_version.py index b780b23..055ceff 100644 --- a/koji/_version.py +++ b/koji/_version.py @@ -1,2 +1,2 @@ -__version_info__ = (1, 27, 1) +__version_info__ = (1, 28, 0) __version__ = '.'.join([str(x) for x in __version_info__]) From a9e440e7254386df075823e1efc99be62d86cb30 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Feb 10 2022 14:45:01 +0000 Subject: [PATCH 4/4] fix typo --- diff --git a/docs/source/release_notes/release_notes_1.28.rst b/docs/source/release_notes/release_notes_1.28.rst index 1467241..d467932 100644 --- a/docs/source/release_notes/release_notes_1.28.rst +++ b/docs/source/release_notes/release_notes_1.28.rst @@ -155,7 +155,7 @@ Web | PR: https://pagure.io/koji/pull-request/3215 -Buildsbystatus wep page is showing a bit more information now. +Buildsbystatus web page is showing a bit more information now. Plugins