Skip to content

Commit 6e565cf

Browse files
committed
ReadyOnCreate set in HCN.Create()
Signed-off-by: Kirtana Ashok <[email protected]> (cherry picked from commit 76fd09d62abba4b2ffb64291e3725fd039a818d2) Signed-off-by: Kirtana Ashok <[email protected]>
1 parent c950974 commit 6e565cf

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

hcn/hcnnamespace.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"syscall"
1010

1111
"github.com/Microsoft/go-winio/pkg/guid"
12+
"github.com/Microsoft/hcsshim"
1213
icni "github.com/Microsoft/hcsshim/internal/cni"
1314
"github.com/Microsoft/hcsshim/internal/interop"
1415
"github.com/Microsoft/hcsshim/internal/regstate"
@@ -309,16 +310,41 @@ func GetNamespaceContainerIds(namespaceID string) ([]string, error) {
309310

310311
// NewNamespace creates a new Namespace object
311312
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+
*/
312325
return &HostComputeNamespace{
313326
Type: nsType,
314327
SchemaVersion: V2SchemaVersion(),
328+
//ReadyOnCreate: isReadyOnCreate,
315329
}
316330
}
317331

318332
// Create Namespace.
319333
func (namespace *HostComputeNamespace) Create() (*HostComputeNamespace, error) {
320334
logrus.Debugf("hcn::HostComputeNamespace::Create id=%s", namespace.Id)
321335

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+
322348
jsonString, err := json.Marshal(namespace)
323349
if err != nil {
324350
return nil, err

0 commit comments

Comments
 (0)