Skip to content
RED SAGSkills

CI/CD interview questions and answers

CI/CD questions cover how code gets from a commit to production safely and quickly.

Below are 60 CI/CD questions with the correct answer and a short explanation, grouped from fresher to experienced level. Try each one before you open the answer.

What CI/CD interviews usually check

  • ✓Pipelines, stages and artifacts
  • ✓Automated tests and quality gates
  • ✓Deployment strategies: blue-green and canary
  • ✓Secrets in pipelines
  • ✓Rollbacks and release safety

CI/CD interview questions for freshers easy

1. Undoing a bad commit on main

A commit that breaks the build was pushed to the shared main branch an hour ago, and teammates have already pulled it. What is the safest way to undo it?

  1. A.git reset --hard HEAD~1 and then git push --force
  2. B.git revert <commit> and push the new commit
  3. C.Delete main on the remote and push it again
  4. D.git commit --amend and push
Show answer

Answer: B. git revert <commit> and push the new commit

git revert creates a new commit that undoes the changes, so history stays intact and teammates can pull normally. Resetting and force-pushing rewrites shared history and breaks other people's clones. Amending also rewrites the last commit.

2. Turning off a broken feature fast

A new "split bill" feature causes errors in production. The team wants to disable it in seconds without a deploy. What should they have built in?

  1. A.A longer CI pipeline with more tests
  2. B.A separate database for the new feature
  3. C.A feature flag that acts as a kill switch
  4. D.A monthly release schedule
Show answer

Answer: C. A feature flag that acts as a kill switch

A feature flag checked at runtime lets you turn a feature off instantly from a config service, without building or deploying. It is one of the fastest ways to reduce impact during an incident. Testing helps prevent bugs but cannot remove one already live.

3. Why use a canary release

A team sends 5% of traffic to a new version for 30 minutes before a full rollout. What is the main benefit?

  1. A.Problems affect few users and are caught early
  2. B.The new version runs 5% faster for everyone
  3. C.Rollbacks are no longer ever necessary
  4. D.It removes the need for automated tests
Show answer

Answer: A. Problems affect few users and are caught early

A canary exposes a small share of real traffic to the change while you compare its errors and latency with the stable version. If it looks bad, you stop and roll back with limited impact. It complements, not replaces, testing.

4. Undoing a commit already on main

You pushed a bad commit to the shared main branch and teammates have already pulled it. What is the safest way to undo it?

  1. A.git reset --hard HEAD~1 and then git push --force
  2. B.git revert <commit-sha> and push the new commit
  3. C.git commit --amend and push
  4. D.Delete the branch on GitHub and recreate it
Show answer

Answer: B. git revert <commit-sha> and push the new commit

git revert creates a new commit that undoes the changes, so history stays intact and nobody’s local copy breaks. Resetting and force-pushing rewrites shared history and causes problems for everyone who already pulled. Amending also rewrites the last commit, so it has the same problem.

5. Why commit the lockfile

Why should you commit package-lock.json and use npm ci in your CI pipeline?

  1. A.It makes npm download every package from a faster private registry mirror
  2. B.Every machine installs exactly the same dependency versions
  3. C.It upgrades all packages to their latest version
  4. D.It removes the need for package.json
Show answer

Answer: B. Every machine installs exactly the same dependency versions

The lockfile records the exact version of every direct and indirect dependency. npm ci installs exactly that tree and fails if it does not match package.json, so CI, teammates and production build the same thing. Without it, a new minor release of some package can break a build that worked yesterday.

6. Verifying a contract on Etherscan

Why do teams verify their contract source code on a block explorer like Etherscan?

  1. A.So anyone can check that the published source compiles to the exact bytecode deployed at the address
  2. B.Verification makes the contract upgradeable
  3. C.Verification is required before the contract can receive transactions
  4. D.It reduces the gas cost of calling the contract
Show answer

Answer: A. So anyone can check that the published source compiles to the exact bytecode deployed at the address

Verification uploads the source and compiler settings, and the explorer checks they produce the deployed bytecode. Users and auditors can then read the real code and use the explorer's read and write tabs. An unverified contract still works, but it is much harder to trust.

7. Where to try a deployment

You want to try your deployment scripts on a public network without spending real money. What should you use?

  1. A.Ethereum mainnet with a very low gas price
  2. B.A private key with no ETH on mainnet
  3. C.A public testnet such as Sepolia, using free test ETH from a faucet
  4. D.The Etherscan contract simulator
Show answer

Answer: C. A public testnet such as Sepolia, using free test ETH from a faucet

Public testnets like Sepolia behave like mainnet but their ETH has no value and is given out by faucets. They are good for testing deployment scripts, verification and frontend flows. Local nodes like Anvil are faster for unit tests, but a testnet shows real network behaviour.

8. Blue-green deployment

In a blue-green deployment, how is a new version released?

  1. A.The new version is rolled out to 1% of users and slowly increased.
  2. B.Old servers are stopped first, then the new version is installed on them.
  3. C.Each server is updated one at a time while others keep serving traffic.
  4. D.The new version runs in a separate, identical environment, and traffic is switched over all at once; switching back is the rollback.
