Skip to content

[Problem RFC] Missing imagePullSecret Dependency Fault #852

Closed

Description

@W-OK-E

Hello everyone,

I am submitting this RFC as part of the UIUC++ SRSE evaluation task for a new SREGym benchmark problem.

Proposal: Injecting Missing imagePullSecret Dependency Fault

I propose adding a new standalone object-layer authentication fault: Missing or Invalid imagePullSecret. The inspiration for this issue comes from SREGym Issue #201 and is modeled after the cluster troubleshooting signals introduced in Kubernetes PR #117927. This PR updated the Kubelet to emit an explicit warning event (FailedToRetrieveImagePullSecret) when a referenced secret cannot be found—providing a clear object-layer signature that agents can leverage to diagnose underlying registry authentication issues.


Why This is a Great Fit for SREGym

  • Addresses an Explicit Gap: Gap analysis actively tracks imagePullSecret missing as an open fault class with zero current registry coverage.
  • Distinct Fault DNA: The benchmark already includes image rollout faults like incorrect_image. However, this new fault features a completely valid image tag. The failure happens exclusively at the cluster object dependency layer, forcing an agent to debug the Kubernetes secret infrastructure rather than the deployment manifest.
  • Evaluates Real-World Correlation (PR #117927 Update): Following Kubernetes PR #117927, Kubelet now emits a warning when a secret is missing. However, because this event is notoriously noisy and can trigger on perfectly healthy pods (e.g., if the image is public or alternate credentials succeed), this task forces the agent to contextually evaluate whether the log is an actual root cause or just noise based on the pod's true runtime state (ImagePullBackOff).

Target Application

HotelReservation (hotel-reservation namespace).

Rationale from the existing problem inventory:

  • HotelReservation hosts all of the benchmark's raw-KubeCtl problems — network_policy_block, admission_webhook_outage, admission_webhook_tls_mismatch, expired_tls_hotel_reservation, node_conntrack_exhaustion, pod_cidr_exhaustion. An imagePullSecret fault is a cluster-credential object dependency, placing it naturally in this family.
  • The app uses a single shared image (yinfangchen/hotelreservation:latest on Docker Hub) for all its microservices, which simplifies targeting a single Deployment without tracking multiple image references.
  • AstronomyShop (ghcr.io/open-telemetry/demo:*) and SocialNetwork (docker.io/deathstarbench/social-network-microservices:latest) are also viable and can be good candidates too.

Technical Implementation Strategy (Handling the Public Image Paradox)

Because HotelReservation uses public Docker Hub images, a missing or invalid secret will not naturally prevent the image from being pulled; the Kubelet will simply bypass the missing secret and pull the public image successfully (though it will log the PR #117927 warning).

To ensure the pod actually breaks and falls into an ImagePullBackOff loop to test the agent's diagnostics, I propose one of two injection mechanisms alongside modifying the target deployment's imagePullPolicy to Always (which contradicts the change introduced in #201):

  • Option A (Lightweight Domain Mutation): The injection script will use kubectl patch to mutate the deployment's image string to point to a fictitious private registry domain (e.g., internal-secure-registry.io/hotelreservation:latest) while injecting a broken imagePullSecret. This simulates a complete authentication/resolution breakdown.
  • Option B (Local Auth Registry): The injection script will dynamically deploy a temporary, authenticated local registry container inside the cluster during problem setup, host the application image there, and then purposely delete or corrupt the matching namespace secret to trigger the hard failure.

Questions for the Authors

  • Is this problem definition novel enough to be added to the registry as a standalone task? Did I miss something in my analysis of the existing problems?
  • I could not find any associated Real World corporate incidents linked to the issue. Is it okay to add it by referencing the upstream Kubernetes documentation framework (PR #117927) as our domain justification?
  • If you do approve of this plan, which of the proposed technical implementation strategies (Option A or Option B) fits better with SREGym's existing fault injection philosophy?

I look forward to your feedback on whether this aligns with the roadmap so I can begin drafting the PR!

Activity

  1. Saadmrp1038 commented on Jun 3, 2026

    @Saadmrp1038
    Collaborator

    @W-OK-E Thanks for the RFC! The noisy-warning angle from PR #117927 is really interesting.

    To me it looks like Option B is the better choice. Option A (fake registry + broken secret) is just incorrect_image again, the pod goes into ImagePullBackOff and kubectl describe pod shows the answer. Option B (valid image, real broken secret) plus a decoy of healthy pods throwing the same FailedToRetrieveImagePullSecret warning is much more unique. Now the agent can't trust the warning and has to check it against real pod state to find the one true root cause.

    One thing to watch out for is since the real image is also public on Docker Hub, the agent can just repoint the deployment at the public image, the pod goes Running without ever touching the secret, and it'll look solved. If the app comes back up that way, the agent will reasonably think it fixed it, so I don't think we can fairly fail it for that. You'll need to make sure there's no working image reachable except through the secret (private-only image, no cached/public fallback), otherwise this collapses back into incorrect_image. Worth thinking about how you'd close that loophole before the PR.

    For your questions:

    1. Not novel or hard enough as written, but the Option B + decoy version would be.
    2. Found this #128544. Take a look and see if relevant.
    3. Obviously B. One thing don't make imagePullPolicy: Always a permanent change to the manifest. Set it during injection and revert it on recovery.

    If you can figure out agent using public image part this could be a great fault!
    Also, the implementation for this might be quite tricky. Feel free to ask for help and please test the fault thoroughly before giving PR.

  2. W-OK-E commented on Jun 4, 2026

    @W-OK-E
    ContributorAuthor

    Thank you for the feedback @Saadmrp1038 , have tested a few things, will incorporate aforementioned changes and keep you posted.

  3. W-OK-E commented on Jun 6, 2026

    @W-OK-E
    ContributorAuthor

    Hey @Saadmrp1038 , I went on and implemented the problem, here I outline the rough details and a few questions that were bugging me:

    1. The Problem: In the hotel-reservation app, the recommendation pod image is moved to a private registry and its credentials secret (hotel-registry-creds) is deleted, leading to ImagePullBackOff.
    2. Key Challenge: Two decoy pods emit the same FailedToRetrieveImagePullSecret warning but stay Running, requiring the agent to distinguish between pods using actual status, not just events. The decoy pods have no labels to distinguish them from legitimate or broken pods. (Inspired from #128544)
    3. The Fix: Recreate a valid kubernetes.io/dockerconfigjson secret and ensure the Deployment references it.
    4. Uniqueness: Unlike existing tasks, it uses a private registry (making credentials non-optional) and introduces noise via decoy pods.
    5. Implementation: Injector sets up a registry:2 container, configures containerd on Kind nodes for HTTP pulls, and forces a rollout.
    6. Oracle Checks: Validates secret existence, correct format (auths block), Deployment reference, preservation of the private registry image URL, and pod health.

    All the oracle checks pass, recover_fault() undoes all the changes successfully, and as instructed, the change in imagePullPolicy is reverted back to IfNotPresent.


    Questions

    Some of these are also about design choices that confused me:

    1. Oracle check 4 scope: an agent that creates a correct secret but also changes the image URL back to Docker Hub as a precaution fails check 4, even though the registry pull would still work. Should check 4 only reject agents that remove the private image entirely, or is it correct to reject any image URL change?
    2. To mitigate the issue an agent needs to know two things: the registry server address and the credentials. While the server address is discoverable, the credentials are not, do we leave it at that or do we include some sort of a hint in the get_context() function? Or while I am pushing the docker image into the private registry, I could make the subprocess run the command in such a way that the password is discoverable via ps aux, currently it is getting piped in.

    And of course, let me know if you have any additional questions or would want me to share any additional test results before you approve this for a PR. Even if you think the current implementation is not challenging/novel enough for a PR, feel free to let me know, I will improve it.

  4. Saadmrp1038 commented on Jun 6, 2026

    @Saadmrp1038
    Collaborator

    @W-OK-E Nice work! For your questions:

    1. Reject any image URL change. Ideal scenerio is make the public swap actually fail (maybe block egress so the Docker Hub image isn't reachable, or some other way) instead of just failing it in the oracle while the pod runs. Otherwise the agent points to the public image, sees a healthy app, and thinks it fixed it.

    2. The ps aux trick feels flaky. Better to leave the creds discoverable in cluster state like real recovery would. Just drop the registry user/pass into a Secret the agent can read and let it rebuild the pull secret from there. Easiest spot is probably the registry's own namespace, so the agent can trace from the broken pod to its registry to the secret. Worth looking up what's common in prod environments.

    I think the core challenge now is blocking the move-to-public-image mitigation.

  5. W-OK-E commented on Jun 6, 2026

    @W-OK-E
    ContributorAuthor

    Makes sense, thank you for the insights @Saadmrp1038 , I have been trying a few things with the image repointing trick. Will incorporate a readable secret and once the private to public image switch is resolved, will update here and raise a PR.

  6. W-OK-E commented on Jun 8, 2026

    @W-OK-E
    ContributorAuthor

    Hey @Saadmrp1038, I figured the following ways to tackle the credentials and the public image pull issues:

    • For credentials, I am isolating them in a separate namespace inspired from standard practices. The namespace contains an opaque secret, acting in line with a centralized external Secrets provider pattern
      Additionally, a configMap (registry-access-runbook) is left in hotel-reservation, as a hint that creds are centrally managed and pointing it at the namespace + secret name.

    • To prevent public dockerhub pulls, any external pull requests are redirected at the containerd-mirror level to a small nginx:alpine sidecar that returns 403 forbidden. The redirect happens to http://dockerhub.internal:80 so as to keep it subtle, and even if the agent figures out that the redirect is forced, it cannot disable it since it lives in a node-filesystem containerd config, invisible to an agent operating via kubectl/Kubernetes RBAC. However, I found a bug after extensive testing:

    Sometimes, in the hotel-reservation app, I would exit the SREGym CLI via ctrl + c (post inject_fault and without running recover_fault) which meant that the private-registry I created (for storing docker images) and the changes made to /etc/containerd/certs.d/docker.io/hosts.toml would still persist (Unless I get rid of them manually post exit). Now if someone starts any other problem after this series of events (inject_fault -> exit (no teardown, no recover_fault)) any requests to dockerhub would get redirected to the sidecar.

    So I wanted advice on whether this design choice is okay i.e. are there other problems that make node-level changes and we trust every problem to finish or should I look for other ways to block egress? There are a few but they can be turned off by an agent with kubectl RBAC.

  7. Saadmrp1038 commented on Jun 8, 2026

    @Saadmrp1038
    Collaborator

    @W-OK-E

    are there other problems that make node-level changes and we trust every problem to finish

    Yes we do and no we don't trust every problem to finish. Look at the fix_kubernetes function inside conductor.py. For problems that if they exit mid-run without proper teardown can mess up our cluster we add global cleanup.

  8. W-OK-E commented on Jun 8, 2026

    @W-OK-E
    ContributorAuthor

    Aah, I completely missed that! Thank you for highlighting it @Saadmrp1038 !!
    I can see that currently there are a few cleanups which are specific to a few problem IDs in fix_kubernetes if I am not wrong:

    self.logger.info("[FIX] Calico IPPool/strictAffinity leftover if any")
            try:
                from sregym.conductor.problems.pod_cidr_exhaustion_hotel_reservation import (
                    PodCIDRExhaustionHotelReservation,
                )
    
                kubectl = KubeCtl()
                kubectl.exec_command(
                    f"kubectl patch ippool {PodCIDRExhaustionHotelReservation.DEFAULT_POOL_NAME} --type=merge "
                    '-p \'{"spec":{"disabled":false}}\'')

    I have taken a similar approach, and added cleanup for my problem ID:

     try:
                from sregym.conductor.problems.missing_image_pull_secret_hotel_reservation import (
                    MissingImagePullSecretHotelReservation,
                )
    
            MissingImagePullSecretHotelReservation.cleanup_leftovers() #Just calls the cleanup steps from recover_fault function.
            except Exception as e:
                self.logger.warning(f"Could not clean up MissingImagePullSecret leftovers: {e}")

    Does this approach seem fine? If yes, I will go ahead and open the PR.

  9. Saadmrp1038 commented on Jun 8, 2026

    @Saadmrp1038
    Collaborator

    @W-OK-E yeah this is fine.

  10. tianyin commented on Jun 16, 2026

    @tianyin
    Contributor

    Close this RFC as it is implemented in #883 already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions