Set resources of container as configured. Can be used to change resources when the container is running.
(config configs.Config)
| 166 | // Set resources of container as configured. Can be used to change resources |
| 167 | // when the container is running. |
| 168 | func (c *Container) Set(config configs.Config) error { |
| 169 | c.m.Lock() |
| 170 | defer c.m.Unlock() |
| 171 | status, err := c.currentStatus() |
| 172 | if err != nil { |
| 173 | return err |
| 174 | } |
| 175 | if status == Stopped { |
| 176 | return ErrNotRunning |
| 177 | } |
| 178 | if err := c.cgroupManager.Set(config.Cgroups.Resources); err != nil { |
| 179 | // Set configs back |
| 180 | if err2 := c.cgroupManager.Set(c.config.Cgroups.Resources); err2 != nil { |
| 181 | logrus.Warnf("Setting back cgroup configs failed due to error: %v, your state.json and actual configs might be inconsistent.", err2) |
| 182 | } |
| 183 | return err |
| 184 | } |
| 185 | if c.intelRdtManager != nil { |
| 186 | if err := c.intelRdtManager.Set(&config); err != nil { |
| 187 | // Set configs back |
| 188 | if err2 := c.cgroupManager.Set(c.config.Cgroups.Resources); err2 != nil { |
| 189 | logrus.Warnf("Setting back cgroup configs failed due to error: %v, your state.json and actual configs might be inconsistent.", err2) |
| 190 | } |
| 191 | if err2 := c.intelRdtManager.Set(c.config); err2 != nil { |
| 192 | logrus.Warnf("Setting back intelrdt configs failed due to error: %v, your state.json and actual configs might be inconsistent.", err2) |
| 193 | } |
| 194 | return err |
| 195 | } |
| 196 | } |
| 197 | // After config setting succeed, update config and states |
| 198 | c.config = &config |
| 199 | _, err = c.updateState(nil) |
| 200 | return err |
| 201 | } |
| 202 | |
| 203 | // Start starts a process inside the container. Returns error if process fails |
| 204 | // to start. You can track process lifecycle with passed Process structure. |