Show answer

Answer: D. The new version runs in a separate, identical environment, and traffic is switched over all at once; switching back is the rollback.

Blue-green keeps two full environments. The idle one gets the new version and is tested, then the router or load balancer moves all traffic to it. Rollback is fast because the old environment is still running. Gradual percentages describe canary releases, and one-by-one updates describe rolling updates.

9. GitLab CI stages

In this .gitlab-ci.yml, how do the jobs run by default?

stages: [build, test, deploy]

unit:
  stage: test
  script: npm test

lint:
  stage: test
  script: npm run lint

build:
  stage: build
  script: npm run build
  1. A.All three jobs start at the same time, because no needs: keyword is set.
  2. B.build first; then unit and lint in parallel; deploy only after test passes.
  3. C.Jobs run one at a time in the order they appear in the file: unit, lint, build.
  4. D.build runs first; then unit runs, and lint runs only if unit has failed.
Show answer

Answer: B. build first; then unit and lint in parallel; deploy only after test passes.

Stages run in the order listed, and jobs in the same stage run in parallel when runners are available. A stage starts only after all jobs in the previous stage succeed. The needs: keyword can break this ordering into a DAG so a job starts as soon as its own dependencies finish.

10. Parking unfinished changes

You are halfway through a change when an urgent bug needs a fix on the same branch. You do not want to commit the half-done work. Which Git command sets it aside so you can come back to it?

  1. A.git reset --hard
  2. B.git clean -fd
  3. C.git stash
  4. D.git revert HEAD
Show answer

Answer: C. git stash

git stash saves your uncommitted changes and gives you a clean working tree. After the fix, git stash pop brings the changes back. reset --hard and clean -fd would throw the work away.

11. Build once, promote everywhere

Why do good pipelines build the artifact (for example a container image) once and promote the same artifact from staging to production?

  1. A.It lets each environment use a different compiler
  2. B.Rebuilding for production is blocked by registries
  3. C.It removes the need for any tests in staging
  4. D.What you tested is exactly what you ship
Show answer

Answer: D. What you tested is exactly what you ship

Rebuilding for each environment can pull different dependency versions or base images, so production might run code that was never tested. Promoting one immutable artifact, with config supplied per environment, keeps them identical. It also makes builds faster and traceable.

12. Keeping secrets out of CI logs

A job prints its full environment with `env` to debug a failure. The API key appears as *** in GitHub Actions logs. What protects it?

  1. A.The key is encrypted again every time it is printed
  2. B.GitHub deletes the log line after the job finishes
  3. C.The CI masks values of registered secrets in log output
  4. D.env never prints variables that come from secrets
Show answer

Answer: C. The CI masks values of registered secrets in log output

CI systems replace the exact values of stored secrets with *** in logs. Masking only matches the exact string, so encoded or split values can still leak. Avoid printing env or secrets at all.

13. Installing collections in CI

A playbook uses amazon.aws and community.general. How should a CI job install them in a repeatable way?

  1. A.Ansible downloads any missing collection while the play runs
  2. B.ansible-galaxy install -r requirements.yml, versions pinned
  3. C.pip install every collection by name in the job
  4. D.Copy the collections folder from a laptop into the runner
Show answer

Answer: B. ansible-galaxy install -r requirements.yml, versions pinned

List collections and versions in requirements.yml and install with ansible-galaxy collection install -r requirements.yml. Pinning versions avoids surprise breakage. Ansible does not fetch missing collections on its own during a play.

14. Storing a token for a CI workflow

A GitHub Actions workflow needs an API token to deploy. Where should the token live?

  1. A.Committed directly in the workflow YAML file next to the job
  2. B.In the repository README so every teammate can find it
  3. C.As an encrypted repository or environment secret
  4. D.In a public gist that the workflow downloads at runtime
Show answer

Answer: C. As an encrypted repository or environment secret

GitHub Actions secrets are encrypted, masked in logs, and only exposed to workflows that reference them. Environment secrets can also require approvals before a job can read them. Anything committed to the repo or shared publicly should be treated as leaked; for cloud access, OIDC federation is even better than stored tokens.

15. What is a canary release?

What is a canary release?

  1. A.Releasing only on Fridays when traffic is low
  2. B.Running two complete environments and switching all traffic at once
  3. C.Sending a small share of traffic to the new version first and comparing its health before rolling out further
  4. D.Turning off monitoring during a release to avoid noise
Show answer

Answer: C. Sending a small share of traffic to the new version first and comparing its health before rolling out further

A canary exposes a new version to a small slice of real traffic, such as 1% or 5%. If its error rate and latency stay in line with the old version, the rollout continues; if not, only a few users were affected and it is rolled back. Switching all traffic at once is blue-green deployment.

16. Canary deployment

What is a canary deployment of a new model version?

  1. A.Deploying to all users at once at midnight
  2. B.Testing the model only on synthetic data
  3. C.Sending a small share of live traffic to the new version, watching metrics, then increasing gradually
  4. D.Running the old and new model on separate websites
