Skip to content

Commit

Permalink
Merge pull request #11 from gwesterfieldjr/repo-improvements
Browse files Browse the repository at this point in the history
add readme and linter to verify any missing nil checks
  • Loading branch information
abhay-krishna authored Aug 30, 2022
2 parents 8d08273 + 5f8096e commit dd7bc8c
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 6 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- main
pull_request:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v3
with:
go-version: '1.18'
check-latest: true
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.49.0
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ generate-conversion: $(CONVERSION_GEN)
--output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE) \
--go-header-file=hack/boilerplate.go.txt

build: docker-build

# Build the docker image
docker-build: test
docker build . -t ${IMG}
Expand All @@ -89,6 +91,19 @@ docker-build: test
docker-push:
docker push ${IMG}

.PHONY: lint
lint: bin/golangci-lint ## Run golangci-lint
bin/golangci-lint run

bin/golangci-lint: ## Download golangci-lint
bin/golangci-lint: GOLANGCI_LINT_VERSION?=$(shell cat .github/workflows/golangci-lint.yml | yq e '.jobs.golangci.steps[] | select(.name == "golangci-lint") .with.version' -)
bin/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_LINT_VERSION)

.PHONY: clean
clean:
rm -Rf ./bin

$(CONTROLLER_GEN): $(TOOLS_BIN_DIR) # Build controller-gen from tools folder.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected])

Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## ETCD Admin Controller for Amazon EKS Anywhere

The etcdadm-controller is responsible for managing external etcd clusters created by Amazon EKS Anywhere (EKS-A)

Amazon EKS Anywhere is a new deployment option for Amazon EKS that enables you to easily create and operate Kubernetes clusters on-premises with your own virtual machines.
It brings a consistent AWS management experience to your data center, building on the strengths of [Amazon EKS Distro](https://github.com/aws/eks-distro), the same distribution of Kubernetes that powers EKS on AWS.
Its goal is to include full lifecycle management of multiple Kubernetes clusters that are capable of operating completely independently of any AWS services.

Here are the steps for [getting started](https://anywhere.eks.amazonaws.com/docs/getting-started/) with EKS Anywhere.
Full documentation for releases can be found on [https://anywhere.eks.amazonaws.com](https://anywhere.eks.amazonaws.com/).

## Security

If you discover a potential security issue in this project, or think you may
have discovered a security issue, we ask that you notify AWS Security via our
[vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/).
Please do **not** create a public GitHub issue.

## License

This project is licensed under the [Apache-2.0 License](LICENSE).
5 changes: 3 additions & 2 deletions controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (r *EtcdadmClusterReconciler) reconcile(ctx context.Context, etcdCluster *e
if nextMachineUpdateTime.After(time.Now()) {
// the latest machine with updated spec should get more time for etcd data sync
// requeue this after
after := nextMachineUpdateTime.Sub(time.Now())
after := time.Until(nextMachineUpdateTime)
log.Info(fmt.Sprintf("Requeueing etcdadm cluster for updating next machine after %s", after.String()))
return ctrl.Result{RequeueAfter: after}, nil
}
Expand All @@ -276,7 +276,8 @@ func (r *EtcdadmClusterReconciler) reconcile(ctx context.Context, etcdCluster *e
if conditions.Has(ep.EC, etcdv1.EtcdMachinesSpecUpToDateCondition) {
conditions.MarkTrue(ep.EC, etcdv1.EtcdMachinesSpecUpToDateCondition)

if _, hasUpgradeAnnotation := etcdCluster.Annotations[etcdv1.UpgradeInProgressAnnotation]; hasUpgradeAnnotation {
_, hasUpgradeAnnotation := etcdCluster.Annotations[etcdv1.UpgradeInProgressAnnotation]
if hasUpgradeAnnotation {
delete(etcdCluster.Annotations, etcdv1.UpgradeInProgressAnnotation)
}
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"crypto/x509"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -65,7 +65,7 @@ func (r *EtcdadmClusterReconciler) performEndpointHealthCheck(ctx context.Contex
// reuse connection
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion controllers/periodic_healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ func (r *EtcdadmClusterReconciler) periodicEtcdMembersHealthCheck(ctx context.Co
}
} else {
// member passed healthcheck. so if it was previously added to unhealthy map, remove it since only consecutive failures should lead to member removal
if _, markedUnhealthy := currClusterHFConfig.unhealthyMembersFrequency[endpoint]; markedUnhealthy {
_, markedUnhealthy := currClusterHFConfig.unhealthyMembersFrequency[endpoint]
if markedUnhealthy {
delete(currClusterHFConfig.unhealthyMembersFrequency, endpoint)
}
}
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ func main() {
var onlyOneSignalHandler = make(chan struct{})
var shutdownSignals = []os.Signal{os.Interrupt, syscall.SIGTERM}

/* Controller runtime 0.5.4 returns a stop channel and 0.7.0 onwards returns a context that can be passed down to SetupWithManager and reconcilers
/*
Controller runtime 0.5.4 returns a stop channel and 0.7.0 onwards returns a context that can be passed down to SetupWithManager and reconcilers
Because cluster-api v0.3.x uses controller-runtime 0.5.4 version, etcdadm-controller cannot switch to a higher controller-runtime due to version mismatch errors
So this function setupSignalHandler is a modified version of controller-runtime's SetupSignalHandler that returns both, a stop channel and a context that
is cancelled when this controller exits
Expand Down

0 comments on commit dd7bc8c

Please sign in to comment.