Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️ Clean up "deprecated" variables/functions in v1alpha4 #4078

Merged
merged 1 commit into from
Mar 12, 2021
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
10 changes: 0 additions & 10 deletions bootstrap/kubeadm/api/v1alpha4/condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ const (
// the KubeadmConfig controller ensure this pre-condition is satisfied.
WaitingForClusterInfrastructureReason = "WaitingForClusterInfrastructure"

// WaitingForControlPlaneAvailableReason (Severity=Info) document a bootstrap secret generation process
// waiting for the control plane machine to be available.
//
// NOTE: Having the control plane machine available is a pre-condition for joining additional control planes
// or workers nodes.
// DEPRECATED: This has been deprecated in v1alpha3 and will be removed in a future version.
// Switch to WaitingForControlPlaneAvailableReason constant from the `sigs.k8s.io/cluster-api/api/v1alpha3`
// package.
WaitingForControlPlaneAvailableReason = clusterv1.WaitingForControlPlaneAvailableReason

// DataSecretGenerationFailedReason (Severity=Warning) documents a KubeadmConfig controller detecting
// an error while generating a data secret; those kind of errors are usually due to misconfigurations
// and user intervention is required to get them fixed.
Expand Down
12 changes: 0 additions & 12 deletions controllers/machinehealthcheck_targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ import (
const (
// Event types

// EventSkippedControlPlane is emitted in case an unhealthy node (or a machine
// associated with the node) has the `control-plane` role
// Deprecated: no longer in use
EventSkippedControlPlane string = "SkippedControlPlane"
// EventMachineDeletionFailed is emitted in case remediation of a machine
// is required but deletion of its Machine object failed
// Deprecated: no longer in use
EventMachineDeletionFailed string = "MachineDeletionFailed"
// EventMachineDeleted is emitted when machine was successfully remediated
// by deleting its Machine object
// Deprecated: no longer in use
EventMachineDeleted string = "MachineDeleted"
// EventMachineMarkedUnhealthy is emitted when machine was successfully marked as unhealthy
EventMachineMarkedUnhealthy string = "MachineMarkedUnhealthy"
// EventDetectedUnhealthy is emitted in case a node associated with a
Expand Down
5 changes: 0 additions & 5 deletions hack/tools/release/notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ func run() int {
key = warning
body = strings.TrimPrefix(body, ":warning:")
body = strings.TrimPrefix(body, "⚠️")
case strings.HasPrefix(body, ":running:"), strings.HasPrefix(body, "🏃"):
// This has been deprecated in favor of :seedling:
key = other
body = strings.TrimPrefix(body, ":running:")
body = strings.TrimPrefix(body, "🏃")
default:
key = unknown
}
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/envtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func (t *TestEnvironment) Stop() error {
}

func (t *TestEnvironment) CreateKubeconfigSecret(ctx context.Context, cluster *clusterv1.Cluster) error {
return kubeconfig.CreateEnvTestSecret(ctx, t.Client, t.Config, cluster)
return t.Create(ctx, kubeconfig.GenerateSecret(cluster, kubeconfig.FromEnvTestConfig(t.Config, cluster)))
}

func (t *TestEnvironment) Cleanup(ctx context.Context, objs ...client.Object) error {
Expand Down
7 changes: 0 additions & 7 deletions util/kubeconfig/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,14 @@ limitations under the License.
package kubeconfig

import (
"context"
"fmt"

"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha4"
"sigs.k8s.io/controller-runtime/pkg/client"
)

// Deprecated: use test/helpers/envtest
func CreateEnvTestSecret(ctx context.Context, client client.Client, cfg *rest.Config, cluster *clusterv1.Cluster) error {
return client.Create(ctx, GenerateSecret(cluster, FromEnvTestConfig(cfg, cluster)))
}

func FromEnvTestConfig(cfg *rest.Config, cluster *clusterv1.Cluster) []byte {
contextName := fmt.Sprintf("%s@%s", cfg.Username, cluster.Name)
c := api.Config{
Expand Down
8 changes: 0 additions & 8 deletions util/secret/certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,6 @@ func NewCertificatesForInitialControlPlane(config *v1beta1.ClusterConfiguration)
return certificates
}

// NewCertificatesForJoiningControlPlane gets any certs that exist and writes them to disk
//
// Deprecated: this method is deprecated in favor of NewControlPlaneJoinCerts that
// provides full support for the external etcd scenario.
func NewCertificatesForJoiningControlPlane() Certificates {
return NewControlPlaneJoinCerts(nil)
}

// NewControlPlaneJoinCerts gets any certs that exist and writes them to disk
func NewControlPlaneJoinCerts(config *v1beta1.ClusterConfiguration) Certificates {
certificatesDir := DefaultCertificatesDir
Expand Down
7 changes: 0 additions & 7 deletions util/secret/certificates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ import (
"sigs.k8s.io/cluster-api/util/secret"
)

func TestNewCertificatesForJoiningControlPlane_Stacked(t *testing.T) {
g := NewWithT(t)

certs := secret.NewCertificatesForJoiningControlPlane()
g.Expect(certs.GetByPurpose(secret.EtcdCA).KeyFile).NotTo(BeEmpty())
}

func TesNewControlPlaneJoinCerts_Stacked(t *testing.T) {
g := NewWithT(t)

Expand Down
52 changes: 0 additions & 52 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,14 @@ import (
k8sversion "k8s.io/apimachinery/pkg/version"
"k8s.io/client-go/metadata"
"k8s.io/client-go/rest"
"k8s.io/klog/klogr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha4"
"sigs.k8s.io/cluster-api/util/annotations"
"sigs.k8s.io/cluster-api/util/container"
"sigs.k8s.io/cluster-api/util/predicates"
"sigs.k8s.io/cluster-api/util/version"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
)

const (
Expand Down Expand Up @@ -141,18 +136,6 @@ func GetMachinesForCluster(ctx context.Context, c client.Client, cluster *cluste
return &machines, nil
}

// SemverToOCIImageTag is a helper function that replaces all
// non-allowed symbols in tag strings with underscores.
// Image tag can only contain lowercase and uppercase letters, digits,
// underscores, periods and dashes.
// Current usage is for CI images where all of symbols except '+' are valid,
// but function is for generic usage where input can't be always pre-validated.
// Taken from k8s.io/cmd/kubeadm/app/util
// Deprecated: Please use the functions in util/container
func SemverToOCIImageTag(version string) string {
return container.SemverToOCIImageTag(version)
}

// GetControlPlaneMachines returns a slice containing control plane machines.
func GetControlPlaneMachines(machines []*clusterv1.Machine) (res []*clusterv1.Machine) {
for _, machine := range machines {
Expand Down Expand Up @@ -403,17 +386,6 @@ func indexOwnerRef(ownerReferences []metav1.OwnerReference, ref metav1.OwnerRefe
return -1
}

// PointsTo returns true if any of the owner references point to the given target
// Deprecated: Use IsOwnedByObject to cover differences in API version or backup/restore that changed UIDs.
func PointsTo(refs []metav1.OwnerReference, target *metav1.ObjectMeta) bool {
for _, ref := range refs {
if ref.UID == target.UID {
return true
}
}
return false
}

// IsOwnedByObject returns true if any of the owner references point to the given target.
func IsOwnedByObject(obj metav1.Object, target client.Object) bool {
for _, ref := range obj.GetOwnerReferences() {
Expand Down Expand Up @@ -506,16 +478,6 @@ func HasOwner(refList []metav1.OwnerReference, apiVersion string, kinds []string
return false
}

var (
// IsPaused returns true if the Cluster is paused or the object has the `paused` annotation.
// Deprecated: use util/annotations/IsPaused instead
IsPaused = annotations.IsPaused

// HasPausedAnnotation returns true if the object has the `paused` annotation.
// Deprecated: use util/annotations/HasPausedAnnotation instead
HasPausedAnnotation = annotations.HasPausedAnnotation
)

// GetCRDWithContract retrieves a list of CustomResourceDefinitions from using controller-runtime Client,
// filtering with the `contract` label passed in.
// Returns the first CRD in the list that matches the GroupVersionKind, otherwise returns an error.
Expand Down Expand Up @@ -591,20 +553,6 @@ func (o MachinesByCreationTimestamp) Less(i, j int) bool {
return o[i].CreationTimestamp.Before(&o[j].CreationTimestamp)
}

// WatchOnClusterPaused adds a conditional watch to the controlled given as input
// that sends watch notifications on any create or delete, and only updates
// that toggle Cluster.Spec.Cluster.
// Deprecated: Instead add the Watch directly and use predicates.ClusterUnpaused or
// predicates.ClusterUnpausedAndInfrastructureReady depending on your use case.
func WatchOnClusterPaused(c controller.Controller, fn handler.MapFunc) error {
log := klogr.New().WithName("WatchOnClusterPaused")
return c.Watch(
&source.Kind{Type: &clusterv1.Cluster{}},
handler.EnqueueRequestsFromMapFunc(fn),
predicates.ClusterUnpaused(log),
)
}

// ClusterToObjectsMapper returns a mapper function that gets a cluster and lists all objects for the object passed in
// and returns a list of requests.
// NB: The objects are required to have `clusterv1.ClusterLabelName` applied.
Expand Down