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 <85255050+ritikaguptams@users.noreply.github.com>

Adding stringer for usage and CI/CD

Signed-off-by: ritikaguptams <85255050+ritikaguptams@users.noreply.github.com>

Fixing build errors

Signed-off-by: ritikaguptams <85255050+ritikaguptams@users.noreply.github.com>

Ignore linting for files generated by Stringer

Signed-off-by: ritikaguptams <85255050+ritikaguptams@users.noreply.github.com>

Trying to fix CI go gen

Signed-off-by: ritikaguptams <85255050+ritikaguptams@users.noreply.github.com>

Removing extra step to fix CI go gen

Signed-off-by: ritikaguptams <85255050+ritikaguptams@users.noreply.github.com>

go gen CI fix try 2

Signed-off-by: ritikaguptams <85255050+ritikaguptams@users.noreply.github.com>

Skip autogenerated file from linting

Signed-off-by: ritikaguptams <85255050+ritikaguptams@users.noreply.github.com>

Fixing linting

Signed-off-by: ritikaguptams <85255050+ritikaguptams@users.noreply.github.com>

Fixing linting

Signed-off-by: ritikaguptams <85255050+ritikaguptams@users.noreply.github.com>

Removing stringer to avoid increasing package bloat for hcsshim

Signed-off-by: ritikaguptams <85255050+ritikaguptams@users.noreply.github.com>

cleanup

Signed-off-by: ritikaguptams <85255050+ritikaguptams@users.noreply.github.com>

Adding comment for future HNS v2 change

Signed-off-by: ritikaguptams <85255050+ritikaguptams@users.noreply.github.com>

Fix linting

Signed-off-by: ritikaguptams <85255050+ritikaguptams@users.noreply.github.com>
(cherry picked from commit e96bfcd)
Signed-off-by: ritikaguptams <85255050+ritikaguptams@users.noreply.github.com>
  • 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 # to comment.