Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused code in vpc cni init and vpc cni binary. #2891

Merged
merged 3 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions cmd/aws-vpc-cni-init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (

const (
defaultHostCNIBinPath = "/host/opt/cni/bin"
vpcCniInitDonePath = "/vpc-cni-init/done"
metadataLocalIP = "local-ipv4"
metadataMAC = "mac"
defaultDisableIPv4TcpEarlyDemux = false
Expand Down Expand Up @@ -181,17 +180,7 @@ func _main() int {
return 1
}

// TODO: In order to speed up pod launch time, VPC CNI init container is not a Kubernetes init container.
// The VPC CNI container blocks on the existence of vpcCniInitDonePath
//err = cp.TouchFile(vpcCniInitDonePath)
//if err != nil {
// log.WithError(err).Errorf("Failed to set VPC CNI init done")
// return 1
//}

log.Infof("CNI init container done")

// TODO: Since VPC CNI init container is a real container, it never exits
// time.Sleep(time.Duration(1<<63 - 1))
return 0
}
29 changes: 0 additions & 29 deletions cmd/aws-vpc-cni/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ import (
"os/exec"
"strconv"
"strings"
"time"

"github.com/pkg/errors"
log "github.com/sirupsen/logrus"

"github.com/containernetworking/cni/pkg/types"
Expand Down Expand Up @@ -188,27 +186,6 @@ func waitForIPAM() bool {
}
}

// Wait for vpcCniInitDonePath to exist (maximum wait time is 60 seconds)
func waitForInit() error {
start := time.Now()
maxEnd := start.Add(time.Minute)
for {
// Check for existence of vpcCniInitDonePath
if _, err := os.Stat(vpcCniInitDonePath); err == nil {
// Delete the done file in case of a reboot of the node or restart of the container (force init container to run again)
if err := os.Remove(vpcCniInitDonePath); err == nil {
return nil
}
// If file deletion fails, log and allow retry
log.Errorf("Failed to delete file: %s", vpcCniInitDonePath)
}
if time.Now().After(maxEnd) {
return errors.Errorf("time exceeded")
}
time.Sleep(1 * time.Second)
}
}

func getPrimaryIP(ipv4 bool) (string, error) {
var hostIP string
var err error
Expand Down Expand Up @@ -471,12 +448,6 @@ func _main() int {
return 1
}

// Wait for init container to complete
//if err := waitForInit(); err != nil {
// log.WithError(err).Errorf("Init container failed to complete")
// return 1
//}

log.Infof("Copying config file... ")
err = generateJSON(defaultAWSconflistFile, tmpAWSconflistFile, getPrimaryIP)
if err != nil {
Expand Down
Loading