Skip to content

Commit

Permalink
Adding state attribute to the HNSEndpoint struct to support hyperv co…
Browse files Browse the repository at this point in the history
…ntainers for k8s

Signed-off-by: ritikaguptams <[email protected]>

Adding stringer for usage and CI/CD

Signed-off-by: ritikaguptams <[email protected]>

Fixing build errors

Signed-off-by: ritikaguptams <[email protected]>

Ignore linting for files generated by Stringer

Signed-off-by: ritikaguptams <[email protected]>

Trying to fix CI go gen

Signed-off-by: ritikaguptams <[email protected]>

Removing extra step to fix CI go gen

Signed-off-by: ritikaguptams <[email protected]>

go gen CI fix try 2

Signed-off-by: ritikaguptams <[email protected]>

Skip autogenerated file from linting

Signed-off-by: ritikaguptams <[email protected]>

Fixing linting

Signed-off-by: ritikaguptams <[email protected]>

Fixing linting

Signed-off-by: ritikaguptams <[email protected]>

Removing stringer to avoid increasing package bloat for hcsshim

Signed-off-by: ritikaguptams <[email protected]>

cleanup

Signed-off-by: ritikaguptams <[email protected]>

Adding comment for future HNS v2 change

Signed-off-by: ritikaguptams <[email protected]>

Fix linting

Signed-off-by: ritikaguptams <[email protected]>
(cherry picked from commit e96bfcd)
Signed-off-by: ritikaguptams <[email protected]>
  • Loading branch information
ritikaguptams authored and kiashok committed Jun 24, 2024
1 parent 1495e9f commit e59d3d2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions internal/hns/hnsendpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@ import (
"github.com/sirupsen/logrus"
)

// EndpointState represents the states of an HNS Endpoint lifecycle.
type EndpointState uint16

// EndpointState const
// The lifecycle of an Endpoint goes through created, attached, AttachedSharing - endpoint is being shared with other containers,
// detached, after being attached, degraded and finally destroyed.
// Note: This attribute is used by calico to define stale containers and is dependent on HNS v1 api, if we move to HNS v2 api we will need
// to update the current calico code and cordinate the change with calico. Reach out to Microsoft to facilate the change via HNS.
const (
Uninitialized EndpointState = iota
Created EndpointState = 1
Attached EndpointState = 2
AttachedSharing EndpointState = 3
Detached EndpointState = 4
Degraded EndpointState = 5
Destroyed EndpointState = 6
)

func (es EndpointState) String() string {
return [...]string{"Uninitialized", "Attached", "AttachedSharing", "Detached", "Degraded", "Destroyed"}[es]
}

// HNSEndpoint represents a network endpoint in HNS
type HNSEndpoint struct {
Id string `json:"ID,omitempty"`
Expand All @@ -34,6 +56,7 @@ type HNSEndpoint struct {
Namespace *Namespace `json:",omitempty"`
EncapOverhead uint16 `json:",omitempty"`
SharedContainers []string `json:",omitempty"`
State EndpointState `json:",omitempty"`
}

// SystemType represents the type of the system on which actions are done
Expand Down

0 comments on commit e59d3d2

Please sign in to comment.