Skip to content

Commit 878ee0f

Browse files
committed
Package update
1 parent a0cd2d7 commit 878ee0f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+205
-243
lines changed

cmd/configure.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/goccy/go-json"
1717
"github.com/spf13/cobra"
1818

19-
"github.com/pterodactyl/wings/config"
19+
"github.com/kubectyl/kuber/config"
2020
)
2121

2222
var configureArgs struct {

cmd/diagnostics.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import (
2020
"github.com/goccy/go-json"
2121
"github.com/spf13/cobra"
2222

23-
"github.com/pterodactyl/wings/config"
24-
"github.com/pterodactyl/wings/loggers/cli"
25-
"github.com/pterodactyl/wings/system"
23+
"github.com/kubectyl/kuber/config"
24+
"github.com/kubectyl/kuber/loggers/cli"
25+
"github.com/kubectyl/kuber/system"
2626
)
2727

2828
const (

environment/allocations.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
"github.com/docker/go-connections/nat"
88

9-
"github.com/pterodactyl/wings/config"
9+
"github.com/kubectyl/kuber/config"
1010
)
1111

1212
// Defines the allocations available for a given server. When using the Docker environment

environment/environment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66
"time"
77

8-
"github.com/pterodactyl/wings/events"
8+
"github.com/kubectyl/kuber/events"
99
)
1010

