Skip to content

Commit

Permalink
Merge pull request #24 from spectrocloud/revert-22-PPD-1435
Browse files Browse the repository at this point in the history
Revert "PPD-1435: Upgrade CAPVC"
  • Loading branch information
a-kad authored Jul 2, 2024
2 parents fccbc1d + 4974aa5 commit 656833c
Show file tree
Hide file tree
Showing 10 changed files with 778 additions and 286 deletions.
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ WORKDIR /workspace

# Copy binaries
COPY ${HELM} helm
COPY --from=thirdparty /binaries/helm/latest/$BIN_TYPE/$TARGETARCH/helm /binaries/helm
COPY --from=thirdparty /binaries/helm/latest/$BIN_TYPE/$TARGETARCH/helm helm
COPY ${HELM_CHART} vcluster-0.18.1.tgz

COPY ${HELM_CHART} vcluster-0.16.4.tgz

# Install Delve for debugging
RUN if [ "${TARGETARCH}" = "amd64" ]; then go install github.com/go-delve/delve/cmd/dlv@latest; fi
Expand Down Expand Up @@ -45,7 +43,7 @@ FROM --platform=linux/amd64 gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
COPY --from=builder /workspace/helm .
COPY --from=builder /workspace/vcluster-0.18.1.tgz .
COPY --from=builder /workspace/vcluster-0.16.4.tgz .
USER 65532:65532

ENTRYPOINT ["/manager"]
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BUILD_ARGS = --build-arg CRYPTO_LIB=${FIPS_ENABLE} --build-arg BUILDER_GOLANG_VE
ENVTEST_K8S_VERSION = 1.23
# HELM_VERSION = 3.12.0
HELM_VERSION = 3.11.2-20230627
VCLUSTER_CHART_VERSION = 0.18.1
VCLUSTER_CHART_VERSION = 0.16.4

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -180,6 +180,8 @@ release: manifests kustomize ## Builds the manifests to publish with a release.
.PHONY: binaries
binaries: download-chart ## Download binaries

HELM=$(BIN_DIR)/helm-$(GOOS)-$(GOARCH)

.PHONY: download-chart
download-chart: bin-dir ## Download vcluster chart
helm repo add loft https://charts.loft.sh
Expand Down
15 changes: 7 additions & 8 deletions api/v1alpha1/vcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package v1alpha1

import (
"fmt"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -34,25 +33,25 @@ func (r *VCluster) Default() {
}

// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
func (r *VCluster) ValidateCreate() (admission.Warnings, error) {
func (r *VCluster) ValidateCreate() error {
vclusterlog.Info("validate create", "name", r.Name)
return nil, nil
return nil
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *VCluster) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
func (r *VCluster) ValidateUpdate(old runtime.Object) error {
vclusterlog.Info("validate update", "name", r.Name)
oldVcluster := old.(*VCluster)

if r.Name != oldVcluster.Name {
return nil, apierrors.NewBadRequest(fmt.Sprintf("vcluster name change is not allowed, old=%s, new=%s", oldVcluster.Name, r.Name))
return apierrors.NewBadRequest(fmt.Sprintf("vcluster name change is not allowed, old=%s, new=%s", oldVcluster.Name, r.Name))
}

return nil, nil
return nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *VCluster) ValidateDelete() (admission.Warnings, error) {
func (r *VCluster) ValidateDelete() error {
vclusterlog.Info("validate delete", "name", r.Name)
return nil, nil
return nil
}
7 changes: 5 additions & 2 deletions api/v1alpha1/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"k8s.io/client-go/rest"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/envtest"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
)
Expand All @@ -34,8 +36,9 @@ var cancel context.CancelFunc
func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)

RunSpecs(t,
"Webhook Suite")
RunSpecsWithDefaultAndCustomReporters(t,
"Webhook Suite",
[]Reporter{printer.NewlineReporter{}})
}

var _ = BeforeSuite(func() {
Expand Down
10 changes: 5 additions & 5 deletions controllers/vcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"strings"
"time"

"github.com/loft-sh/log"
"github.com/loft-sh/utils/pkg/log"
vconstants "github.com/loft-sh/vcluster/pkg/constants"
"github.com/loft-sh/vcluster/pkg/lifecycle"
"github.com/loft-sh/vcluster/pkg/util"
Expand Down Expand Up @@ -62,7 +62,7 @@ type VClusterReconciler struct {
*kubernetes.Clientset
HelmClient helm.Client
HelmSecrets *helm.Secrets
Log log.BaseLogger
Log log.Logger
Scheme *runtime.Scheme
clusterKindExists bool
}
Expand Down Expand Up @@ -247,10 +247,10 @@ func (r *VClusterReconciler) pauseIfNeeded(ctx context.Context, vCluster *v1alph
return nil
}

if err := lifecycle.PauseVCluster(ctx, r.Clientset, vCluster.Name, vCluster.Namespace, r.Log); err != nil {
if err := lifecycle.PauseVCluster(r.Clientset, vCluster.Name, vCluster.Namespace, r.Log); err != nil {
return err
}
if err := lifecycle.DeleteVClusterWorkloads(ctx, r.Clientset, "vcluster.loft.sh/managed-by="+vCluster.Name, vCluster.Namespace, r.Log); err != nil {
if err := lifecycle.DeleteVClusterWorkloads(r.Clientset, "vcluster.loft.sh/managed-by="+vCluster.Name, vCluster.Namespace, r.Log); err != nil {
return err
}

Expand All @@ -265,7 +265,7 @@ func (r *VClusterReconciler) resumeIfNeeded(ctx context.Context, vCluster *v1alp
return nil
}

if err := lifecycle.ResumeVCluster(ctx, r.Clientset, vCluster.Name, vCluster.Namespace, r.Log); err != nil {
if err := lifecycle.ResumeVCluster(r.Clientset, vCluster.Name, vCluster.Namespace, r.Log); err != nil {
return err
}

Expand Down
168 changes: 97 additions & 71 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,126 +6,152 @@ toolchain go1.22.2

require (
github.com/ghodss/yaml v1.0.0
github.com/go-logr/logr v1.4.1
github.com/google/go-cmp v0.6.0
github.com/loft-sh/log v0.0.0-20240219160058-26d83ffb46ac
github.com/loft-sh/utils v0.0.29
github.com/loft-sh/vcluster v0.19.5
github.com/google/go-cmp v0.5.9
github.com/loft-sh/utils v0.0.13-alpha
github.com/loft-sh/vcluster v0.13.0-alpha.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.30.0
github.com/onsi/gomega v1.23.0
github.com/pkg/errors v0.9.1
k8s.io/api v0.29.1
k8s.io/apimachinery v0.29.1
k8s.io/apiserver v0.29.1
k8s.io/client-go v0.29.1
k8s.io/klog/v2 v2.120.1
sigs.k8s.io/cluster-api v1.6.3
sigs.k8s.io/controller-runtime v0.17.0
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.1
k8s.io/apiserver v0.25.2
k8s.io/client-go v0.25.6
k8s.io/klog/v2 v2.80.1
sigs.k8s.io/cluster-api v1.1.3
sigs.k8s.io/controller-runtime v0.13.0
)

require (
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
github.com/fvbommel/sortorder v1.1.0 // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/fvbommel/sortorder v1.0.1 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/jonboulle/clockwork v0.4.0 // indirect
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/xlab/treeprint v1.2.0 // indirect
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
k8s.io/cli-runtime v0.29.1 // indirect
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect
sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3 // indirect
github.com/russross/blackfriday v1.5.2 // indirect
github.com/xlab/treeprint v1.1.0 // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
k8s.io/cli-runtime v0.25.6 // indirect
sigs.k8s.io/kustomize/api v0.12.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect
)

require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/fatih/camelcase v1.0.0 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
github.com/go-openapi/swag v0.22.7 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/cobra v1.4.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
k8s.io/kubectl v0.29.1 // indirect
k8s.io/kubectl v0.25.2 // indirect
)

require (
github.com/AlecAivazis/survey/v2 v2.3.7 // indirect
github.com/Sytten/logrus-zap-hook v0.1.0 // indirect
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
cloud.google.com/go v0.97.0 // indirect
github.com/AlecAivazis/survey/v2 v2.3.6 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.27 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.20 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.2 // indirect
github.com/evanphx/json-patch v5.8.1+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.8.1 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/zapr v1.2.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.46.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.33.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd // indirect
golang.org/x/net v0.3.1-0.20221206200815-1e63c2f08a10 // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.29.1 // indirect
k8s.io/component-base v0.29.1 // indirect
k8s.io/kube-openapi v0.0.0-20240117194847-208609032b15 // indirect
k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
k8s.io/apiextensions-apiserver v0.25.2 // indirect
k8s.io/component-base v0.25.6 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

// address incompatibility between github.com/kubernetes/cli-runtime v0.26.1 and latest kustomize release
replace (
sigs.k8s.io/kustomize/api => sigs.k8s.io/kustomize/api v0.12.1
sigs.k8s.io/kustomize/kyaml => sigs.k8s.io/kustomize/kyaml v0.13.9
)

// address incompatibility between sigs.k8s.io/cluster-api v1.3.3 and latest k8s release
replace (
k8s.io/api => k8s.io/api v0.25.6
k8s.io/apimachinery => k8s.io/apimachinery v0.25.6
k8s.io/apiserver => k8s.io/apiserver v0.25.6
k8s.io/cli-runtime => k8s.io/cli-runtime v0.25.6
k8s.io/client-go => k8s.io/client-go v0.25.6
k8s.io/kubectl => k8s.io/kubectl v0.25.6
)

// address incompatibility between k8s.io/cli-runtime v0.25.6 and latest controller-runtime release
replace sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.13.1

// PRISMA-2022-0227
replace github.com/emicklei/go-restful/v3 => github.com/emicklei/go-restful/v3 v3.10.0

// CVE-2022-41723, CVE-2022-41723
replace golang.org/x/net => golang.org/x/net v0.7.0

replace github.com/loft-sh/vcluster => github.com/spectrocloud/vcluster v0.13.0-alpha.0-spectro-20221213
Loading

0 comments on commit 656833c

Please sign in to comment.