Skip to content
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
36 changes: 23 additions & 13 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ steps:
- cd $WORKSPACE_DIR/go/src/github.com/gravitational/teleport
- build.assets/build-fido2-macos.sh build
- export PKG_CONFIG_PATH="$(build.assets/build-fido2-macos.sh pkg_config_path)"
- make clean release OS=$OS ARCH=$ARCH FIDO2=yes TOUCHID=yes LIBPCSCLITE=yes
- make clean release OS=$OS ARCH=$ARCH FIDO2=yes TOUCHID=yes
- export VERSION=$(make -C $WORKSPACE_DIR/go/src/github.com/gravitational/teleport
print-version)
- export BUILD_NUMBER=$DRONE_BUILD_NUMBER
Expand Down Expand Up @@ -3823,7 +3823,7 @@ steps:
- cd $WORKSPACE_DIR/go/src/github.com/gravitational/teleport
- build.assets/build-fido2-macos.sh build
- export PKG_CONFIG_PATH="$(build.assets/build-fido2-macos.sh pkg_config_path)"
- make clean release OS=$OS ARCH=$ARCH FIDO2=yes TOUCHID=yes LIBPCSCLITE=yes
- make clean release OS=$OS ARCH=$ARCH FIDO2=yes TOUCHID=yes
environment:
ARCH: amd64
BUILDBOX_PASSWORD:
Expand Down Expand Up @@ -6104,16 +6104,21 @@ steps:
- name: Check out code
image: alpine/git:latest
commands:
- mkdir -p "/go/src/github.com/gravitational/teleport"
- mkdir -pv "/go/src/github.com/gravitational/teleport"
- cd "/go/src/github.com/gravitational/teleport"
- git clone https://github.com/gravitational/${DRONE_REPO_NAME}.git .
- git checkout "${DRONE_TAG}"
- git init && git remote add origin ${DRONE_REMOTE_URL}
- git fetch origin --tags
- git checkout -qf "${DRONE_TAG}"
depends_on:
- Verify build is tagged
- name: Check if tag is prerelease
image: golang:1.17-alpine
image: golang:1.18-alpine
commands:
- cd "/go/src/github.com/gravitational/teleport/build.assets/tooling"
- go run ./cmd/check -tag ${DRONE_TAG} -check prerelease || (echo '---> This is
a prerelease, not publishing ${DRONE_TAG} packages to APT repos' && exit 78)
a prerelease, not continuing promotion for ${DRONE_TAG}' && exit 78)
depends_on:
- Check out code
- name: Download artifacts for "${DRONE_TAG}"
image: amazon/aws-cli
commands:
Expand Down Expand Up @@ -6241,16 +6246,21 @@ steps:
- name: Check out code
image: alpine/git:latest
commands:
- mkdir -p "/go/src/github.com/gravitational/teleport"
- mkdir -pv "/go/src/github.com/gravitational/teleport"
- cd "/go/src/github.com/gravitational/teleport"
- git clone https://github.com/gravitational/${DRONE_REPO_NAME}.git .
- git checkout "${DRONE_TAG}"
- git init && git remote add origin ${DRONE_REMOTE_URL}
- git fetch origin --tags
- git checkout -qf "${DRONE_TAG}"
depends_on:
- Verify build is tagged
- name: Check if tag is prerelease
image: golang:1.17-alpine
image: golang:1.18-alpine
commands:
- cd "/go/src/github.com/gravitational/teleport/build.assets/tooling"
- go run ./cmd/check -tag ${DRONE_TAG} -check prerelease || (echo '---> This is
a prerelease, not publishing ${DRONE_TAG} packages to APT repos' && exit 78)
a prerelease, not continuing promotion for ${DRONE_TAG}' && exit 78)
depends_on:
- Check out code
- name: Download artifacts for "${DRONE_TAG}"
image: amazon/aws-cli
commands:
Expand Down Expand Up @@ -7202,6 +7212,6 @@ steps:
WORKSPACE_DIR: /tmp/build-darwin-amd64-connect
---
kind: signature
hmac: 707c836fc9c2d0b3ee8074d258b3723651a6e53dcada5b5fcf0417b10f455b45
hmac: 65e2f6af8da82eac69c036051504edb6a9e175e2175bfe4ac40631c6dbf58a79

...
29 changes: 29 additions & 0 deletions build.assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,32 @@ Or simply copy the binary out of the image using a volume (it will be copied to
```
docker run -v $(pwd)/build:/builds -it teleportbuilder cp /gopath/src/github.com/gravitational/teleport/teleport.tgz /builds
```

# OS package repo migrations

An OS package repo migration is semi-manually publishing specific releases to the new APT and YUM repos. This is required in several situations:
* A customer requests that we add an older version to the repos
* We add another OS package repo (for example APK)
* A OS package promotion fails (for example https://drone.platform.teleport.sh/gravitational/teleport/14666/1/3), requires a PR to fix, and we don't want to cut another minor version

Multiple migrations can be performed at once. To run a migration do the following:
1. Clone https://github.com/gravitational/teleport.git.
2. Change to the directory the repo was cloned to.
3. Create a new branch from master.
4. Add the Teleport versions you wish to migration as demonstrated here: https://github.com/gravitational/teleport/commit/151a2f489e3116fc7ce8f55e056529361d3233a6#diff-2e3a64c97d186491e06fb2c7ead081b7ace2b67c4a4d974a563daf7c117a2c50.
5. Set the `migrationBranch` variable to the name of the branch you created in (3) as demonstrated here: https://github.com/gravitational/teleport/commit/151a2f489e3116fc7ce8f55e056529361d3233a6#diff-2e3a64c97d186491e06fb2c7ead081b7ace2b67c4a4d974a563daf7c117a2c50.
6. Get your Drone credentials from here: https://drone.platform.teleport.sh/account.
7. Export your drone credentials as shown under "Example CLI Usage" on the Drone account page
8. Open a new terminal.
9. Run `tsh app login drone` and follow any prompts.
10. Run `tsh proxy app drone` and copy the printed socket. This should look something like `127.0.0.1:60982`
11. Switch back to your previous terminal.
12. Run `export DRONE_SERVER=http://{host:port}`, replacing `{host:port}` with the data you copied in (10)
13. Run `make dronegen`
14. Commit the two changed files and push/publish the branch
15. Open a PR merging your changes into master via https://github.com/gravitational/teleport/compare
16. Under the "checks" section, click "details" on the check labeled "continuous-integration/drone/push"
17. Once the pipelines complete, comment out the versions you added and blank out the `migrationBranch` string set in (4, 5) as demonstrated here: https://github.com/gravitational/teleport/pull/15531/commits/9095880560cfe6c93e491e39a7604b1faf72c600#diff-2e3a64c97d186491e06fb2c7ead081b7ace2b67c4a4d974a563daf7c117a2c50
18. Run `make dronegen`
19. Commit and push the changes.
20. Merge the PR and backport if required.
54 changes: 54 additions & 0 deletions dronegen/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"log"
"os/exec"
"path"
"strings"
)

Expand Down Expand Up @@ -96,6 +97,16 @@ func pushTriggerForBranch(branches ...string) trigger {
return t
}

func cloneRepoCommands(cloneDirectory, commit string) []string {
return []string{
fmt.Sprintf("mkdir -pv %q", cloneDirectory),
fmt.Sprintf("cd %q", cloneDirectory),
`git init && git remote add origin ${DRONE_REMOTE_URL}`,
`git fetch origin --tags`,
fmt.Sprintf("git checkout -qf %q", commit),
}
}

type buildType struct {
os string
arch string
Expand Down Expand Up @@ -243,3 +254,46 @@ func waitForDockerStep() step {
Volumes: dockerVolumeRefs(),
}
}

func verifyValidPromoteRunSteps(checkoutPath, commit string, isParallelismEnabled bool) []step {
tagStep := verifyTaggedStep()
cloneStep := cloneRepoStep(checkoutPath, commit)
verifyStep := verifyNotPrereleaseStep(checkoutPath)

if isParallelismEnabled {
cloneStep.DependsOn = []string{tagStep.Name}
verifyStep.DependsOn = []string{cloneStep.Name}
}

return []step{tagStep, cloneStep, verifyStep}
}

func verifyTaggedStep() step {
return step{
Name: "Verify build is tagged",
Image: "alpine:latest",
Commands: []string{
"[ -n ${DRONE_TAG} ] || (echo 'DRONE_TAG is not set. Is the commit tagged?' && exit 1)",
},
}
}

// Note that tags are also valid here as a tag refers to a specific commit
func cloneRepoStep(clonePath, commit string) step {
return step{
Name: "Check out code",
Image: "alpine/git:latest",
Commands: cloneRepoCommands(clonePath, commit),
}
}

func verifyNotPrereleaseStep(checkoutPath string) step {
return step{
Name: "Check if tag is prerelease",
Image: "golang:1.18-alpine",
Commands: []string{
fmt.Sprintf("cd %q", path.Join(checkoutPath, "build.assets", "tooling")),
"go run ./cmd/check -tag ${DRONE_TAG} -check prerelease || (echo '---> This is a prerelease, not continuing promotion for ${DRONE_TAG}' && exit 78)",
},
}
}
24 changes: 4 additions & 20 deletions dronegen/os_repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ func artifactMigrationPipeline() []pipeline {
// "v9.3.10",
// "v9.3.12",
// "v9.3.13",
// "v9.3.14",
// "v10.0.0",
// "v10.0.1",
// "v10.0.2",
// "v10.1.2",
// "v10.1.4",
}
// Pushing to this branch will trigger the listed versions to be migrated. Typically this should be
// the branch that these changes are being committed to.
Expand Down Expand Up @@ -192,26 +195,7 @@ func (optpb *OsPackageToolPipelineBuilder) buildPromoteOsPackagePipeline() pipel
p.Trigger = triggerPromote
p.Trigger.Repo.Include = []string{"gravitational/teleport"}

setupSteps := []step{
{
Name: "Verify build is tagged",
Image: "alpine:latest",
Commands: []string{
"[ -n ${DRONE_TAG} ] || (echo 'DRONE_TAG is not set. Is the commit tagged?' && exit 1)",
},
},
}
setupSteps = append(setupSteps, p.Steps...)
setupSteps = append(setupSteps,
step{
Name: "Check if tag is prerelease",
Image: "golang:1.17-alpine",
Commands: []string{
fmt.Sprintf("cd %q", path.Join(checkoutPath, "build.assets", "tooling")),
"go run ./cmd/check -tag ${DRONE_TAG} -check prerelease || (echo '---> This is a prerelease, not publishing ${DRONE_TAG} packages to APT repos' && exit 78)",
},
},
)
setupSteps := verifyValidPromoteRunSteps(checkoutPath, commitName, true)

setupStepNames := make([]string, 0, len(setupSteps))
for _, setupStep := range setupSteps {
Expand Down