Show answer

Answer: C. Sending a small share of live traffic to the new version, watching metrics, then increasing gradually

A canary exposes only a small percentage of traffic to the new version first. If latency, errors and model metrics look healthy, traffic increases step by step; if not, you roll back quickly with limited user impact.

17. Champion and challenger

In a champion/challenger setup, what is the challenger?

  1. A.The model that currently serves all of the users
  2. B.A rule that rejects every risky incoming request
  3. C.A candidate model compared with the live one on real data
  4. D.The person who signs off on each model release
Show answer

Answer: C. A candidate model compared with the live one on real data

The champion is the current production model. Challengers are candidate models that receive a share of traffic or shadow traffic so their results can be compared fairly. A challenger replaces the champion only when it is clearly better.

18. Why blue-green suits model releases

What is the main advantage of a blue-green deployment for a model service?

  1. A.Only half the users ever see the new model
  2. B.It needs no extra servers at any time
  3. C.Traffic switches at once and can switch back fast
  4. D.It trains the model while serving it
Show answer

Answer: C. Traffic switches at once and can switch back fast

Blue-green runs the old and new versions side by side and flips the router from one to the other. If the new one misbehaves, you flip back in seconds. The cost is running two full environments during the switch.

19. Passwords in test code

Where should the password for a test account used in CI be stored?

  1. A.Hard-coded in the test file so it is easy to find
  2. B.In a comment at the top of the repository README
  3. C.In a public Slack channel
  4. D.In the CI secret store, read by the tests as an environment variable
Show answer

Answer: D. In the CI secret store, read by the tests as an environment variable

Secrets in source code leak through git history, forks and logs. CI systems like GitHub Actions and Jenkins store secrets encrypted and mask them in logs. Locally, use an untracked .env file.

20. Triggering a workflow

In this GitHub Actions workflow, when do the tests run?

on:
  pull_request:
    branches: [main]
  push:
    branches: [main]
  1. A.Only when someone runs them by hand
  2. B.Every hour on a schedule
  3. C.Only when a tag is created
  4. D.On pull requests that target main and on every push to main
Show answer

Answer: D. On pull requests that target main and on every push to main

The on key defines triggers. Here the workflow runs for pull requests into main and for pushes to main, such as merges. Scheduled runs would use schedule with a cron expression.

CI/CD intermediate interview questions medium

21. Errors during every deploy

During each rolling deploy on Kubernetes, clients see a burst of 502 errors as old pods stop. What should the app do when it receives SIGTERM?

  1. A.Call process.exit(0) right away, since Kubernetes already moved all traffic to the new pod before sending the signal
  2. B.Ignore SIGTERM so the pod is never stopped
  3. C.Stop taking new connections, finish in-flight requests, close the DB pool, then exit
  4. D.Restart itself in the same container
Show answer

Answer: C. Stop taking new connections, finish in-flight requests, close the DB pool, then exit

Graceful shutdown drains work instead of cutting connections mid-request. Kubernetes sends SIGTERM, waits terminationGracePeriodSeconds, then sends SIGKILL, so the drain must fit in that window. Failing the readiness probe first, or a short preStop delay, gives the load balancer time to stop routing to the pod.

22. Steps git bisect needs

A bug appeared somewhere in the last 1,000 commits. About how many builds do you need to test with git bisect to find the first bad commit?

  1. A.100
  2. B.10
  3. C.500
  4. D.32
Show answer

Answer: B. 10

git bisect is binary search over history: each test halves the suspect commits. 2^10 = 1,024, so about 10 tests are enough. Automating it with git bisect run and a test script makes this fast.

23. Contract too large to deploy

Deployment fails because the runtime bytecode is 27 KB. What limit was hit, and what is a common fix?

  1. A.The 24 KB (24,576 byte) code limit; split into libraries
  2. B.The 64 KB calldata limit; send less constructor data
  3. C.The block gas limit; deploy at a quieter time
  4. D.The 32 KB stack limit; use fewer local variables
Show answer

Answer: A. The 24 KB (24,576 byte) code limit; split into libraries

EIP-170 caps deployed contract code at 24,576 bytes. Fixes include moving logic into external libraries or separate contracts, removing unused code, using custom errors instead of long revert strings, and turning on the optimizer (with a low runs value favouring size).

24. Two pipelines for every push

After adding merge request pipelines, every push to a branch with an open MR starts two pipelines. How do you fix this cleanly in GitLab CI?

  1. A.Disable shared runners for the project so that only one of the two pipelines can start at a time.
  2. B.Add when: manual to every job so the second pipeline waits for a click.
  3. C.Remove the stages: list so that each job runs only once per push event.
  4. D.Add workflow: rules to run MR pipelines and skip branch ones when an MR is open.
Show answer

Answer: D. Add workflow: rules to run MR pipelines and skip branch ones when an MR is open.

