8000 rkt/app: multiple bugfixes by lucab · Pull Request #3405 · rkt/rkt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 24, 2020. It is now read-only.

rkt/app: multiple bugfixes #3405

Merged
merged 5 commits into from
Nov 24, 2016
Merged

Conversation

lucab
Copy link
Member
@lucab lucab commented Nov 23, 2016

This is a cumulative PR containing multiple fixes for rkt app that surfaced while writing tests at #3371. Tests are not yet green, but these fixes should be ready to get in.

@lucab lucab added this to the v1.20.0 milestone Nov 23, 2016
Copy link
Contributor
@s-urbaniak s-urbaniak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a few nits, and questions, otherwise LGTM 👍

@@ -388,17 +383,17 @@ func RmApp(cfg RmConfig) error {
}
}

if err := RunCrossingEntrypoint(cfg.PodPath, cfg.PodPID, cfg.AppName.String(), appRmEntrypoint, args); err != nil {
if err := RunCrossingEntrypoint(cfg.PodPath, cfg.PodPID, cfg.AppName.String(), appRmEntrypoint, args, false); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are starting to accumulate more, and more parameters. How about introducing a:

type CrossingEntryPoint struct {
  PodPath string
  PodPID string
  AppName string
  RmEntrypoint string
  Interactive bool
}

and have the following method:

func (cep CrossingEntryPoint) Run() error {
 ...
}

The caller would instantiate a struct using obvious named values, and invoke the Run() method.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes a lot of sense.

flavor, _, err := stage1initcommon.GetFlavor(p)
if err != nil {
log.PrintE("failed to get stage1 flavor", err)
os.Exit(254)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't our logger exit with 254, when using log.FatalE?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, it looks like we can get rid of all those explicit Exit().

if err != nil {
log.FatalE("error getting cgroups", err)
log.PrintE(`error preparing cgroups`, err)
os.Exit(254)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, log.FatalE doesn't exit with 254 already?

Copy link
Member Author
@lucab lucab Nov 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to double-check, as I don't exactly remember what was going on here.

if !isUnified {
enabledCgroups, err := v1.GetEnabledCgroups()
// when using host cgroups, make the subgroup writable by pod systemd
if flavor != "kvm" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh ....

@@ -165,10 +156,39 @@ func main() {
Args: args,
}

if err := cmd.Run(); err != nil {
log.PrintE(`error executing "systemctl daemon-reload"`, err)
if out, err := cmd.CombinedOutput(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;-)

if err := cmd.Run(); err != nil {
log.PrintE(`error executing "systemctl daemon-reload"`, err)
if out, err := cmd.CombinedOutput(); err != nil {
log.Error(fmt.Errorf("%q failed at daemon-reload:\n%s", appName, out))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.Errorf?

return errwrap.Wrap(errors.New("failed to determine cgroup version"), err)
}

if !isUnified {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if isUnified {
  return nil
}

then untab the inner block

log.PrintE(`error executing "systemctl daemon-reload"`, err)

if out, err := cmd.CombinedOutput(); err != nil {
log.Error(fmt.Errorf("%q failed at daemon-reload:\n%s", appName, out))
os.Exit(254)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.FatalF?

if err := cmd.Run(); err != nil {
log.PrintE(fmt.Sprintf("error starting app %q", appName.String()), err)
if out, err := cmd.CombinedOutput(); err != nil {
log.Error(fmt.Errorf("%q failed:\n%s", appName, out))
os.Exit(254)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.FatalF?

@lucab lucab changed the title app: multiple bugfixes rkt/app: multiple bugfixes Nov 23, 2016
This add `Errorf()`, `Fatalf()` and `Panicf()` as convience
helpers to format and print string errors.
This fixes an incorrect behavior regarding cgroups remounting.
When running inside a kvm pod app-add should not try to tweak
host cgroups, as the pod already gets a dedicated and writable
cgroup hierarchy inside the VM.
This commit adds a `/etc/mtab -> ../proc/self/mounts` symlink in stage1
in oder to make mount and other tools happy.
@lucab lucab force-pushed the to-upstream/app-fixes branch from a3fd941 to 24bbe1f Compare November 23, 2016 15:35
@lucab
Copy link
Member Author
lucab commented Nov 23, 2016

Added a couple more commits to cleanup a few other bits after review comments. @s-urbaniak PTAL.

@s-urbaniak
Copy link
Contributor

LGTM, nice to have the 254 exits consolidated!

@s-urbaniak s-urbaniak merged commit 511bc08 into rkt:master Nov 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0