spacelift-io / spacelift-migration-kit

Helper to move from various tools to Spacelift
MIT License
36 stars 5 forks source link

IndexError: list index out of range for agent pool #50

Closed maddocash closed 1 month ago

maddocash commented 4 months ago

When running the export command I get the IndexError: list index out of range for agent pool error.

I ran the audit command which shows there are no agent pools, so is this a case of a missing check for agent pools when exporting?

spacemk audit 
Agent Pools: 0
...
command output ```zsh ERROR The command failed ╭──────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────────────────╮ │ /spacelift-migration-kit/spacemk/cli.py:76 in app │ │ │ │ 73 │ │ 74 def app(): │ │ 75 │ try: │ │ ❱ 76 │ │ spacemk() │ │ 77 │ except Exception: │ │ 78 │ │ logging.exception("The command failed") │ │ 79 │ │ sys.exit(1) │ │ │ │ /python3.12/site-packages/click/core.py:1157 in __call__ │ │ │ │ 1154 │ │ │ 1155 │ def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Any: │ │ 1156 │ │ """Alias for :meth:`main`.""" │ │ ❱ 1157 │ │ return self.main(*args, **kwargs) │ │ 1158 │ │ 1159 │ │ 1160 class Command(BaseCommand): │ │ │ │ /python3.12/site-packages/click/core.py:1078 in main │ │ │ │ 1075 │ │ try: │ │ 1076 │ │ │ try: │ │ 1077 │ │ │ │ with self.make_context(prog_name, args, **extra) as ctx: │ │ ❱ 1078 │ │ │ │ │ rv = self.invoke(ctx) │ │ 1079 │ │ │ │ │ if not standalone_mode: │ │ 1080 │ │ │ │ │ │ return rv │ │ 1081 │ │ │ │ │ # it's not safe to `ctx.exit(rv)` here! │ │ │ │ /python3.12/site-packages/click/core.py:1688 in invoke │ │ │ │ 1685 │ │ │ │ super().invoke(ctx) │ │ 1686 │ │ │ │ sub_ctx = cmd.make_context(cmd_name, args, parent=ctx) │ │ 1687 │ │ │ │ with sub_ctx: │ │ ❱ 1688 │ │ │ │ │ return _process_result(sub_ctx.command.invoke(sub_ctx)) │ │ 1689 │ │ │ │ 1690 │ │ # In chain mode we create the contexts step by step, but after the │ │ 1691 │ │ # base command has been invoked. Because at that point we do not │ │ │ │ /python3.12/site-packages/click/core.py:1434 in invoke │ │ │ │ 1431 │ │ │ echo(style(message, fg="red"), err=True) │ │ 1432 │ │ │ │ 1433 │ │ if self.callback is not None: │ │ ❱ 1434 │ │ │ return ctx.invoke(self.callback, **ctx.params) │ │ 1435 │ │ │ 1436 │ def shell_complete(self, ctx: Context, incomplete: str) -> t.List["CompletionItem"]: │ │ 1437 │ │ """Return a list of completions for the incomplete value. Looks │ │ │ │ /python3.12/site-packages/click/core.py:783 in invoke │ │ │ │ 780 │ │ │ │ 781 │ │ with augment_usage_errors(__self): │ │ 782 │ │ │ with ctx: │ │ ❱ 783 │ │ │ │ return __callback(*args, **kwargs) │ │ 784 │ │ │ 785 │ def forward( │ │ 786 │ │ __self, __cmd: "Command", *args: t.Any, **kwargs: t.Any # noqa: B902 │ │ │ │ /python3.12/site-packages/click/decorators.py:118 in new_func │ │ │ │ 115 │ │ def new_func(*args: "P.args", **kwargs: "P.kwargs") -> R: │ │ 116 │ │ │ ctx = get_current_context() │ │ 117 │ │ │ obj = ctx.meta[key] │ │ ❱ 118 │ │ │ return ctx.invoke(f, obj, *args, **kwargs) │ │ 119 │ │ │ │ 120 │ │ return update_wrapper(new_func, f) │ │ 121 │ │ │ │ /python3.12/site-packages/click/core.py:783 in invoke │ │ │ │ 780 │ │ │ │ 781 │ │ with augment_usage_errors(__self): │ │ 782 │ │ │ with ctx: │ │ ❱ 783 │ │ │ │ return __callback(*args, **kwargs) │ │ 784 │ │ │ 785 │ def forward( │ │ 786 │ │ __self, __cmd: "Command", *args: t.Any, **kwargs: t.Any # noqa: B902 │ │ │ │ /spacelift-migration-kit/spacemk/commands/export.py:17 in export │ │ │ │ 14 @pass_meta_key("config") │ │ 15 def export(config): │ │ 16 │ exporter = load_exporter(config=config.get("exporter", {})) │ │ ❱ 17 │ exporter.export() │ │ 18 │ │ │ │ /spacelift-migration-kit/spacemk/exporters/base.py:200 in export │ │ │ │ 197 │ │ self._check_requirements(action="export") │ │ 198 │ │ data = self._extract_data() │ │ 199 │ │ data = self._filter_data(data) │ │ ❱ 200 │ │ data = self._enrich_data(data) │ │ 201 │ │ data = self._map_data(data) │ │ 202 │ │ save_normalized_data(data) │ │ 203 │ │ │ │ /spacelift-migration-kit/spacemk/exporters/terraform.py:493 in _enrich_data │ │ │ │ 490 │ │ logging.info("Start enriching data") │ │ 491 │ │ │ │ 492 │ │ self._download_state_files(data) │ │ ❱ 493 │ │ data = self._enrich_workspace_variable_data(data) │ │ 494 │ │ │ │ 495 │ │ logging.info("Stop enriching data") │ │ 496 │ │ │ │ /spacelift-migration-kit/spacemk/exporters/terraform.py:353 in _enrich_workspace_variable_data │ │ │ │ 350 │ │ │ try: │ │ 351 │ │ │ │ logging.info(f"Start local TFC/TFE agent for organization │ │ '{organization_id}'") │ │ 352 │ │ │ │ │ │ ❱ 353 │ │ │ │ agent_pool_id = self._create_agent_pool(organization_id=organization_id) │ │ 354 │ │ │ │ │ │ 355 │ │ │ │ agent_container_name = f"smk-tfc-agent-{organization_id}" │ │ 356 │ │ │ │ agent_container = self._start_agent_container( │ │ │ │ /spacelift-migration-kit/spacemk/exporters/terraform.py:215 in _create_agent_pool │ │ │ │ 212 │ │ │ request_data=agent_pool_request_data, │ │ 213 │ │ ) │ │ 214 │ │ if len(agent_pool_data) == 0: │ │ ❱ 215 │ │ │ agent_pool_id = agent_pool_data[0].get("id") │ │ 216 │ │ │ logging.info(f"Created '{agent_pool_id}' agent pool") │ │ 217 │ │ │ │ 218 │ │ return agent_pool_id │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ IndexError: list index out of range ```
Apollorion commented 3 months ago

Hey @maddocash I believe this has been fixed with the latest version of the migration kit. If youre still attempting this migration, please pull the latest down and give it another try.