A branch pipeline and a merge request pipeline are separate pipeline sources. Top-level workflow: rules decide whether a pipeline is created at all; a common pattern runs on merge_request_event, skips push pipelines when CI_OPEN_MERGE_REQUESTS is set, and still runs on the default branch and tags. GitLab provides a template (Workflows/MergeRequest-Pipelines) for this.

25. Approval before production deploy

Compliance wants a named lead to approve every production deploy, while staging deploys run automatically. How is this usually set up in GitHub Actions?

  1. A.A comment in the workflow file asking for approval
  2. B.A separate repository just for the production code
  3. C.Manual edits to the workflow file before each release
  4. D.A production environment with required reviewers
Show answer

Answer: D. A production environment with required reviewers

Jobs that reference an environment wait for its protection rules, such as required reviewers or a wait timer, before they start. Environments can also hold their own secrets and limit which branches may deploy. GitLab offers similar protected environments with approvals.

26. Sharing one pipeline across 30 repos

Thirty service repos copy the same build-and-scan workflow, and fixing it means 30 PRs. Which GitHub Actions feature lets them all call one central definition?

  1. A.A repository_dispatch event from each repo
  2. B.A shared self-hosted runner for all repos
  3. C.A reusable workflow triggered by workflow_call
  4. D.A cron schedule in a central repo
Show answer

Answer: C. A reusable workflow triggered by workflow_call

A workflow with on: workflow_call can be used by other workflows with uses: org/repo/.github/workflows/build.yml@v3. Inputs and secrets are passed in, and versioning the reference lets teams upgrade on their own schedule. Composite actions are another option for sharing steps.

27. git describe fails in CI

A build step uses `git describe --tags` to make the version. It works locally but fails in CI with "No names found". The checkout step uses default settings. What is the likely fix?

  1. A.Run git init again before the build step
  2. B.Tag the commit again inside the CI job
  3. C.Use a larger runner with more disk
  4. D.Fetch full history and tags, e.g. fetch-depth: 0
Show answer

Answer: D. Fetch full history and tags, e.g. fetch-depth: 0

CI checkouts often fetch only the last commit (actions/checkout defaults to depth 1) and no tags, so git describe finds nothing. Setting fetch-depth: 0 fetches all history and tags. Fetching just the tags is a lighter option for big repos.

28. When rolling updates are unsafe

A legacy app holds an exclusive lock on a file share, so two versions cannot run at the same time. Which deployment strategy fits, and what is its cost?

  1. A.Rolling update with maxSurge 50% and no downtime
  2. B.Canary with 10% of traffic on the new version
  3. C.Recreate: stop all old Pods first, accepting short downtime
  4. D.Blue-green with both versions serving traffic
Show answer

Answer: C. Recreate: stop all old Pods first, accepting short downtime

Rolling, canary and blue-green all have old and new versions running together for a while. Recreate stops every old instance before starting new ones, so they never overlap, at the price of a gap in service. Plan it for a low-traffic window, or remove the exclusivity to allow safer strategies.

29. Builds pass or fail by runner

On persistent self-hosted runners, some builds pass only because files left by earlier jobs are still on disk. What is the best long-term fix?

  1. A.Use ephemeral runners that start clean for each job
  2. B.Run a cleanup script once a week on each runner
  3. C.Pin each repo to one specific runner machine
  4. D.Disable caching in all workflows
Show answer

Answer: A. Use ephemeral runners that start clean for each job

Long-lived runners collect leftover files, tools and env changes, which hide missing steps and leak data between jobs. Ephemeral runners (one VM or container per job, then destroyed) make every build start the same. They are also safer, since one job cannot tamper with the next.

30. Secret leaked despite masking

A CI log shows a base64 string that decodes to your API token, though the raw token is masked as ***. What happened, and what is the lesson?

  1. A.The masking feature is off by default on all CI systems
  2. B.Masking matches only exact values; never print secrets in any form
  3. C.Base64 is a form of encryption, so this is safe
  4. D.The token must be shorter than 8 characters to be masked
Show answer

Answer: B. Masking matches only exact values; never print secrets in any form

Log masking replaces the exact secret string, so encoded, split or transformed versions are not hidden. Base64 is reversible, so the token is exposed. Treat masking as a safety net, avoid echoing secrets or debug env dumps, and rotate any secret that appears.

31. A sensible image scan gate

You want the pipeline to block risky images without stopping all work over CVEs nobody can fix yet. Which gate is common and practical?

  1. A.Fail the build on any CVE of any severity at all
  2. B.Never fail; only email a scan report once each month
  3. C.Fail only if the final image is larger than 500 MB
  4. D.Fail on Critical or High findings that have a fix available
Show answer

Answer: D. Fail on Critical or High findings that have a fix available

Blocking on fixable high-severity issues forces quick wins, since the fix is a version bump or rebuild. Failing on every CVE, including unfixed lows, blocks delivery and trains people to bypass the gate. Track unfixed findings separately with deadlines and exceptions.

32. What a signed commit proves