1111
const (

environment/kubernetes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package environment
22

33
import (
4-
"github.com/pterodactyl/wings/config"
4+
"github.com/kubectyl/kuber/config"
55
"k8s.io/client-go/kubernetes"
66
"k8s.io/client-go/rest"
77
)

environment/kubernetes/container.go

+41-26
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package docker
1+
package kubernetes
22

33
import (
44
"bufio"
@@ -21,9 +21,9 @@ import (
2121
"k8s.io/client-go/kubernetes/scheme"
2222
"k8s.io/client-go/tools/remotecommand"
2323

24-
"github.com/pterodactyl/wings/config"
25-
"github.com/pterodactyl/wings/environment"
26-
"github.com/pterodactyl/wings/system"
24+
"github.com/kubectyl/kuber/config"
25+
"github.com/kubectyl/kuber/environment"
26+
"github.com/kubectyl/kuber/system"
2727
)
2828

2929
var ErrNotAttached = errors.Sentinel("not attached to instance")
@@ -145,33 +145,48 @@ func (e *Environment) Attach(ctx context.Context) error {
145145
// fly for individual instances.
146146

147147
func (e *Environment) InSituUpdate() error {
148-
// ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
149-
// defer cancel()
150-
151-
// if _, err := e.ContainerInspect(ctx); err != nil {
152-
// // If the container doesn't exist for some reason there really isn't anything
153-
// // we can do to fix that in this process (it doesn't make sense at least). In those
154-
// // cases just return without doing anything since we still want to save the configuration
155-
// // to the disk.
156-
// //
157-
// // We'll let a boot process make modifications to the container if needed at this point.
158-
// if client.IsErrNotFound(err) {
159-
// return nil
160-
// }
161-
// return errors.Wrap(err, "environment/docker: could not inspect container")
162-
// }
148+
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
149+
defer cancel()
150+
151+
if _, err := e.client.CoreV1().Pods(config.Get().System.Namespace).Get(ctx, e.Id, metav1.GetOptions{}); err != nil {
152+
// If the pod doesn't exist for some reason there really isn't anything
153+
// we can do to fix that in this process (it doesn't make sense at least). In those
154+
// cases just return without doing anything since we still want to save the configuration
155+
// to the disk.
156+
//
157+
// We'll let a boot process make modifications to the pod if needed at this point.
158+
if apierrors.IsNotFound(err) {
159+
return nil
160+
}
161+
return errors.Wrap(err, "environment/docker: could not get pod")
162+
} else {
163+
// resources := e.Configuration.Limits()
164+
// Resources:
165+
// corev1.ResourceRequirements{
166+
// Limits: corev1.ResourceList{
167+
// "cpu": *resource.NewQuantity(resources.CpuLimit/100, resource.DecimalSI),
168+
// "memory": *resource.NewQuantity(resources.BoundedMemoryLimit(), resource.BinarySI),
169+
// },
170+
// Requests: corev1.ResourceList{
171+
// "cpu": *resource.NewQuantity(resources.CpuLimit/100, resource.DecimalSI),
172+
// "memory": *resource.NewQuantity(resources.BoundedMemoryLimit(), resource.BinarySI),
173+
// },
174+
// },
175+
// pod.Spec.Containers[0].Resources.Limits.Cpu() = append()
176+
// pod.Spec.Containers[0].Resources.Requests[v1.ResourceCPU] = *resource.NewQuantity(resources.CpuLimit*10, resource.DecimalSI)
177+
}
163178

164179
// CPU pinning cannot be removed once it is applied to a container. The same is true
165180
// for removing memory limits, a container must be re-created.
166-
//
181+
167182
// @see https://github.com/moby/moby/issues/41946
168183

169-
// if _, err := e.client.ContainerUpdate(ctx, e.Id, container.UpdateConfig{
170-
// Resources: e.Configuration.Limits().AsContainerResources(),
171-
// }); err != nil {
172-
//
173-
// return errors.Wrap(err, "environment/docker: could not update container")
174-
// }
184+
// if _, err := e.client.ContainerUpdate(ctx, e.Id, container.UpdateConfig{
185+
// Resources: e.Configuration.Limits().AsContainerResources(),
186+
// }); err != nil {
187+
// return errors.Wrap(err, "environment/docker: could not update container")
188+
// }
189+
175190
return nil
176191
}
177192

environment/kubernetes/environment.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package docker
1+
package kubernetes
22

33
import (
44
"context"
@@ -14,11 +14,11 @@ import (
1414
"k8s.io/client-go/kubernetes"
1515
"k8s.io/client-go/rest"
1616

17-
"github.com/pterodactyl/wings/config"
18-
"github.com/pterodactyl/wings/environment"
19-
"github.com/pterodactyl/wings/events"
20-
"github.com/pterodactyl/wings/remote"
21-
"github.com/pterodactyl/wings/system"
17+
"github.com/kubectyl/kuber/config"
18+
"github.com/kubectyl/kuber/environment"
19+
"github.com/kubectyl/kuber/events"
20+
"github.com/kubectyl/kuber/remote"
21+
"github.com/kubectyl/kuber/system"
2222
)
2323

2424
type Metadata struct {
@@ -174,10 +174,12 @@ func (e *Environment) ExitState() (uint32, bool, error) {
174174
return 0, false, err
175175
}
176176

177-
if c.Status.Phase != v1.PodRunning {
177+
// Still checking if the pod is running because sometimes crash detection is buggy
178+
if c.Status.Phase != v1.PodRunning && len(c.Status.ContainerStatuses) != 0 {
178179
if c.Status.ContainerStatuses[0].State.Terminated.ExitCode == 137 {
179180
return 137, true, nil
180181
}
182+
181183
return uint32(c.Status.ContainerStatuses[0].State.Terminated.ExitCode), false, nil
182184
}
183185
return 1, false, nil

environment/kubernetes/power.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package docker
1+
package kubernetes
22

33
import (
44
"context"
@@ -15,9 +15,9 @@ import (
1515
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1616
"k8s.io/apimachinery/pkg/util/wait"
1717

18-
"github.com/pterodactyl/wings/config"
19-
"github.com/pterodactyl/wings/environment"
20-
"github.com/pterodactyl/wings/remote"
18+
"github.com/kubectyl/kuber/config"
19+
"github.com/kubectyl/kuber/environment"
20+
"github.com/kubectyl/kuber/remote"
2121
)
2222

2323
// OnBeforeStart run before the container starts and get the process

environment/kubernetes/stats.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package docker
1+
package kubernetes
22

33
import (
44
"context"
@@ -10,8 +10,8 @@ import (
1010
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1111
metrics "k8s.io/metrics/pkg/client/clientset/versioned"
1212

13-
"github.com/pterodactyl/wings/config"
14-
"github.com/pterodactyl/wings/environment"
13+
"github.com/kubectyl/kuber/config"
14+
"github.com/kubectyl/kuber/environment"
1515
)
1616

1717
// Uptime returns the current uptime of the container in milliseconds. If the

environment/settings.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/apex/log"
99
"github.com/docker/docker/api/types/container"
1010

11-
"github.com/pterodactyl/wings/config"
11+
"github.com/kubectyl/kuber/config"
1212
)
1313

1414
type Mount struct {

events/events.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"emperror.dev/errors"
77
"github.com/goccy/go-json"
88

9-
"github.com/pterodactyl/wings/system"
9+
"github.com/kubectyl/kuber/system"
1010
)
1111

1212
// Event represents an Event sent over a Bus.

go.mod

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/pterodactyl/wings
1+
module github.com/kubectyl/kuber
22

33
go 1.18
44

@@ -38,7 +38,6 @@ require (
3838
github.com/mholt/archiver/v4 v4.0.0-alpha.7
3939
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
4040
github.com/patrickmn/go-cache v2.1.0+incompatible
41-
github.com/pkg/sftp v1.13.5
4241
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
4342
github.com/spf13/cobra v1.5.0
4443
github.com/stretchr/testify v1.8.0
@@ -78,19 +77,13 @@ require (
7877
)
7978

8079
require (
81-
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
8280
github.com/Microsoft/go-winio v0.6.0 // indirect
8381
github.com/Microsoft/hcsshim v0.9.4 // indirect
8482
github.com/andybalholm/brotli v1.0.4 // indirect
85-
github.com/beorn7/perks v1.0.1 // indirect
86-
github.com/cespare/xxhash/v2 v2.1.2 // indirect
87-
github.com/containerd/fifo v1.0.0 // indirect
8883
github.com/davecgh/go-spew v1.1.1 // indirect
8984
github.com/docker/distribution v2.8.1+incompatible // indirect
90-
github.com/docker/go-metrics v0.0.1 // indirect
9185
github.com/docker/go-units v0.5.0 // indirect
9286
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
93-
github.com/fsnotify/fsnotify v1.5.4 // indirect
9487
github.com/gammazero/deque v0.2.0 // indirect
9588
github.com/gin-contrib/sse v0.1.0 // indirect
9689
github.com/glebarez/go-sqlite v1.19.1 // indirect
@@ -105,27 +98,20 @@ require (
10598
github.com/jinzhu/now v1.1.5 // indirect
10699
github.com/json-iterator/go v1.1.12 // indirect
107100
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
108-
github.com/kr/fs v0.1.0 // indirect
109101
github.com/leodido/go-urn v1.2.1 // indirect
110102
github.com/magefile/mage v1.14.0 // indirect
111103
github.com/mattn/go-isatty v0.0.16 // indirect
112-
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
113104
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
114105
github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae // indirect
115106
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
116107
github.com/modern-go/reflect2 v1.0.2 // indirect
117-
github.com/morikuni/aec v1.0.0 // indirect
118108
github.com/nwaples/rardecode/v2 v2.0.0-beta.2 // indirect
119109
github.com/opencontainers/go-digest v1.0.0 // indirect
120110
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
121111
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
122112
github.com/pierrec/lz4/v4 v4.1.17 // indirect
123113
github.com/pkg/errors v0.9.1 // indirect
124114
github.com/pmezard/go-difflib v1.0.0 // indirect
125-
github.com/prometheus/client_golang v1.13.0 // indirect
126-
github.com/prometheus/client_model v0.2.0 // indirect
127-
github.com/prometheus/common v0.37.0 // indirect
128-
github.com/prometheus/procfs v0.8.0 // indirect
129115
github.com/remyoudompheng/bigfft v0.0.0-20220927061507-ef77025ab5aa // indirect
130116
github.com/robfig/cron/v3 v3.0.1 // indirect
131117
github.com/sirupsen/logrus v1.9.0 // indirect

0 commit comments

Comments
 (0)