Skip to content

Commit

Permalink
Merge pull request #3663 from telepresenceio/thallgren/login-and-make…
Browse files Browse the repository at this point in the history
…-test

Empty commit
  • Loading branch information
thallgren authored Aug 14, 2024
2 parents dd6a286 + e266326 commit bebecb1
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 40 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,29 @@ jobs:
run: |
v=$(go run build-aux/genversion/main.go ${{github.run_id}})
echo "TELEPRESENCE_VERSION=$v" >> "$GITHUB_ENV"
echo "TELEPRESENCE_SEMVER=${v#v}" >> "$GITHUB_ENV"
echo "version=$v" >> $GITHUB_OUTPUT
echo "semver=${v#v}" >> $GITHUB_OUTPUT
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Setup docker buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Build cluster images
- name: Build image dependencies
run: make images-deps
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push client image
run: |
make push-images-x
docker buildx build --platform=linux/amd64,linux/arm64 --build-arg TELEPRESENCE_VERSION=${{env.TELEPRESENCE_SEMVER}} \
--push --tag ${{env.TELEPRESENCE_REGISTRY}}/telepresence:${{env.TELEPRESENCE_SEMVER}} -f build-aux/docker/images/Dockerfile.client .
- name: Push tel2 image
run: |
docker buildx build --platform=linux/amd64,linux/arm64 --build-arg TELEPRESENCE_VERSION=${{env.TELEPRESENCE_SEMVER}} \
--push --tag ${{env.TELEPRESENCE_REGISTRY}}/tel2:${{env.TELEPRESENCE_SEMVER}} -f build-aux/docker/images/Dockerfile.traffic .
- name: Log out from registry
if: always()
run: docker logout

run_tests:
if: github.event.label.name == 'ok to test'
strategy:
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,29 @@ jobs:
name: install dependencies
- name: set version
shell: bash
run: echo "TELEPRESENCE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
run: |
v=${{ github.ref_name }}
echo "TELEPRESENCE_VERSION=$v" >> "$GITHUB_ENV"
echo "TELEPRESENCE_SEMVER=${v#v}" >> "$GITHUB_ENV"
- name: Setup docker buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Build image dependencies
run: make images-deps
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Upload Docker images
- name: Push client image
run: |
docker buildx build --platform=linux/amd64,linux/arm64 --build-arg TELEPRESENCE_VERSION=${{env.TELEPRESENCE_SEMVER}} \
--push --tag ${{env.TELEPRESENCE_REGISTRY}}/telepresence:${{env.TELEPRESENCE_SEMVER}} -f build-aux/docker/images/Dockerfile.client .
- name: Push tel2 image
run: |
make push-images-x
docker buildx build --platform=linux/amd64,linux/arm64 --build-arg TELEPRESENCE_VERSION=${{env.TELEPRESENCE_SEMVER}} \
--push --tag ${{env.TELEPRESENCE_REGISTRY}}/tel2:${{env.TELEPRESENCE_SEMVER}} -f build-aux/docker/images/Dockerfile.traffic .
- name: Log out from registry
if: always()
run: docker logout

publish-release:
runs-on: ubuntu-latest
Expand Down
36 changes: 8 additions & 28 deletions build-aux/main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -220,53 +220,33 @@ TELEPRESENCE_SEMVER=$(patsubst v%,%,$(TELEPRESENCE_VERSION))
CLIENT_IMAGE_FQN=$(TELEPRESENCE_REGISTRY)/telepresence:$(TELEPRESENCE_SEMVER)
TEL2_IMAGE_FQN=$(TELEPRESENCE_REGISTRY)/tel2:$(TELEPRESENCE_SEMVER)

.PHONY: images-deps
images-deps: build-deps setup-build-dir

.PHONY: tel2-image
tel2-image: build-deps setup-build-dir
tel2-image: images-deps
$(eval PLATFORM_ARG := $(if $(TELEPRESENCE_TEL2_IMAGE_PLATFORM), --platform=$(TELEPRESENCE_TEL2_IMAGE_PLATFORM),))
docker build $(PLATFORM_ARG) --target tel2 --tag tel2 --tag $(TEL2_IMAGE_FQN) -f build-aux/docker/images/Dockerfile.traffic .

.PHONY: tel2-image-x
tel2-image-x: build-deps setup-build-dir
docker buildx build --platform=linux/amd64,linux/arm64 --build-arg TELEPRESENCE_VERSION=$(TELEPRESENCE_VERSION) --cache-to type=local,dest=$(BUILDDIR)/docker-cache -f build-aux/docker/images/Dockerfile.traffic .

.PHONY: client-image
client-image: build-deps setup-build-dir
client-image: images-deps
docker build --target telepresence --tag telepresence --tag $(CLIENT_IMAGE_FQN) -f build-aux/docker/images/Dockerfile.client .

.PHONY: client-image-x
client-image-x: build-deps setup-build-dir
docker buildx build --platform=linux/amd64,linux/arm64 --build-arg TELEPRESENCE_VERSION=$(TELEPRESENCE_VERSION) --cache-to type=local,dest=$(BUILDDIR)/docker-cache -f build-aux/docker/images/Dockerfile.client .

.PHONY: push-tel2-image
push-tel2-image: tel2-image ## (Build) Push the manager/agent container image to $(TELEPRESENCE_REGISTRY)
docker push $(TEL2_IMAGE_FQN)