Your repo requires signed commits. A reviewer says "all commits are signed, so the code is safe". What do signatures actually show?

  1. A.That the code has passed a full security review
  2. B.That none of its dependencies have known CVEs
  3. C.That a trusted key holder made it and it was not altered
  4. D.That the commit was built and fully tested in CI
Show answer

Answer: C. That a trusted key holder made it and it was not altered

A commit signature links the commit to a key, showing who created it and that it was not altered after signing. It says nothing about whether the change is good or secure. A stolen key or a careless author still produces valid signatures, so review and testing stay necessary.

33. Applying exactly what was reviewed

In CI you want the apply step to do exactly what reviewers saw in the plan step. What is the right approach?

  1. A.Run terraform plan, then terraform apply -auto-approve
  2. B.Run terraform plan -out=tfplan, then terraform apply tfplan
  3. C.Run terraform plan twice and compare the text
  4. D.Run terraform apply -refresh=false after the plan
Show answer

Answer: B. Run terraform plan -out=tfplan, then terraform apply tfplan

A saved plan file fixes the exact set of actions, and apply tfplan runs only those. If the state changed since the plan, Terraform refuses the stale plan instead of doing something new. A plain apply re-plans, so it may include changes nobody reviewed.

34. Overly broad GitHub OIDC trust policy

A production deploy role trusts GitHub Actions OIDC with the condition below. What is the problem?

"Condition": {
  "StringEquals": { "token.actions.githubusercontent.com:aud": "sts.amazonaws.com" },
  "StringLike":   { "token.actions.githubusercontent.com:sub": "repo:acme/*" }
}
  1. A.OIDC tokens cannot be used with AssumeRoleWithWebIdentity
  2. B.The audience value must be placed inside the sub claim
  3. C.Any branch of any repo in the acme org can assume the prod role
  4. D.The wildcard makes the role impossible to assume
Show answer

Answer: C. Any branch of any repo in the acme org can assume the prod role

