Skip to content

Commit

Permalink
Implement strict mode checkbox for sync runs.
Browse files Browse the repository at this point in the history
see: SUSE/spacewalk#22420

This PR includes:

1. Added no-strict parameter handling in SyncRepositoriesAction.java, RepoSyncTask.java, and spacewalk-repo-sync.
2. Introduced a checkbox in syncrepos.jsp for user control, with accompanying text in StringResource_en_US.xml.
3. Adjusted RepoSync class in reposync.py to process the new parameter.

Tested the functionality to ensure correct flag passing and expected behavior on toggling strict mode from the frontend.
  • Loading branch information
r-richardson committed Oct 18, 2023
1 parent 4da0ed2 commit 0aaf18a
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public ActionForward execute(ActionMapping mapping,

try {
Map<String, String> mparams = new HashMap<>();
String [] lparams = {"no-errata", "latest", "sync-kickstart", "fail"};
String [] lparams = {"no-errata", "latest", "sync-kickstart", "fail", "no-strict"};

for (String p : lparams) {
if (request.getParameter(p) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23549,6 +23549,12 @@ given channel.</source>
<context context-type="sourcefile">/rhn/channels/manage/Sync.do</context>
</context-group>
</trans-unit>
<trans-unit id="channel.manage.sync.nostrict.jsp" xml:space="preserve">
<source>Do not use strict mode</source>
<context-group name="ctx">
<context context-type="sourcefile">/rhn/channels/manage/Sync.do</context>
</context-group>
</trans-unit>
<trans-unit id="channel.manage.sync.latestonly.jsp" xml:space="preserve">
<source>Sync only latest packages</source>
<context-group name="ctx">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void execute(JobExecutionContext context) throws JobExecutionException {
final JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
final List<Long> channelIds = getChannelIds(jobDataMap);

List<String> lparams = List.of("no-errata", "latest", "sync-kickstart", "fail");
List<String> lparams = List.of("no-errata", "latest", "sync-kickstart", "fail", "no-strict");
List<String> ltrue = List.of("true", "1");
List<String> params = new ArrayList<>();
for (String p : lparams) {
Expand Down
12 changes: 8 additions & 4 deletions java/code/webapp/WEB-INF/pages/channel/manage/syncrepos.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@

</rl:list>

<div class="checkbox">
<label>
<input type="checkbox" name="no-strict" id="no-strict"/>
<bean:message key="channel.manage.sync.nostrict.jsp"/>
</label>
</div>

<div class="checkbox">
<label>
<input type="checkbox" name="no-errata" id="no-errata"/>
Expand Down Expand Up @@ -107,12 +114,10 @@
</div>

<br/>

<c:if test='${scheduleEditable}'>
<jsp:include page="/WEB-INF/pages/common/fragments/repeat-task-picker.jspf">
<jsp:param name="widget" value="date"/>
</jsp:include>

<div class="text-right">
<button type="submit" value="<bean:message key='schedule.button'/>" class="btn btn-default"
name="dispatch" ${inactive ? 'disabled' : ''}>
Expand All @@ -121,7 +126,7 @@
</button>
</div>
</c:if>

<c:if test='${not scheduleEditable}'>
<div class="panel panel-default">
<div class="panel-heading">
Expand All @@ -134,7 +139,6 @@
</div>
</c:if>


</rl:listset>

</body>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add no-strict checkbox to manage channel sync page
2 changes: 1 addition & 1 deletion python/spacewalk/satellite_tools/reposync.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ class RepoSync(object):

def __init__(self, channel_label, repo_type=None, url=None, fail=False,
filters=None, no_errata=False, sync_kickstart=False, latest=False,
metadata_only=False, strict=0, excluded_urls=None, no_packages=False,
metadata_only=False, strict=False, excluded_urls=None, no_packages=False,
log_dir="reposync", log_level=None, force_kickstart=False, force_all_errata=False,
check_ssl_dates=True, force_null_org_content=False, show_packages_only=False,
noninteractive=False, deep_verify=False):
Expand Down
4 changes: 3 additions & 1 deletion python/spacewalk/satellite_tools/spacewalk-repo-sync
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def main():
callback=reposync.set_filter_opt,
type='str', nargs=1, dest='filters', default=[],
help="Comma or space separated list of excluded packages or package groups.")
parser.add_option('', '--no-strict', action='store_true',help="do not unlink packages when deleted from repository", dest='no_strict')
parser.add_option('', '--email', action="store_true", help="e-mail a report of what was synced/imported")
parser.add_option('', '--traceback-mail', action="store",
help="alternative email address(es) for sync output (--email option)")
Expand Down Expand Up @@ -143,7 +144,7 @@ def main():
rhnLog.initLOG(log_path, log_level)
log2disk(0, "Command: %s" % str(sys.argv))

l_params=["no_errata", "sync_kickstart", "fail"]
l_params=["no_errata", "sync_kickstart", "fail", "no-strict"]
d_chan_repo=reposync.getChannelRepo()
l_ch_custom=reposync.getCustomChannels()
d_parent_child=reposync.getParentsChilds()
Expand Down Expand Up @@ -256,6 +257,7 @@ def main():
repo_type=options.repo_type,
url=repo,
fail=options.fail,
strict= not options.no_strict,
noninteractive=options.noninteractive,
filters=options.filters,
deep_verify=options.deep_verify,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Implement no-strict option:
* Make strict=false the default in reposync.py
* Add no-script parameter handling to spacewalk-repo-sync

0 comments on commit 0aaf18a

Please sign in to comment.