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

client: remove unused Docker images and containers on startup #5877

Merged
merged 6 commits into from
Nov 3, 2024

Conversation

davidpanderson
Copy link
Contributor

The names of images and containers created by docker_wrapper have a particular form:
boinc__ and boinc__.

docker_wrapper normally cleans up after itself.
But if it crashes, these objects could hang around forever, taking up disk space.

So clean them up on client startup, as follows:
make lists of the image/container names for active Docker tasks.
Then go through the Docker images and containers.
Remove any that

  • were created by Docker wrapper (i.e. have boinc__ names)
  • aren't in the active-task lists

On Unix, do this on the host itself if it has Docker installed.
On Win, do it for every WSL distro that has Docker installed.

The images and containers created by docker_wrapper have a particular form:
boinc__<proj>__<wuname> and boinc__<proj>__<resultname>.

docker_wrapper normally cleans up after itself.
But if it crashes these objects could hang around forever,
taking up disk space.

So we clean them up on client startup, as follows:
make lists of the names for active Docker tasks.
Then go through the list of Docker images and containers.
Remove any that
- were created by Docker wrapper (i.e. have boinc__ names)
- aren't in the active-task lists

On Unix, do this on the host itself if it has Docker installed.
On Win, do it for every WSL distro that has Docker installed.
Make 'verbose' an attribute of DOCKER_CONN.
@AenBleidd
Copy link
Member

@davidpanderson, please fix build errors

@AenBleidd
Copy link
Member

@davidpanderson,
there are some other errors left:

  • linux:
util.cpp: In member function ‘int DOCKER_CONN::command(const char*, std::vector<std::__cxx11::basic_string<char> >&)’:
boinc_stdio.h:32:19: error: cannot convert ‘FCGI_FILE*’ to ‘FILE*’
   32 | #define stderr    FCGI_stderr
      |                   ^~~~~~~~~~~
      |                   |
      |                   FCGI_FILE*
util.cpp:732:17: note: in expansion of macro ‘stderr’
  732 |         fprintf(stderr, "running docker command: %s\n", cmd);
      |                 ^~~~~~
In file included from /usr/include/stdio.h:894,
                 from /usr/include/fcgi_stdio.h:18,
                 from boinc_stdio.h:28,
                 from util.cpp:34:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:103:27: note:   initializing argument 1 of ‘int fprintf(FILE*, const char*, ...)’
  103 | fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...)
      |          ~~~~~~~~~~~~~~~~~^~~~~~~~
In file included from boinc_stdio.h:28,
                 from util.cpp:34:
boinc_stdio.h:32:19: error: cannot convert ‘FCGI_FILE*’ to ‘FILE*’
   32 | #define stderr    FCGI_stderr
      |                   ^~~~~~~~~~~
      |                   |
      |                   FCGI_FILE*
util.cpp:752:21: note: in expansion of macro ‘stderr’
  752 |             fprintf(stderr, "command failed: %s\n", boincerror(retval));
      |                     ^~~~~~
In file included from /usr/include/stdio.h:894,
                 from /usr/include/fcgi_stdio.h:18,
                 from boinc_stdio.h:28,
                 from util.cpp:34:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:103:27: note:   initializing argument 1 of ‘int fprintf(FILE*, const char*, ...)’
  103 | fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...)
      |          ~~~~~~~~~~~~~~~~~^~~~~~~~
In file included from boinc_stdio.h:28,
                 from util.cpp:34:
boinc_stdio.h:32:19: error: cannot convert ‘FCGI_FILE*’ to ‘FILE*’
   32 | #define stderr    FCGI_stderr
      |                   ^~~~~~~~~~~
      |                   |
      |                   FCGI_FILE*
util.cpp:758:17: note: in expansion of macro ‘stderr’
  758 |         fprintf(stderr, "command output:\n");
      |                 ^~~~~~
In file included from /usr/include/stdio.h:894,
                 from /usr/include/fcgi_stdio.h:18,
                 from boinc_stdio.h:28,
                 from util.cpp:34:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:103:27: note:   initializing argument 1 of ‘int fprintf(FILE*, const char*, ...)’
  103 | fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...)
      |          ~~~~~~~~~~~~~~~~~^~~~~~~~
In file included from boinc_stdio.h:28,
                 from util.cpp:34:
boinc_stdio.h:32:19: error: cannot convert ‘FCGI_FILE*’ to ‘FILE*’
   32 | #define stderr    FCGI_stderr
      |                   ^~~~~~~~~~~
      |                   |
      |                   FCGI_FILE*
util.cpp:760:21: note: in expansion of macro ‘stderr’
  760 |             fprintf(stderr, "%s\n", line.c_str());
      |                     ^~~~~~
In file included from /usr/include/stdio.h:894,
                 from /usr/include/fcgi_stdio.h:18,
                 from boinc_stdio.h:28,
                 from util.cpp:34:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:103:27: note:   initializing argument 1 of ‘int fprintf(FILE*, const char*, ...)’
  103 | fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...)
      |          ~~~~~~~~~~~~~~~~~^~~~~~~~
make[2]: *** [Makefile:1898: libboinc_fcgi_la-util.lo] Error 1
make[2]: Leaving directory '/home/runner/work/boinc/boinc/lib'
make[1]: *** [Makefile:687: all-recursive] Error 1
make[1]: Leaving directory '/home/runner/work/boinc/boinc'
make: *** [Makefile:591: all] Error 2
  • windows:
       "D:\a\boinc\boinc\win_build\sim.vcxproj.metaproj" (default target) (5) ->
       "D:\a\boinc\boinc\win_build\sim.vcxproj" (default target) (52) ->
       (ClCompile target) -> 
         D:\a\boinc\boinc\client\cs_apps.cpp(483,12): error C2660: 'DOCKER_CONN::init': function does not take 2 arguments [D:\a\boinc\boinc\win_build\sim.vcxproj]


       "D:\a\boinc\boinc\win_build\boinc.sln" (default target) (1) ->
       "D:\a\boinc\boinc\win_build\boinccmd.vcxproj" (default target) (20) ->
       "D:\a\boinc\boinc\win_build\boinc_cli.vcxproj" (default target) (24) ->
         D:\a\boinc\boinc\client\cs_apps.cpp(483,12): error C2660: 'DOCKER_CONN::init': function does not take 2 arguments [D:\a\boinc\boinc\win_build\boinc_cli.vcxproj]```

@AenBleidd
Copy link
Member

@davidpanderson, linux is still failing because of FCGI for the server build

Maybe we should divide util.cpp into
- things used from the scheduler and file upload handlers
    (where we need boinc::stdio stuff)
- everything else
Copy link

codecov bot commented Nov 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 43 lines in your changes missing coverage. Please review.

Project coverage is 10.73%. Comparing base (7a873b1) to head (3645a16).
Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
lib/util.cpp 0.00% 43 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5877      +/-   ##
============================================
- Coverage     10.75%   10.73%   -0.02%     
  Complexity     1068     1068              
============================================
  Files           280      280              
  Lines         36555    36598      +43     
  Branches       8472     8482      +10     
============================================
  Hits           3930     3930              
- Misses        32236    32279      +43     
  Partials        389      389              
Files with missing lines Coverage Δ
lib/util.h 40.00% <ø> (ø)
lib/util.cpp 22.41% <0.00%> (-7.36%) ⬇️

@AenBleidd AenBleidd merged commit d889e9f into master Nov 3, 2024
152 of 153 checks passed
@AenBleidd AenBleidd deleted the dpa_docker_cleanup branch November 3, 2024 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

2 participants