.PHONY: push-tel2-image-x
push-tel2-image-x: build-deps setup-build-dir
docker buildx build --platform=linux/amd64,linux/arm64 --build-arg TELEPRESENCE_VERSION=$(TELEPRESENCE_VERSION) --cache-from type=local,src=$(BUILDDIR)/docker-cache -f build-aux/docker/images/Dockerfile.traffic --push --tag $(TEL2_IMAGE_FQN) .

.PHONY: push-client-image
push-client-image: client-image ## (Build) Push the client container image to $(TELEPRESENCE_REGISTRY)
docker push $(CLIENT_IMAGE_FQN)

.PHONY: push-client-image-x
push-client-image-x: build-deps setup-build-dir
docker buildx build --platform=linux/amd64,linux/arm64 --build-arg TELEPRESENCE_VERSION=$(TELEPRESENCE_VERSION) --cache-from type=local,src=$(BUILDDIR)/docker-cache -f build-aux/docker/images/Dockerfile.client --push --tag $(CLIENT_IMAGE_FQN) .

.PHONY: save-tel2-image
save-tel2-image: tel2-image
docker save $(TEL2_IMAGE_FQN) > $(BUILDDIR)/tel2-image.tar

.PHONY: save-client-image
save-client-image: client-image
docker save $(CLIENT_IMAGE_FQN) > $(BUILDDIR)/telepresence-image.tar
.PHONY: push-client-image
push-client-image: client-image ## (Build) Push the client container image to $(TELEPRESENCE_REGISTRY)
docker push $(CLIENT_IMAGE_FQN)

.PHONY: push-images
push-images: push-tel2-image push-client-image

.PHONY: push-images-x
push-images-x: push-tel2-image-x push-client-image-x

.PHONY: clobber
clobber: ## (Build) Remove all build artifacts and tools
rm -rf $(BUILDDIR)
Expand Down
8 changes: 6 additions & 2 deletions cmd/traffic/cmd/manager/state/intercept.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ func (s *state) waitForAgent(ctx context.Context, name, namespace string, failed
return agent.Name == name && agent.Namespace == namespace
})
failedContainerRx := regexp.MustCompile(`restarting failed container (\S+) in pod ([0-9A-Za-z_-]+)_` + namespace)
mm := mutator.GetMap(ctx)

// fes collects events from the failedCreatedCh and is included in the error message in case
// the waitForAgent call times out.
var fes []*events.Event
Expand Down Expand Up @@ -451,8 +453,10 @@ func (s *state) waitForAgent(ctx context.Context, name, namespace string, failed
return status.Error(codes.Canceled, fmt.Sprintf("channel closed while waiting for agent %s.%s to arrive", name, namespace))
}
for _, a := range snapshot.State {
dlog.Debugf(ctx, "Agent %s.%s is ready", a.Name, a.Namespace)
return nil
if !mm.IsBlacklisted(a.PodName, a.Namespace) {
dlog.Debugf(ctx, "Agent %s.%s is ready", a.Name, a.Namespace)
return nil
}
}
dlog.Debugf(ctx, "Got empty snapshot while waiting for agent %s.%s", name, namespace)
case <-ctx.Done():
Expand Down
32 changes: 29 additions & 3 deletions integration_test/itest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"time"
"unicode/utf8"

"github.com/cenkalti/backoff/v4"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -1014,11 +1015,22 @@ func Kubectl(ctx context.Context, namespace string, args ...string) error {
} else {
ks = args
}
return Run(ctx, "kubectl", ks...)
b := backoff.NewExponentialBackOff(
backoff.WithInitialInterval(2*time.Second),
backoff.WithMaxInterval(7*time.Second),
backoff.WithMaxElapsedTime(30*time.Second),
)
return backoff.Retry(func() error {
err := Run(ctx, "kubectl", ks...)
if err != nil && !strings.Contains(err.Error(), "(ServiceUnavailable)") {
err = backoff.Permanent(err)
}
return err
}, b)
}

// KubectlOut runs kubectl with the default context and the application namespace and returns its combined output.
func KubectlOut(ctx context.Context, namespace string, args ...string) (string, error) {
func KubectlOut(ctx context.Context, namespace string, args ...string) (out string, err error) {
getT(ctx).Helper()
var ks []string
if namespace != "" {
Expand All @@ -1027,7 +1039,20 @@ func KubectlOut(ctx context.Context, namespace string, args ...string) (string,
} else {
ks = args
}
return Output(ctx, "kubectl", ks...)
b := backoff.NewExponentialBackOff(
backoff.WithInitialInterval(2*time.Second),
backoff.WithMaxInterval(7*time.Second),
backoff.WithMaxElapsedTime(30*time.Second),
)
err = backoff.Retry(func() error {
var bErr error
out, bErr = Output(ctx, "kubectl", ks...)
if bErr != nil && !strings.Contains(bErr.Error(), "(ServiceUnavailable)") {
bErr = backoff.Permanent(bErr)
}
return bErr
}, b)
return out, err
}

func CreateNamespaces(ctx context.Context, namespaces ...string) {
Expand Down Expand Up @@ -1108,6 +1133,7 @@ func PingInterceptedEchoServer(ctx context.Context, svc, svcPort string, headers
dlog.Info(ctx, err)
return false
}
ips = iputil.UniqueSorted(ips)
if len(ips) != 1 {
dlog.Infof(ctx, "Lookup for %s returned %v", svc, ips)
return false
Expand Down

0 comments on commit bebecb1

Please sign in to comment.