|
9 | 9 | "syscall" |
10 | 10 |
|
11 | 11 | "github.com/Microsoft/go-winio/pkg/guid" |
| 12 | + "github.com/Microsoft/hcsshim" |
12 | 13 | icni "github.com/Microsoft/hcsshim/internal/cni" |
13 | 14 | "github.com/Microsoft/hcsshim/internal/interop" |
14 | 15 | "github.com/Microsoft/hcsshim/internal/regstate" |
@@ -309,16 +310,41 @@ func GetNamespaceContainerIds(namespaceID string) ([]string, error) { |
309 | 310 |
|
310 | 311 | // NewNamespace creates a new Namespace object |
311 | 312 | func NewNamespace(nsType NamespaceType) *HostComputeNamespace { |
| 313 | + /* |
| 314 | + // HNS versions >= 15.2 change how network compartments are |
| 315 | + // initialized for pods and depends on ReadyOnCreate flag in |
| 316 | + // HCN namespace. It primarily supports removal of pause containers |
| 317 | + // for process isolation. |
| 318 | + isReadyOnCreate := false |
| 319 | + hnsGlobals, err := hcsshim.GetHNSGlobals() |
| 320 | + if err == nil { |
| 321 | + isReadyOnCreate = (hnsGlobals.Version.Major > 15) || |
| 322 | + (hnsGlobals.Version.Major == 15 && hnsGlobals.Version.Minor >= 2) |
| 323 | + } |
| 324 | + */ |
312 | 325 | return &HostComputeNamespace{ |
313 | 326 | Type: nsType, |
314 | 327 | SchemaVersion: V2SchemaVersion(), |
| 328 | + //ReadyOnCreate: isReadyOnCreate, |
315 | 329 | } |
316 | 330 | } |
317 | 331 |
|
318 | 332 | // Create Namespace. |
319 | 333 | func (namespace *HostComputeNamespace) Create() (*HostComputeNamespace, error) { |
320 | 334 | logrus.Debugf("hcn::HostComputeNamespace::Create id=%s", namespace.Id) |
321 | 335 |
|
| 336 | + // HNS versions >= 15.2 change how network compartments are |
| 337 | + // initialized for pods and depends on ReadyOnCreate flag in |
| 338 | + // HCN namespace. It primarily supports removal of pause containers |
| 339 | + // for process isolation. |
| 340 | + isReadyOnCreate := false |
| 341 | + hnsGlobals, err := hcsshim.GetHNSGlobals() |
| 342 | + if err == nil { |
| 343 | + isReadyOnCreate = (hnsGlobals.Version.Major > 15) || |
| 344 | + (hnsGlobals.Version.Major == 15 && hnsGlobals.Version.Minor >= 2) |
| 345 | + } |
| 346 | + namespace.ReadyOnCreate = isReadyOnCreate |
| 347 | + |
322 | 348 | jsonString, err := json.Marshal(namespace) |
323 | 349 | if err != nil { |
324 | 350 | return nil, err |
|
0 commit comments