The sub claim identifies the repo and the ref or environment that the workflow runs for. A repo:acme/* pattern lets any workflow in the org, including a feature branch, take the prod role. Scope it to something like repo:acme/api:environment:production, and protect that environment with required reviewers.

35. Releasing to 5 percent of traffic first

You want a risky change to receive 5 percent of traffic first, watch error rates, and then expand step by step. Which deployment strategy is this?

  1. A.Blue-green with an instant full cutover
  2. B.Recreate deployment
  3. C.Canary deployment
  4. D.Big-bang release
Show answer

Answer: C. Canary deployment

A canary sends a small share of traffic to the new version and increases it only while metrics stay healthy, with automatic rollback if they do not. Blue-green switches all traffic at once between two full environments. Recreate and big-bang releases have no gradual exposure.

36. Secrets stolen through a pull request

A GitHub Actions workflow uses pull_request_target and checks out the PR's code, then runs its tests. An outsider opened a PR and your cloud secrets were used from an unknown IP. What went wrong?

  1. A.GitHub publishes all secrets in public repositories by design
  2. B.Untrusted PR code ran with access to repository secrets
  3. C.The outsider guessed the secrets by brute force over the API
  4. D.pull_request_target workflows cannot read secrets at all
Show answer

Answer: B. Untrusted PR code ran with access to repository secrets

pull_request_target runs in the context of the base repo, with secrets available. Checking out and running the PR's code lets an attacker's script read those secrets. Rotate all exposed secrets, review cloud logs, and use pull_request for untrusted code or require approval.

37. Shadow deployment

What does a shadow deployment of a new model do?

  1. A.It replaces the old model for half of users
  2. B.It deploys the model only in a test environment with fake data
  3. C.It hides the model from monitoring tools
  4. D.It sends a copy of live requests to the new model and logs its predictions, while users still get responses from the current model
Show answer

Answer: D. It sends a copy of live requests to the new model and logs its predictions, while users still get responses from the current model

Shadow mode tests the new model on real traffic with zero user impact. You can compare predictions, latency and errors with the current model before any user sees the new results. It cannot measure user behaviour changes, which still need an A/B test.

38. Deploying by alias, not version

Your serving config points to a model registry alias such as "champion" instead of a fixed version number. What does this enable?

  1. A.The model trains itself automatically
  2. B.Every registered version is served at once
  3. C.Promotion and rollback by moving the alias, with a clear record of which version it pointed to
  4. D.The registry skips storing older versions
Show answer

Answer: C. Promotion and rollback by moving the alias, with a clear record of which version it pointed to

An alias is a movable pointer to one version. Promoting a model means moving the alias after checks pass, and rolling back means moving it back. Serving reads the alias but should log the resolved version so every prediction can be traced.

39. p99 doubled right after a release

Ten minutes after a new model version rolled out to all traffic, p99 latency doubled and errors are rising. Traffic is normal. What should you do first?

  1. A.Start profiling the new model in production
  2. B.Roll back to the previous version, then investigate
  3. C.Add more replicas and wait
  4. D.Disable the latency alert
Show answer

Answer: B. Roll back to the previous version, then investigate

When a change clearly lines up with user impact, restore service first by rolling back, then find the cause safely. Adding replicas may hide the issue but costs money and may not help if the new model is simply slower. Afterwards, add latency checks to the canary stage so it is caught earlier.

40. A matrix build

How many jobs does this GitHub Actions configuration start?

strategy:
  matrix:
    browser: [chromium, firefox, webkit]
    shard: [1, 2]
  1. A.6
  2. B.2
  3. C.3
  4. D.5
Show answer

Answer: A. 6

A matrix creates one job for each combination: 3 browsers times 2 shards is 6 jobs running in parallel. Use fail-fast: false if you want all combinations to finish even after one fails.

CI/CD interview questions for experienced candidates hard

41. Migrations run on every pod start

Each of 10 app pods runs database migrations when it starts. During deploys, migrations sometimes fail with lock errors or run twice. What is the better setup?

  1. A.Run migrations once as a separate deploy step or job
  2. B.Add random delays to pod start-up
  3. C.Run migrations only on pods with an even number
  4. D.Disable transactions in all migrations
Show answer

Answer: A. Run migrations once as a separate deploy step or job

Starting several pods at once makes them race to apply the same migrations. Run migrations once, from a CI step or a Kubernetes Job, before the new app version starts. Tools that take an advisory lock help, but a single step is clearer.

42. Sending funds to a missing contract

A team sent tokens on an L2 to the address of their Safe from Ethereum mainnet, but that Safe had not been deployed on the L2. What risk did this create?

  1. A.The tokens go back to the sender automatically
  2. B.The L2 bridge forwards them to mainnet
  3. C.Someone else may be able to deploy code at that address
  4. D.Nothing, since addresses are the same on all chains
Show answer

Answer: C. Someone else may be able to deploy code at that address

A contract address depends on how it was created (deployer and nonce, or CREATE2 inputs). On another chain those may be controlled by someone else, who can deploy different code at that address and take the funds. This happened to a market maker on Optimism in 2022. Deploy first, or confirm the address can be recreated.

43. A factory with a huge init code

Since the Shanghai upgrade, what limit applies to the init code used for contract creation?

  1. A.24,576 bytes, the same as runtime code
  2. B.No limit, only gas limits apply
  3. C.65,536 bytes, the size of a memory page
  4. D.49,152 bytes, twice the runtime limit
Show answer

Answer: D. 49,152 bytes, twice the runtime limit

EIP-3860 limits init code to 49,152 bytes (2 x 24,576) and charges 2 gas per 32-byte word of it. Creation with larger init code fails. This matters for factories that embed large contracts or constructor data.

44. Libraries that must be linked

A library has public functions. A contract that uses them fails to deploy with "unlinked library" placeholders in the bytecode. Why?

  1. A.Libraries can only contain internal functions, not public ones
  2. B.The library must be inherited by the contract, not imported
  3. C.Public functions run via DELEGATECALL to a deployed library
  4. D.Public library functions need the payable keyword
Show answer

Answer: C. Public functions run via DELEGATECALL to a deployed library

Internal library functions are copied into the calling contract. Public or external ones stay in the library, which must be deployed first, and its address is linked into the caller's bytecode. This is a way to get around the contract size limit, at the cost of extra calls.

45. Renaming a column with zero downtime

You run rolling deployments, so old and new app versions run side by side for a while. You need to rename users.fullname to users.display_name. Which approach avoids errors?

  1. A.Expand and contract: add display_name, deploy code that writes both and reads the new column, backfill data, switch all reads, then drop fullname in a later release.
  2. B.Run ALTER TABLE ... RENAME COLUMN in the same release as the code change.
  3. C.Rename the column first, then deploy the new code as fast as possible.
  4. D.Take the database offline for a short maintenance window; zero downtime is not possible.
Show answer

Answer: A. Expand and contract: add display_name, deploy code that writes both and reads the new column, backfill data, switch all reads, then drop fullname in a later release.

During a rolling deploy both versions query the database, so a single rename breaks whichever version expects the other name. The expand and contract pattern keeps the schema compatible with both versions at every step. The old column is removed only after no running code uses it.

46. Secrets in a GitOps repo

Your team uses Argo CD and wants everything in Git, including database credentials. Which approach keeps GitOps without storing plaintext secrets in Git?

  1. A.Commit ExternalSecret references synced from a secret manager, or encrypted values with Sealed Secrets or SOPS.
  2. B.Commit plain Kubernetes Secret YAML to a private repo, since only the team can read a private repo.
  3. C.Base64 encode every value twice before committing, so nobody browsing the repo can read them.
  4. D.Keep secrets only as Argo CD UI parameter overrides, which are never saved anywhere outside the UI.
Show answer

Answer: A. Commit ExternalSecret references synced from a secret manager, or encrypted values with Sealed Secrets or SOPS.

GitOps wants the desired state in Git, but secret values do not need to be there in plaintext. ExternalSecret manifests describe where to fetch a secret, and the operator creates the Kubernetes Secret in-cluster, which also eases rotation. Sealed Secrets and SOPS store encrypted data that only the cluster or holders of the key can decrypt. Private repos still leak via clones, forks and CI logs.

47. Recovering after a bad force push

You ran `git reset --hard HEAD~3` on your feature branch by mistake and then force-pushed. The 3 commits are gone from the remote branch. How can you get them back from your own machine?

  1. A.Run git revert HEAD~3 to restore the deleted commits
  2. B.Find the old commit in git reflog, reset to it, and push again
  3. C.Run git fetch, as the remote keeps every forced commit
  4. D.They are lost; Git deletes them at the force push
Show answer

Answer: B. Find the old commit in git reflog, reset to it, and push again

The reflog records where HEAD and branches pointed, so the old tip is still listed, for example as HEAD@{1}. git reset --hard to that commit, then force-push again (prefer --force-with-lease). Unreachable commits stay until garbage collection, usually weeks later.

48. Security gain of pull-based GitOps

Your CI currently holds a kubeconfig with admin rights to run kubectl apply on production. You move to Argo CD or Flux, which run in the cluster. What is the main security gain?

  1. A.Git no longer needs any access control
  2. B.Container images no longer need to be signed
  3. C.CI no longer needs credentials to the production cluster
  4. D.Developers can push straight to main safely
Show answer

Answer: C. CI no longer needs credentials to the production cluster

With pull-based GitOps, an agent inside the cluster watches Git and applies changes, so the CI system only needs to update Git or push images. A leaked CI secret then cannot change the cluster directly. Git access control and review now guard production, so they matter even more.

49. Migrations run by every replica

An app runs DB migrations at startup. With 6 replicas rolling out, several Pods run the same migration at once and some crash with lock errors. What is the better design?

  1. A.Run migrations once as a separate job before the rollout
  2. B.Raise the replica count so failures average out
  3. C.Add retries so each Pod tries the migration 10 times
  4. D.Start the Pods one at a time with maxSurge: 0
Show answer

Answer: A. Run migrations once as a separate job before the rollout

Migrations should run once per release, not once per Pod. A pipeline step, a Kubernetes Job, or a pre-deploy hook can run them before the app rolls out, with a database lock as a safety net. The migration should also be backward compatible so old Pods keep working.

50. Self-hosted runners on a public repo

An open-source project uses a self-hosted runner inside the company network for faster builds, and runs CI on pull requests from forks. What is the risk?

  1. A.Anyone can open a PR that runs code inside your network
  2. B.Forks cannot trigger workflows on self-hosted runners
  3. C.The runner leaks its CPU model in the logs
  4. D.Public repos cannot use self-hosted runners at all
Show answer

Answer: A. Anyone can open a PR that runs code inside your network

A pull request can change the workflow or test code, so an outsider gets to run anything on that machine, reach internal systems and leave malware behind for later jobs. GitHub advises against self-hosted runners for public repos. Use hosted or isolated ephemeral runners, and require approval for outside contributors.

51. Where to run an active DAST scan

You want an active DAST scan (it submits forms and attack payloads) on every release candidate. Where should it run?

  1. A.Against production during business hours
  2. B.Against a developer laptop over the office Wi-Fi
  3. C.Against a short-lived test environment with test data
  4. D.Against the vendor's public demo site
Show answer

Answer: C. Against a short-lived test environment with test data

Active scans create records, send emails and can trip rate limits or corrupt data, so running them on production is risky. A preview or staging environment built from the same artifact, with fake data, gives realistic results safely. Light passive checks can still run against production.

52. Stopping exfiltration from runners

A malicious dependency running in a build tries to send CI secrets to an attacker's server. Which control on the runners blocks this even if the code runs?

  1. A.A bigger runner VM with more memory and CPU cores
  2. B.Egress rules that allow only known hosts such as registries
  3. C.Running builds only at night when traffic is low
  4. D.A longer build timeout set for each pipeline job
Show answer

Answer: B. Egress rules that allow only known hosts such as registries

Most builds only need to reach package registries, source control and your artifact store. An egress allow-list (firewall, proxy or a tool like Harden-Runner) blocks calls to unknown hosts, so stolen secrets cannot easily leave. It also gives logs of unexpected outbound calls.

53. New instances take 12 minutes to serve

Scaling out is too slow: each new instance runs a user-data script that installs packages and builds the app, taking 12 minutes. What is the most effective fix?

  1. A.Increase the scaling cooldown period
  2. B.Bake a pre-built image so instances start ready
  3. C.Use a larger load balancer
  4. D.Run the script twice in parallel
Show answer

Answer: B. Bake a pre-built image so instances start ready

Building at boot makes scale-out slow and fragile, since package mirrors can fail. Baking a golden image (with Packer or EC2 Image Builder) or using containers means instances only need to start the app. Warm pools also help.

54. Where generation time goes

A request has a 6,000-token prompt and an 800-token answer, and total latency is too high. Which statement about prefill and decode is correct?

  1. A.Prefill handles one prompt token at a time, so prompt length dominates total time
  2. B.Decode is compute-bound, so a faster GPU core clock is the main fix
  3. C.Both phases cost the same per token, so cut whichever is longer
  4. D.Prefill processes the prompt in parallel; decode emits tokens one by one, so the long answer usually dominates
Show answer

Answer: D. Prefill processes the prompt in parallel; decode emits tokens one by one, so the long answer usually dominates

Prefill runs all prompt tokens through the model in parallel and is compute-bound, so it is fast per token. Decode produces one token per forward pass and is limited by memory bandwidth, so each output token is far more expensive in time. Shorter outputs, streaming and speculative decoding attack the decode cost.

55. Shadow model sent real emails

A shadow deployment of a new churn model also triggered retention emails to customers, duplicating those from the live model. What went wrong?

  1. A.Shadow deployments always send output to users
  2. B.The shadow model was too accurate
  3. C.The canary percentage was too high
  4. D.The shadow path was not isolated from side effects; it should only log predictions, with writes and actions stubbed out
Show answer

Answer: D. The shadow path was not isolated from side effects; it should only log predictions, with writes and actions stubbed out

Shadow mode is meant to be invisible: it receives copies of traffic and its outputs are compared offline. Any downstream action, such as writing to a database, calling a payment API or sending messages, must be disabled or redirected. Shared code paths make this easy to miss, so test the shadow setup explicitly.

56. Canary that cannot catch quality drops

Your canary sends 1% of traffic to a new model for 30 minutes and checks conversion rate. A model that lowered conversion by 3% passed. Why?

  1. A.Canaries should use 0% of traffic
  2. B.Conversion rate cannot be measured
  3. C.At that traffic and duration the canary has far too little statistical power to detect a 3% change
  4. D.The model was rolled back too early
Show answer

Answer: C. At that traffic and duration the canary has far too little statistical power to detect a 3% change

A few thousand requests cannot reliably show a small change in a noisy business metric. Short canaries are good at catching crashes, errors and latency regressions. Quality changes need a longer, larger, properly powered A/B test, or offline and shadow evaluation before rollout.

57. Canary looked perfect

A canary served 500 requests with 0 errors, and the team promoted it. At full traffic the error rate was 0.5%. Was the canary result surprising?

  1. A.Yes; 500 requests should show at least 25 errors
  2. B.No; with 500 requests, 0 errors is quite likely even at 0.5%
  3. C.Yes; a 0.5% error rate always shows in 100 requests
  4. D.No; canaries cannot measure error rates
Show answer

Answer: B. No; with 500 requests, 0 errors is quite likely even at 0.5%

At 0.5%, expected errors in 500 requests is 2.5, and P(0 errors) ≈ e^−2.5 ≈ 8%. Small canaries can miss low-rate problems. Size canaries for the effect you need to catch, or keep them running longer.

58. Passed on retry

CI is set to retry failed tests twice. A checkout test fails about 1 run in 15 but always passes on retry, so the pipeline is green. What should a senior QA do?

  1. A.Nothing, because the pipeline is green
  2. B.Raise retries to five to be safe
  3. C.Delete the test because it is unreliable
  4. D.Treat "passed on retry" as a signal: track flaky rates, investigate with traces, and check whether the product itself has an intermittent bug such as a race condition
Show answer

Answer: D. Treat "passed on retry" as a signal: track flaky rates, investigate with traces, and check whether the product itself has an intermittent bug such as a race condition

Retries keep the pipeline moving, but a test that fails intermittently may be revealing an intermittent product defect that customers will also hit. Playwright marks such tests as flaky in its report; review those trends, attach traces and decide whether to fix the test or the code. Never let retries silently hide failures.

59. Feature flags and tests

Product turns feature flags on and off in the test environment, and your tests fail depending on the current flag values. What is the best practice?

  1. A.Only test with all flags off
  2. B.Tests set the flag values they need explicitly, for example through a test override or targeting a test user, and critical flags are tested in both states
  3. C.Remove feature flags from the product
  4. D.Ask product never to change flags
Show answer

Answer: B. Tests set the flag values they need explicitly, for example through a test override or targeting a test user, and critical flags are tested in both states

A test must control its inputs, and flags are inputs. Per-test or per-user overrides make results deterministic, and testing both sides of risky flags protects the rollout and the rollback.

60. Ordering pipeline stages

Which pipeline order gives the fastest useful feedback for a web app?

  1. A.E2E tests, then unit tests, then lint
  2. B.Deploy to production, then run all tests
  3. C.Lint and type check, unit tests, API and component tests, then deploy to a preview environment and run a focused E2E suite
  4. D.Run all stages in one job one after another, regardless of failures
Show answer

Answer: C. Lint and type check, unit tests, API and component tests, then deploy to a preview environment and run a focused E2E suite

Cheap, fast checks run first so most mistakes fail within minutes. Expensive E2E tests run later against a real deployed preview. Independent stages can also run in parallel to cut total time.

Ready to test yourself?

Take a 15-question CI/CD MCQ test with a score at the end, or practise the full CI/CD question bank and earn points on the leaderboard.