Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldwan committed Sep 22, 2023
2 parents fdee596 + f1a45f1 commit 97ec948
Show file tree
Hide file tree
Showing 118 changed files with 2,497 additions and 753 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
test_build:
runs-on: ubuntu-latest-m
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v4
Expand All @@ -22,7 +22,7 @@ jobs:
- name: "Place wintun.dll"
run: cp deps/wintun/bin/amd64/wintun.dll ./
- name: build
uses: goreleaser/goreleaser-action@v4
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: build --clean --snapshot
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
precommit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
Expand All @@ -38,7 +38,7 @@ jobs:
name: lint
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: "${{ matrix.module }}/go.mod"
Expand Down
30 changes: 15 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
os: [ ubuntu-latest-m, macos-latest-xl, windows-latest-l ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v4
Expand All @@ -30,14 +30,14 @@ jobs:
- name: "Place wintun.dll"
run: cp deps/wintun/bin/amd64/wintun.dll ./
- name: Run tests
run: make test
run: make test test-api

release:
needs: test
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'dev-')
if: startsWith(github.ref, 'refs/tags/v0.') && !contains(github.ref, 'dev-')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v4
Expand All @@ -48,12 +48,12 @@ jobs:
id: go-version
run: echo "name=version::$(go env GOVERSION)" >> $GITHUB_OUTPUT
- name: Login to Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -65,7 +65,7 @@ jobs:
mkdir -p ./tmp
./scripts/changelog.sh > ./tmp/changelog.txt
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean --release-notes=./tmp/changelog.txt
Expand All @@ -80,18 +80,18 @@ jobs:
sync_docs:
needs: release
runs-on: ubuntu-latest
if: ${{ !contains(github.ref, 'pre') }}
if: startsWith(github.ref, 'refs/tags/v0.') && !contains(github.ref, 'pre') && !contains(github.ref, 'dev-')
steps:
- name: Checkout flyctl
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: jnwng/github-app-installation-token-action@778da2ab509f3ef5e4b902bc15daf25ef3e34939
id: installationToken
with:
appId: 339363
installationId: 37947271
privateKey: ${{ secrets.DOCS_SYNCER_GITHUB_APP_PRIVATE_KEY }}
- name: Checkout docs
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: superfly/docs
token: ${{ steps.installationToken.outputs.token }}
Expand All @@ -107,10 +107,10 @@ jobs:
run: scripts/publish_docs.sh ${{ github.ref_name }}

