Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileSystemScheduleMonitor crash on read-only file system #932

Open
belcher-rok opened this issue Feb 25, 2025 · 0 comments
Open

FileSystemScheduleMonitor crash on read-only file system #932

belcher-rok opened this issue Feb 25, 2025 · 0 comments

Comments

@belcher-rok
Copy link

belcher-rok commented Feb 25, 2025

Problem

On non-Windows machines, the FileSystemScheduleMonitor class persists scheduled timers to "$HOME/data/webjobs\timers" (note the backslash). This causes problems when using a read-only filesystem on non-Windows machines, such as a Linux container.

Steps to reproduce

  1. Create a WebJobs application
  2. Add a package reference to Microsoft.Azure.WebJobs.Extensions v5.0.
  3. Call AddTimers() on the WebJobs Host Builder.
  4. Build and run to verify it works correctly.
  5. Copy the following text into a compose.yaml file:
services:
  test-app:
    build:
      context: "."
      dockerfile_inline: |
        FROM mcr.microsoft.com/dotnet/sdk:9.0 as build
        WORKDIR /src
        COPY . .
        RUN dotnet build -c Release
        RUN dotnet publish -o ./app
        FROM mcr.microsoft.com/dotnet/runtime:9.0
        WORKDIR /app
        COPY --from=build /src/app .
        USER app
        ENTRYPOINT ["dotnet", "test.dll"]
    # use a read-only OS
    read_only: true 
    volumes:
      # make tmp folder writable
      - target: /tmp
        type: tmpfs
        tmpfs:
          size: 100Mb
      # make "$HOME/data/webjobs" folder writable
      - target: /home/app/data/webjobs
        type: tmpfs
        tmpfs:
          size: 50Mb
  1. Run docker compose up --build.

    If I got the Compose syntax correct, the app should build, start, then crash with the error: Unexpected fatal in startup: Read-only file system : '/home/app/data/webjobs\timers'.

  2. Okay, due to the errant backslash, the timers folder is actually named 'webjobs\timers'. So, let's change the volume mount to /home/app/data and try again: docker compose up --wait && docker compose logs --follow. This time it appears to work, but not so fast... Let's restart the container: docker compose restart && docker compose logs --follow. Now it is crashing on start-up again.

Workarounds

There are two known workarounds:

  1. Change the volume mount to $HOME/data/webjobs\timers. This allows my app to work, but as soon as this bug is fixed, my container will fail on startup since $HOME/data/webjobs/timers will be read-only.
  2. Disable read-only filesystem, assuming your company policy allows it (mine does not).

Expected

  1. WebJob Timers should work on read-only filesystem.
  2. The WebJobs "data" folder should be configurable, not hard coded (although I suppose someone could argue that it is "configurable" via the HOME variable. I don't know enough about Linux to know if that is a wise solution or not).

Version Info

  • .NET SDK 9.0.200
  • Microsoft.Azure.WebJobs 3.0.41
  • Microsoft.Azure.WebJobs.Extensions 5.0
  • TargetFramework: net9.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant