Skip to content

Commit

Permalink
Clean up "deprecated" variables/functions in v1alpha4
Browse files Browse the repository at this point in the history
  • Loading branch information
Evalle committed Feb 10, 2021
1 parent 6db673f commit 0979566
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 117 deletions.
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 @@ -36,18 +36,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
56 changes: 52 additions & 4 deletions test/infrastructure/docker/docker/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,62 @@ limitations under the License.

package docker

import "fmt"
import (
"fmt"
"time"

// ContainerNotRunningError is returned when trying to patch a container that is not running
type ContainerNotRunningError struct {
Name string
"github.com/pkg/errors"
)

// HasRequeueAfterError represents that an actuator managed object should
// be requeued for further processing after the given RequeueAfter time has
// passed.
//
// DEPRECATED: This error is deprecated and should not be used for new code.
// See https://github.com/kubernetes-sigs/cluster-api/issues/3370 for more information.
//
// Users should switch their methods and functions to return a (ctrl.Result, error) pair,
// instead of relying on this error. Controller runtime exposes a Result.IsZero() (from 0.5.9, and 0.6.2)
// which can be used from callers to see if reconciliation should be stopped or continue.
type HasRequeueAfterError interface {
// GetRequeueAfter gets the duration to wait until the managed object is
// requeued for further processing.
GetRequeueAfter() time.Duration
}

// RequeueAfterError represents that an actuator managed object should be
// requeued for further processing after the given RequeueAfter time has
// passed.
//
// DEPRECATED: This error is deprecated and should not be used for new code.
// See https://github.com/kubernetes-sigs/cluster-api/issues/3370 for more information.
//
// Users should switch their methods and functions to return a (ctrl.Result, error) pair,
// instead of relying on this error. Controller runtime exposes a Result.IsZero() (from 0.5.9, and 0.6.2)
// which can be used from callers to see if reconciliation should be stopped or continue.
type RequeueAfterError struct {
RequeueAfter time.Duration
}

// Error implements the error interface
func (e *RequeueAfterError) Error() string {
return fmt.Sprintf("requeue in %v", e.RequeueAfter)
}

// Error returns the error string
func (cse ContainerNotRunningError) Error() string {
return fmt.Sprintf("container with name %q is not running", cse.Name)
}

// IsRequeueAfter returns true if the error satisfies the interface HasRequeueAfterError.
//
// DEPRECATED: This error is deprecated and should not be used for new code.
// See https://github.com/kubernetes-sigs/cluster-api/issues/3370 for more information.
//
// Users should switch their methods and functions to return a (ctrl.Result, error) pair,
// instead of relying on this error. Controller runtime exposes a Result.IsZero() (from 0.5.9, and 0.6.2)
// which can be used from callers to see if reconciliation should be stopped or continue.
func IsRequeueAfter(err error) bool {
_, ok := errors.Cause(err).(HasRequeueAfterError)
return ok
}
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
71 changes: 0 additions & 71 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,12 @@ import (
"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"
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 @@ -128,24 +122,6 @@ func Ordinalize(n int) string {
return fmt.Sprintf("%d%s", n, m[an%10])
}

// ModifyImageRepository takes an imageName (e.g., repository/image:tag), and returns an image name with updated repository
// Deprecated: Please use the functions in util/container
func ModifyImageRepository(imageName, repositoryName string) (string, error) {
return container.ModifyImageRepository(imageName, repositoryName)
}

// ModifyImageTag takes an imageName (e.g., repository/image:tag), and returns an image name with updated tag
// Deprecated: Please use the functions in util/container
func ModifyImageTag(imageName, tagName string) (string, error) {
return container.ModifyImageTag(imageName, tagName)
}

// ImageTagIsValid ensures that a given image tag is compliant with the OCI spec
// Deprecated: Please use the functions in util/container
func ImageTagIsValid(tagName string) bool {
return container.ImageTagIsValid(tagName)
}

// GetMachinesForCluster returns a list of machines associated with the cluster.
func GetMachinesForCluster(ctx context.Context, c client.Client, cluster *clusterv1.Cluster) (*clusterv1.MachineList, error) {
var machines clusterv1.MachineList
Expand All @@ -162,18 +138,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 @@ -424,17 +388,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 @@ -527,16 +480,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 @@ -612,20 +555,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

0 comments on commit 0979566

Please sign in to comment.