Skip to content

Commit

Permalink
*: fix "eks/amazon-eks-ami-issue-454", release (#197)
Browse files Browse the repository at this point in the history
* *: fix "eks/amazon-eks-ami-issue-454"

Signed-off-by: Gyuho Lee <[email protected]>

* CHANGELOG: update

Signed-off-by: Gyuho Lee <[email protected]>

* hack/build.sh: add "arm64" builds

Signed-off-by: Gyuho Lee <[email protected]>
  • Loading branch information
gyuho authored Jan 25, 2021
1 parent 95c85e6 commit 1d18edd
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 31 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG/CHANGELOG-1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@

<hr>

## [v1.5.6](https://github.com/aws/aws-k8s-tester/releases/tag/v1.5.6) (2021-01)
## [v1.5.6](https://github.com/aws/aws-k8s-tester/releases/tag/v1.5.6) (2021-01-25)

See [code changes](https://github.com/aws/aws-k8s-tester/compare/v1.5.5...v1.5.6).

### Release

- Add [arm64 (Apple M1) builds](https://github.com/aws/aws-k8s-tester/pull/193).

### `eksconfig`

- Expose [configuration of sonobuoy worker/systemd-logs container](https://github.com/aws/aws-k8s-tester/pull/190).
Expand All @@ -16,14 +20,16 @@ See [code changes](https://github.com/aws/aws-k8s-tester/compare/v1.5.5...v1.5.6

- Fix [`eks/mng` delete retries](https://github.com/aws/aws-k8s-tester/pull/196).
- See https://github.com/aws/aws-k8s-tester/issues/195.
- Add [`eks/amazon-eks-ami-issue-454`](https://github.com/aws/aws-k8s-tester/pull/193).
- Fix [list nodes](https://github.com/aws/aws-k8s-tester/pull/197).

### Dependency

- Upgrade [`github.com/aws/aws-sdk-go`](https://github.com/aws/aws-sdk-go/releases) from [`v1.35.27`](https://github.com/aws/aws-sdk-go/releases/tag/v1.35.27) to [`v1.35.30`](https://github.com/aws/aws-sdk-go/releases/tag/v1.35.30).
- `v1.36.2` breaks darwin builds.
### Go

- Compile with [*Go 1.15.6*](https://golang.org/doc/devel/release.html#go1.15).
- Compile with [*Go 1.16beta1*](https://golang.org/doc/devel/release.html#go1.16).



Expand Down
9 changes: 6 additions & 3 deletions eks/amazon-eks-ami-issue-454/soft-lockup-454.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,13 @@ func (ts *tester) waitDeployment() (err error) {

func (ts *tester) validateNodesStayHealthy() (err error) {
nodeSelector := ts.getNodeSelector()

nodes, err := ts.cfg.K8SClient.ListNodesWithSelector(1000, 5*time.Second, nodeSelector)
nodes, err := ts.cfg.K8SClient.ListNodes(
1000,
5*time.Second,
k8s_client.WithFieldSelector(nodeSelector),
)
if err != nil {
ts.cfg.Logger.Warn("get nodes failed", zap.Error(err))
ts.cfg.Logger.Warn("list nodes failed", zap.Error(err))
return err
}

Expand Down
36 changes: 22 additions & 14 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,40 @@ echo "GIT_COMMIT:" ${GIT_COMMIT}
echo "RELEASE_VERSION:" ${RELEASE_VERSION}
echo "BUILD_TIME:" ${BUILD_TIME}

DEFAULT_WHAT='aws-k8s-tester cw-utils ec2-utils ecr-utils eks-utils etcd-utils s3-utils sts-utils'
DEFAULT_ARCHS='amd64 arm64'
DEFAULT_TARGETS='linux darwin'
DEFAULT_WHAT='aws-k8s-tester cw-utils ec2-utils ecr-utils eks-utils etcd-utils s3-utils sts-utils'

PACKAGE_NAME='github.com/aws/aws-k8s-tester'
WHAT=${WHAT:-$DEFAULT_WHAT}
ARCHS=${ARCHS:-$DEFAULT_ARCHS}
TARGETS=${TARGETS:-$DEFAULT_TARGETS}
WHAT=${WHAT:-$DEFAULT_WHAT}

echo ""
echo "Usage: \`make TARGETS='linux' WHAT='aws-k8s-tester cw-utils'\`"
echo "DEFAULT_ARCHS=$DEFAULT_ARCHS"
echo "DEFAULT_TARGETS=$DEFAULT_TARGETS"
echo "DEFAULT_WHAT=$DEFAULT_WHAT"
echo ""

mkdir -p ./bin

for os in ${TARGETS}; do
for cmd in ${WHAT}; do
echo "=== Building target=${cmd}, os=${os} ==="
CGO_ENABLED=0 GOOS=${os} GOARCH=$(go env GOARCH) \
go build -mod=vendor -v \
-ldflags "-s -w \
-X ${PACKAGE_NAME}/version.GitCommit=${GIT_COMMIT} \
-X ${PACKAGE_NAME}/version.ReleaseVersion=${RELEASE_VERSION} \
-X ${PACKAGE_NAME}/version.BuildTime=${BUILD_TIME}" \
-o ./bin/${cmd}-${RELEASE_VERSION}-${os}-$(go env GOARCH) \
./cmd/${cmd}
PACKAGE_NAME='github.com/aws/aws-k8s-tester'
for arch in ${ARCHS}; do
for os in ${TARGETS}; do
for bin in ${WHAT}; do
echo "=== Building arch=${arch}, os=${os}, target=${bin} ==="
CGO_ENABLED=0 \
GOARCH=${arch} \
GOOS=${os} \
go build \
-mod=vendor -v \
-ldflags "-s -w \
-X ${PACKAGE_NAME}/version.GitCommit=${GIT_COMMIT} \
-X ${PACKAGE_NAME}/version.ReleaseVersion=${RELEASE_VERSION} \
-X ${PACKAGE_NAME}/version.BuildTime=${BUILD_TIME}" \
-o ./bin/${bin}-${RELEASE_VERSION}-${os}-$(go env GOARCH) \
./cmd/${bin}
done
done
done

Expand Down
39 changes: 28 additions & 11 deletions pkg/k8s-client/eks.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ type EKS interface {
// ListNamespaces returns the list of existing namespace names.
ListNamespaces(batchLimit int64, batchInterval time.Duration) ([]v1.Namespace, error)
// ListNodes returns the list of existing nodes.
ListNodes(batchLimit int64, batchInterval time.Duration) ([]v1.Node, error)
// ListNodes returns the list of existing CSRs.
ListNodes(batchLimit int64, batchInterval time.Duration, opts ...OpOption) ([]v1.Node, error)
// ListCSRs returns the list of existing CSRs.
ListCSRs(batchLimit int64, batchInterval time.Duration) ([]certificatesv1beta1.CertificateSigningRequest, error)
// ListPods returns the list of existing namespace names.
ListPods(namespace string, batchLimit int64, batchInterval time.Duration) ([]v1.Pod, error)
ListPods(namespace string, batchLimit int64, batchInterval time.Duration, opts ...OpOption) ([]v1.Pod, error)
// ListConfigMaps returns the list of existing config maps.
ListConfigMaps(namespace string, batchLimit int64, batchInterval time.Duration) ([]v1.ConfigMap, error)
// ListSecrets returns the list of existing Secret objects.
Expand Down Expand Up @@ -917,20 +917,31 @@ func (e *eks) listNamespaces(batchLimit int64, batchInterval time.Duration) (ns
return ns, err
}

func (e *eks) ListNodes(batchLimit int64, batchInterval time.Duration) ([]v1.Node, error) {
ns, err := e.listNodes(batchLimit, batchInterval)
func (e *eks) ListNodes(batchLimit int64, batchInterval time.Duration, opts ...OpOption) ([]v1.Node, error) {
ns, err := e.listNodes(batchLimit, batchInterval, opts...)
return ns, err
}

func (e *eks) listNodes(batchLimit int64, batchInterval time.Duration) (nodes []v1.Node, err error) {
func (e *eks) listNodes(batchLimit int64, batchInterval time.Duration, opts ...OpOption) (nodes []v1.Node, err error) {
ret := Op{}
ret.applyOpts(opts)

e.cfg.Logger.Info("listing nodes",
zap.Int64("batch-limit", batchLimit),
zap.Duration("batch-interval", batchInterval),
zap.String("label-selector", ret.labelSelector),
zap.String("field-selector", ret.fieldSelector),
)
rs := &v1.NodeList{ListMeta: metav1.ListMeta{Continue: ""}}
for {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
rs, err = e.getClient().CoreV1().Nodes().List(ctx, metav1.ListOptions{Limit: batchLimit, Continue: rs.Continue})
rs, err = e.getClient().CoreV1().Nodes().List(ctx, metav1.ListOptions{
Limit: batchLimit,
Continue: rs.Continue,

LabelSelector: ret.labelSelector,
FieldSelector: ret.fieldSelector,
})
cancel()
if err != nil {
return nil, err
Expand Down Expand Up @@ -986,20 +997,26 @@ func (e *eks) listCSRs(batchLimit int64, batchInterval time.Duration) (csrs []ce
return csrs, err
}

func (e *eks) ListPods(namespace string, batchLimit int64, batchInterval time.Duration) ([]v1.Pod, error) {
ns, err := e.listPods(namespace, batchLimit, batchInterval, 5)
func (e *eks) ListPods(namespace string, batchLimit int64, batchInterval time.Duration, opts ...OpOption) ([]v1.Pod, error) {
ns, err := e.listPods(namespace, batchLimit, batchInterval, 5, opts...)
return ns, err
}

func (e *eks) listPods(
namespace string,
batchLimit int64,
batchInterval time.Duration,
retryLeft int) (pods []v1.Pod, err error) {
retryLeft int,
opts ...OpOption) (pods []v1.Pod, err error) {
ret := Op{}
ret.applyOpts(opts)

e.cfg.Logger.Info("listing pods",
zap.String("namespace", namespace),
zap.Int64("batch-limit", batchLimit),
zap.Duration("batch-interval", batchInterval),
zap.String("label-selector", ret.labelSelector),
zap.String("field-selector", ret.fieldSelector),
)
rs := &v1.PodList{ListMeta: metav1.ListMeta{Continue: ""}}
for {
Expand All @@ -1014,7 +1031,7 @@ func (e *eks) listPods(
// e.g. The provided continue parameter is too old to display a consistent list result. You can start a new list without the continue parameter, or use the continue token in this response to retrieve the remainder of the results. Continuing with the provided token results in an inconsistent list - objects that were created, modified, or deleted between the time the first chunk was returned and now may show up in the list.
e.cfg.Logger.Warn("stale list response, retrying for consistent list", zap.Error(err))
time.Sleep(15 * time.Second)
return e.listPods(namespace, batchLimit, batchInterval, retryLeft-1)
return e.listPods(namespace, batchLimit, batchInterval, retryLeft-1, opts...)
}
return nil, err
}
Expand Down
14 changes: 13 additions & 1 deletion pkg/k8s-client/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -911,15 +911,27 @@ func WaitForDeploymentCompletes(

// Op represents a Kubernetes client operation.
type Op struct {
labelSelector string
fieldSelector string
queryFunc func()
podFunc func(v1.Pod)
forceDelete bool
forceDeleteFunc func()
}

// OpOption configures archiver operations.
// OpOption configures Kubernetes client operations.
type OpOption func(*Op)

// WithLabelSelector configures label selector for list operations.
func WithLabelSelector(s string) OpOption {
return func(op *Op) { op.labelSelector = s }
}

// WithFieldSelector configures field selector for list operations.
func WithFieldSelector(s string) OpOption {
return func(op *Op) { op.fieldSelector = s }
}

// WithQueryFunc configures query function to be called in retry func.
func WithQueryFunc(f func()) OpOption {
return func(op *Op) { op.queryFunc = f }
Expand Down

0 comments on commit 1d18edd

Please sign in to comment.