dev_release:
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, 'dev-')
if: startsWith(github.ref, 'refs/tags/v0.') && contains(github.ref, 'dev-')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v4
Expand All @@ -127,7 +127,7 @@ jobs:
mkdir -p ./tmp
./scripts/changelog.sh > ./tmp/changelog.txt
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --config .goreleaser.dev.yml --rm-dist --release-notes=./tmp/changelog.txt
Expand All @@ -142,10 +142,10 @@ jobs:
aur-publish:
name: Build & publish to AUR
needs: release
if: ${{ !contains(github.ref, 'pre') }}
if: startsWith(github.ref, 'refs/tags/v0.') && !contains(github.ref, 'pre') && !contains(github.ref, 'dev-')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Download checksums
uses: actions/download-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/homebrew_bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
excludes: prerelease, draft
token: ${{ secrets.FLYIO_FLYCTL_BOT_GITHUB_TOKEN }}
- run: 'echo "Latest release: ${{ steps.latest_release.outputs.release }}"'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- id: version_compare
run: |
set -exo pipefail
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
parallelism: [25]
index: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preflight_cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
if: ${{ github.repository == 'superfly/flyctl' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version-file: "go.mod"
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ test: FORCE
test-api: FORCE
cd api && go test ./... --run=$(T)

test-api: FORCE
cd ./api && go test ./... -ldflags="-X 'github.com/superfly/flyctl/internal/buildinfo.buildDate=$(NOW_RFC3339)'" --run=$(T)

raw-preflight-test:
if [ -r .direnv/preflight ]; then . .direnv/preflight; fi; \
go test ./test/preflight --tags=integration -v -timeout 10m --run="$(T)"
Expand Down
4 changes: 2 additions & 2 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"net/http"
"os"
"regexp"
"slices"
"strings"
"time"

Expand Down Expand Up @@ -89,7 +88,8 @@ func (t *Transport) setDefaults(opts ClientOptions) {
if opts.EnableDebugTrace != nil {
t.EnableDebugTrace = *opts.EnableDebugTrace
} else {
t.EnableDebugTrace = !slices.Contains([]string{"", "0", "false"}, os.Getenv("FLY_FORCE_TRACE"))
v := os.Getenv("FLY_FORCE_TRACE")
t.EnableDebugTrace = !(v == "" || v == "0" || v == "false")
}
}

Expand Down
2 changes: 1 addition & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/superfly/flyctl/api

go 1.21
go 1.20

require (
github.com/Khan/genqlient v0.6.0
Expand Down
4 changes: 0 additions & 4 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -28,7 +27,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/superfly/graphql v0.2.4 h1:Av8hSk4x8WvKJ6MTnEwrLknSVSGPc7DWpgT3z/kt3PU=
github.com/superfly/graphql v0.2.4/go.mod h1:CVfDl31srm8HnJ9udwLu6hFNUW/P6GUM2dKcG1YQ8jc=
github.com/vektah/gqlparser/v2 v2.5.1 h1:ZGu+bquAY23jsxDRcYpWjttRZrUz07LbiY77gUOHcr4=
Expand All @@ -44,7 +42,6 @@ golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand All @@ -54,4 +51,3 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
58 changes: 51 additions & 7 deletions api/machine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
MachineStateStopped = "stopped"
MachineStateCreated = "created"
DefaultVMSize = "shared-cpu-1x"
DefaultGPUVMSize = "performance-8x"
)

type Machine struct {
Expand All @@ -37,13 +38,14 @@ type Machine struct {
InstanceID string `json:"instance_id,omitempty"`
Version string `json:"version,omitempty"`
// PrivateIP is the internal 6PN address of the machine.
PrivateIP string `json:"private_ip,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
Config *MachineConfig `json:"config,omitempty"`
Events []*MachineEvent `json:"events,omitempty"`
Checks []*MachineCheckStatus `json:"checks,omitempty"`
LeaseNonce string `json:"nonce,omitempty"`
PrivateIP string `json:"private_ip,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
Config *MachineConfig `json:"config,omitempty"`
Events []*MachineEvent `json:"events,omitempty"`
Checks []*MachineCheckStatus `json:"checks,omitempty"`
LeaseNonce string `json:"nonce,omitempty"`
HostDedicationID string `json:"host_dedication_id,omitempty"`
}

func (m *Machine) FullImageRef() string {
Expand Down Expand Up @@ -177,6 +179,40 @@ func (m *Machine) GetLatestEventOfTypeAfterType(latestEventType, firstEventType
return nil
}

func (m *Machine) MostRecentStartTimeAfterLaunch() (time.Time, error) {
if m == nil {
return time.Time{}, fmt.Errorf("machine is nil")
}
var (
firstStart = -1
firstLaunch = -1
firstExit = -1
)
for i, e := range m.Events {
switch e.Type {
case "start":
firstStart = i
case "launch":
firstLaunch = i
case "exit":
firstExit = i
}
if firstStart != -1 && firstLaunch != -1 {
break
}
}
switch {
case firstStart == -1:
return time.Time{}, fmt.Errorf("no start event found")
case firstStart >= firstLaunch:
return time.Time{}, fmt.Errorf("no start event found after launch")
case firstExit != -1 && firstExit <= firstStart:
return time.Time{}, fmt.Errorf("no start event found after most recent exit")
default:
return m.Events[firstStart].Time(), nil
}
}

func (m *Machine) IsReleaseCommandMachine() bool {
return m.HasProcessGroup(MachineProcessGroupFlyAppReleaseCommand) || m.Config.Metadata["process_group"] == "release_command"
}
Expand All @@ -197,6 +233,10 @@ type MachineEvent struct {
Timestamp int64 `json:"timestamp,omitempty"`
}

func (e *MachineEvent) Time() time.Time {
return time.Unix(e.Timestamp/1000, e.Timestamp%1000*1000000)
}

type MachineRequest struct {
ExitEvent *MachineExitEvent `json:"exit_event,omitempty"`
MonitorEvent *MachineMonitorEvent `json:"MonitorEvent,omitempty"`
Expand Down Expand Up @@ -282,6 +322,7 @@ type MachineGuest struct {
CPUKind string `json:"cpu_kind,omitempty"`
CPUs int `json:"cpus,omitempty"`
MemoryMB int `json:"memory_mb,omitempty"`
GPUKind string `json:"gpu_kind,omitempty"`

KernelArgs []string `json:"kernel_args,omitempty"`
}
Expand Down Expand Up @@ -538,6 +579,8 @@ type MachineConfig struct {
VMSize string `json:"size,omitempty"`
// Deprecated: use Service.Autostart instead
DisableMachineAutostart *bool `json:"disable_machine_autostart,omitempty"`

HostDedicationId string `json:"host_dedication_id,omitempty"`
}

func (c *MachineConfig) ProcessGroup() string {
Expand Down Expand Up @@ -622,6 +665,7 @@ type LaunchMachineInput struct {
Name string `json:"name,omitempty"`
SkipLaunch bool `json:"skip_launch,omitempty"`
SkipServiceRegistration bool `json:"skip_service_registration,omitempty"`
HostDedicationID string `json:"host_dedication_id,omitempty"`

LeaseTTL int `json:"lease_ttl,omitempty"`

Expand Down
Loading

0 comments on commit 97ec948

Please sign in to comment.