Content-Length: 240124 | pFad | http://github.com/miekg/gitopper/commit/a4a8694fa686cef4ae79314a4f99f01c158301ad

6F Remount files (#76) · miekg/gitopper@a4a8694 · GitHub
Skip to content

Commit

Permalink
Remount files (#76)
Browse files Browse the repository at this point in the history
* File bind mounts are done on the inode. We should remount these mounts.

* Better to say unmounting.

* Remount on diff.

* Have to remount before every systemctl call.

* Should be the log for directory mounts.
  • Loading branch information
tongson authored Aug 9, 2024
1 parent 74c63a3 commit a4a8694
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ func (s *Service) trackUpstream(ctx context.Context, duration time.Duration) {
s.SetState(StateDiff, fmt.Sprintf("error rolling back %q to %q: %s", s.Upstream, info, err))
continue
}
if _, err := s.bindmount(); err != nil {
log.Warningf("Service %q, error setting up bind mounts for %q: %s", s.Service, s.Upstream, err)
s.SetState(StateBroken, fmt.Sprintf("error setting up bind mounts repo %q: %s", s.Upstream, err))
continue
}
if rerr := s.reload(); rerr != nil {
log.Warningf("Service %q, error running systemctl daemon-reload: %s", s.Service, rerr)
s.SetState(StateBroken, fmt.Sprintf("error running systemctl daemon-reload %q: %s", s.Upstream, rerr))
Expand Down Expand Up @@ -211,6 +216,11 @@ func (s *Service) trackUpstream(ctx context.Context, duration time.Duration) {
state, info = s.State()
s.SetState(state, info)

if _, err := s.bindmount(); err != nil {
log.Warningf("Service %q, error setting up bind mounts for %q: %s", s.Service, s.Upstream, err)
s.SetState(StateBroken, fmt.Sprintf("error setting up bind mounts repo %q: %s", s.Upstream, err))
continue
}
log.Infof("Service %q, diff in repo %q, pinging it", s.Service, s.Upstream)
if rerr := s.reload(); rerr != nil {
log.Warningf("Service %q, error running systemctl daemon-reload: %s", s.Service, rerr)
Expand Down Expand Up @@ -320,8 +330,24 @@ func (s *Service) bindmount() (int, error) {
}

if ok, err := mountinfo.Mounted(d.Local); err == nil && ok {
log.Infof("%s %q is already mounted", logtype, d.Local)
continue
if d.File == true {
log.Infof("%s %q is already mounted, unmounting", logtype, d.Local)
ctx := context.TODO()
cmd := exec.CommandContext(ctx, "umount", d.Local)
log.Infof("running %v", cmd.Args)
err := cmd.Run()
if err != nil {
if exitError, ok := err.(*exec.ExitError); ok {
if e := exitError.ExitCode(); e != 0 {
return 0, fmt.Errorf("failed to umount %q, exit code %d", d.Local, e)
}
}
return 0, fmt.Errorf("failed to umount %q: %s", d.Local, err)
}
} else {
log.Infof("%s %q is already mounted", logtype, d.Local)
continue
}
}

ctx := context.TODO()
Expand Down

0 comments on commit a4a8694

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/miekg/gitopper/commit/a4a8694fa686cef4ae79314a4f99f01c158301ad

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy