Skip to content

Commit e9f12d7

Browse files
committed
Fix: Effective value of azul_current_{catalog,source} is not obvious (#7503)
1 parent ea9922b commit e9f12d7

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

scripts/mirror.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,8 @@ def main(args):
7474
parser.add_argument('--catalog',
7575
metavar='NAME',
7676
choices=config.catalogs,
77-
default=config.default_catalog,
7877
help='The name of the catalog to mirror.')
7978
parser.add_argument('--sources',
80-
default=config.current_sources,
8179
nargs='+',
8280
help='Limit mirroring to a subset of the configured sources. '
8381
'Supports shell-style wildcards to match multiple sources per argument. '

scripts/reindex.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,11 @@
5757
parser.add_argument('--catalogs',
5858
nargs='+',
5959
metavar='NAME',
60-
default=[
61-
catalog.name
62-
for catalog in config.catalogs.values()
63-
if not catalog.is_integration_test_catalog
64-
]
65-
if config.current_catalog is None else
66-
[
67-
config.catalogs[config.current_catalog].name
68-
],
6960
choices=config.catalogs,
7061
help='Limit reindexing to a a subset of the configured catalogs. If no values are passed, this '
7162
'argument will be set from the environment variable ``azul_current_catalog``. If that '
7263
'variable is unset, all non-IT catalogs will be used.')
7364
parser.add_argument('--sources',
74-
default=config.current_sources,
7565
nargs='+',
7666
help='Limit reindexing to a subset of the configured sources. '
7767
'Supports shell-style wildcards to match multiple sources per argument. '
@@ -132,7 +122,30 @@ def main(argv: list[str]):
132122

133123
azul = AzulClient(num_workers=args.num_workers)
134124

135-
source_globs = set(args.sources)
125+
if args.catalogs is None:
126+
catalog_origin = 'environment variable'
127+
if config.current_catalog is None:
128+
catalog_origin += ' (unset)'
129+
catalogs = [
130+
catalog.name
131+
for catalog in config.catalogs.values()
132+
if not catalog.is_integration_test_catalog
133+
]
134+
else:
135+
catalogs = [config.catalogs[config.current_catalog].name]
136+
else:
137+
catalog_origin = 'command line argument'
138+
catalogs = args.catalogs
139+
log.info('Using catalog(s) specified via %s: %r', catalog_origin, catalogs)
140+
141+
if args.sources is None:
142+
source_origin = 'environment variable'
143+
source_globs = set(config.current_sources)
144+
else:
145+
source_origin = 'command line argument'
146+
source_globs = set(args.sources)
147+
log.info('Using source glob(s) specified via %s: %r', source_origin, source_globs)
148+
136149
every_source = '*' in source_globs
137150
deindex = args.deindex or (args.delete and not every_source)
138151
delete = args.delete and every_source
@@ -150,15 +163,15 @@ def main(argv: list[str]):
150163
parser.error('--deindex is incompatible with --create and --delete.')
151164
assert False
152165

153-
sources_by_catalog = azul.matching_sources(args.catalogs, source_globs)
166+
sources_by_catalog = azul.matching_sources(catalogs, source_globs)
154167
azul.require_no_failures_before()
155168

156169
if deindex:
157170
for catalog, sources in sources_by_catalog.items():
158171
if sources:
159172
azul.deindex(catalog, sources)
160173

161-
azul.reset_indexer(args.catalogs,
174+
azul.reset_indexer(catalogs,
162175
purge_queues=args.purge,
163176
delete_indices=delete,
164177
create_indices=args.create or args.index and delete)
@@ -186,7 +199,7 @@ def main(argv: list[str]):
186199
if args.wait:
187200
if num_notifications == 0:
188201
log.warning('No notifications for prefix %r and catalogs %r were sent',
189-
args.prefix, args.catalogs)
202+
args.prefix, catalogs)
190203
else:
191204
azul.wait_for_indexer()
192205
azul.require_no_failures_after()

0 commit comments

Comments
 (0)