Skip to content

Commit

Permalink
ReadyOnCreate set in HCN.Create()
Browse files Browse the repository at this point in the history
Signed-off-by: Kirtana Ashok <[email protected]>
(cherry picked from commit 76fd09d62abba4b2ffb64291e3725fd039a818d2)
Signed-off-by: Kirtana Ashok <[email protected]>
  • Loading branch information
kiashok committed May 14, 2024
1 parent c950974 commit 6e565cf
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions hcn/hcnnamespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"syscall"

"github.com/Microsoft/go-winio/pkg/guid"
"github.com/Microsoft/hcsshim"
icni "github.com/Microsoft/hcsshim/internal/cni"
"github.com/Microsoft/hcsshim/internal/interop"
"github.com/Microsoft/hcsshim/internal/regstate"
Expand Down Expand Up @@ -309,16 +310,41 @@ func GetNamespaceContainerIds(namespaceID string) ([]string, error) {

// NewNamespace creates a new Namespace object
func NewNamespace(nsType NamespaceType) *HostComputeNamespace {
/*
// HNS versions >= 15.2 change how network compartments are
// initialized for pods and depends on ReadyOnCreate flag in
// HCN namespace. It primarily supports removal of pause containers
// for process isolation.
isReadyOnCreate := false
hnsGlobals, err := hcsshim.GetHNSGlobals()
if err == nil {
isReadyOnCreate = (hnsGlobals.Version.Major > 15) ||
(hnsGlobals.Version.Major == 15 && hnsGlobals.Version.Minor >= 2)
}
*/
return &HostComputeNamespace{
Type: nsType,
SchemaVersion: V2SchemaVersion(),
//ReadyOnCreate: isReadyOnCreate,
}
}

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

// HNS versions >= 15.2 change how network compartments are
// initialized for pods and depends on ReadyOnCreate flag in
// HCN namespace. It primarily supports removal of pause containers
// for process isolation.
isReadyOnCreate := false
hnsGlobals, err := hcsshim.GetHNSGlobals()
if err == nil {
isReadyOnCreate = (hnsGlobals.Version.Major > 15) ||
(hnsGlobals.Version.Major == 15 && hnsGlobals.Version.Minor >= 2)
}
namespace.ReadyOnCreate = isReadyOnCreate

jsonString, err := json.Marshal(namespace)
if err != nil {
return nil, err
Expand Down

0 comments on commit 6e565cf

Please sign in to comment.