Code Migrator
Code Migrator refactors Spark and Airflow source code so that it runs on a target version. It writes each change to a new Git branch and never merges the branch.
Code Migrator changes Spark and Airflow code from a source version to a target version, for example, when a Spark job moves to a newer Spark version during a migration. You can start a Code Migrator job on its own or as part of the Spark migration steps in a workload plan. To start a job on its own, click Code Migrator in the navigation pane to open the Refactor page. Code Migrator is available when Enable LLM is on in the engine configuration of the Cloudera Migration Assistant engine.
How jobs work
For the steps of a refactor job, its work branch, and the migration modes, see Refactoring code with Code Migrator.
Boundaries
Code Migrator works within these boundaries:
- Files – Code Migrator reads and writes files only inside the working directory of the job. It blocks any path that points outside that directory. It does not write to Git metadata or to the configuration files of the build tools, such as .git, .mvn, and Maven settings files.
- Tools – Each agent can use only the tools that it is given. The LLM has no shell access. The build and validation tools run fixed commands. An agent can choose only their arguments, and Code Migrator refuses arguments with special characters and options that change the repository settings of the build tool.
- Build files – Before a build, Code Migrator checks the build files of the project. It refuses a project whose build runs arbitrary commands, such as the Maven exec or antrun plugins, Gradle exec tasks, or sbt process calls, a project with a .mvn directory, and build files larger than 2 MB. It uses the Gradle of the build sandbox, not the Gradle wrapper of the project.
- Build sandbox – Builds, tests, and validation run in a separate pod for each job, under the gVisor container runtime. The pod holds no secrets and no service account token, accepts no incoming connections, and can connect only to DNS and to the network destinations set on the Code Executor Sandbox tab of the Settings page. Code Migrator treats the files that come back from the pod as untrusted. It skips links and protected paths, and limits their size.
- Git – Code Migrator writes only to a new work branch. It never changes the branch or commit that you started from, never merges the work branch, and never pushes to a repository outside the built-in Git server. It checks that it can push to the work branch before it changes any code. It turns off the Git hooks of the repository.
- Secrets in requests – Before each request to the LLM, Code Migrator replaces values that look like secrets with placeholders. The detection is based on patterns, and can miss a secret.
- Iterations – A job runs at most 20 iterations. The limit is fixed. A Code Migrator step in a plan also stops at its total timeout, which you set on the Code Migrator tab of the Settings page.
- Cancel – You can cancel a job at any time. Code Migrator notices the cancel request within about two seconds and stops the job. A build or validation that is running ends immediately, and the job makes no further LLM request, commit, or push. A push or LLM request that is in progress when you cancel completes, but Code Migrator does not use its result.
- Container – Code Migrator runs as a non-root user, with a read-only root filesystem, under the restricted Pod Security Standard of Kubernetes.
- Credentials – Cloudera Migration Assistant stores the LLM API key in a Kubernetes Secret, and never writes it to its database.
- Errors and audit – For authentication, permission, and rate limit errors from the LLM endpoint, the job shows a fixed message, not the response of the provider. Each request to the LLM writes an audit record with the model, the size of the prompt, the outcome, and the job ID, but no prompt text and no code.
Reviewing jobs
To review a job, open it from the Refactor page. You can see each iteration with its build and validation results, the migration plan with before-and-after code, the changes in each iteration, and the conversation history of the agents of the job. If the result is not what you need, you can retry the job with different settings. See Reviewing output on Git branches and Canceling and retrying refactor jobs.
