Skip to content

Commit

Permalink
Minor cosmetics (gardener#7791)
Browse files Browse the repository at this point in the history
* Add the kubeapiserver commands for admissionplugins only if they are present

Not related to this PR

Co-Authored-By: Ashish Ranjan Yadav <[email protected]>
Co-Authored-By: Sonu Kumar Singh <[email protected]>

* Fix wrong spelling and repeated words

Co-Authored-By: Ashish Ranjan Yadav <[email protected]>
Co-Authored-By: Sonu Kumar Singh <[email protected]>

* Fix `unnecessary type arguments` error for sets

Co-Authored-By: Ashish Ranjan Yadav <[email protected]>
Co-Authored-By: Sonu Kumar Singh <[email protected]>

* Replace usages of `sets.NewString` with `sets.New[string]`

Co-Authored-By: Ashish Ranjan Yadav <[email protected]>
Co-Authored-By: Sonu Kumar Singh <[email protected]>

* Remove duplicate imports

Co-Authored-By: Ashish Ranjan Yadav <[email protected]>
Co-Authored-By: Sonu Kumar Singh <[email protected]>

---------

Co-authored-by: Ashish Ranjan Yadav <[email protected]>
Co-authored-by: Sonu Kumar Singh <[email protected]>
  • Loading branch information
3 people authored Apr 14, 2023
1 parent 7b57432 commit f8ace4c
Show file tree
Hide file tree
Showing 76 changed files with 160 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
resourcePolicy:
containerPolicies:
# Due to CVE-2019-5736 runC is initially loaded into memory when the container starts.
# After some time VPA recommends less memory (2,3Mb) than the size of of runC binary (about 10Mb).
# After some time VPA recommends less memory (2,3Mb) than the size of runC binary (about 10Mb).
# This results in an error when trying to start the container:
# failed to write 2485760 to memory.limit_in_bytes in /sys/fs/cgroup/memory/kubepods/prometheus-config-reloader/memory.limit_in_bytes: device or resource busy
# https://github.com/lxc/lxc/commit/6400238d08cdf1ca20d49bafb85f4e224348bf9d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@
"dashLength": 10,
"dashes": false,
"datasource": null,
"description": "The amount of of failures when the `apiserver-proxy` tries to connect to the upstream Shoot Kube API Server",
"description": "The amount of failures when the `apiserver-proxy` tries to connect to the upstream Shoot Kube API Server",
"fieldConfig": {
"defaults": {
"custom": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@
"refId": "A"
}
],
"title": "Drill down to to Pod Dashboard",
"title": "Drill down to Pod Dashboard",
"transform": "timeseries_to_rows",
"type": "table"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@
"refId": "A"
}
],
"title": "Drill down to to Pod Dashboard",
"title": "Drill down to Pod Dashboard",
"transform": "timeseries_to_rows",
"type": "table-old"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@
"refId": "A"
}
],
"title": "Drill down to to Pod Dashboard",
"title": "Drill down to Pod Dashboard",
"transform": "timeseries_to_rows",
"type": "table-old"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dashLength": 10,
"dashes": false,
"datasource": null,
"description": "Traffic for all VPN tunnels of all VPN clients of all all Kube-apiservers pods",
"description": "Traffic for all VPN tunnels of all VPN clients of all Kube-apiservers pods",
"fieldConfig": {
"defaults": {},
"overrides": []
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -4544,7 +4544,7 @@ string
</td>
<td>
<em>(Optional)</em>
<p>Location is the time location in which both start and and shall be evaluated.</p>
<p>Location is the time location in which both start and shall be evaluated.</p>
</td>
</tr>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/control_plane_migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Also, the involved Seeds need to have enabled `BackupBucket`s.

## Shoot Control Plane Migration

Triggering the migration is done by changing the `Shoot`'s `.spec.seedName` to a `Seed` that differs from the `.status.seedName`, we call this `Seed` a `"Destination Seed"`. This action can only be performed by an operator with the necessary RBAC. If the Destination `Seed` does not have a backup and restore configuration, the the change to `spec.seedName` is rejected. Additionally, this Seed must not be set for deletion and must be healthy.
Triggering the migration is done by changing the `Shoot`'s `.spec.seedName` to a `Seed` that differs from the `.status.seedName`, we call this `Seed` a `"Destination Seed"`. This action can only be performed by an operator with the necessary RBAC. If the Destination `Seed` does not have a backup and restore configuration, the change to `spec.seedName` is rejected. Additionally, this Seed must not be set for deletion and must be healthy.

If the `Shoot` has different `.spec.seedName` and `.status.seedName`, a process is started to prepare the Control Plane for migration:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
policies.kyverno.io/category: Other
policies.kyverno.io/subject: Pod
policies.kyverno.io/description: >-
Locally built Gardener images are pushed to a container registry on the the seed.
Locally built Gardener images are pushed to a container registry on the seed.
This registry requires an imagePullSecret, which cannot to gardener components by gardener itself.
spec:
failurePolicy: Ignore
Expand Down
4 changes: 2 additions & 2 deletions extensions/pkg/controller/cmd/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ func (m *ManagerOptions) AddFlags(fs *pflag.FlagSet) {

// Complete implements Completer.Complete.
func (m *ManagerOptions) Complete() error {
if !sets.New[string](logger.AllLogLevels...).Has(m.LogLevel) {
if !sets.New(logger.AllLogLevels...).Has(m.LogLevel) {
return fmt.Errorf("invalid --%s: %s", LogLevelFlag, m.LogLevel)
}

if !sets.New[string](logger.AllLogFormats...).Has(m.LogFormat) {
if !sets.New(logger.AllLogFormats...).Has(m.LogFormat) {
return fmt.Errorf("invalid --%s: %s", LogFormatFlag, m.LogFormat)
}

Expand Down
2 changes: 1 addition & 1 deletion extensions/pkg/terraformer/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (t *terraformer) GetStateOutputVariables(ctx context.Context, variables ...
var (
output = make(map[string]string)

wantedVariables = sets.New[string](variables...)
wantedVariables = sets.New(variables...)
foundVariables = sets.New[string]()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import (
func ValidateAdmissionControllerConfiguration(config *admissioncontrollerconfig.AdmissionControllerConfiguration) field.ErrorList {
allErrs := field.ErrorList{}

if !sets.New[string](logger.AllLogLevels...).Has(config.LogLevel) {
if !sets.New(logger.AllLogLevels...).Has(config.LogLevel) {
allErrs = append(allErrs, field.NotSupported(field.NewPath("logLevel"), config.LogLevel, logger.AllLogLevels))
}
if !sets.New[string](logger.AllLogFormats...).Has(config.LogFormat) {
if !sets.New(logger.AllLogFormats...).Has(config.LogFormat) {
allErrs = append(allErrs, field.NotSupported(field.NewPath("logFormat"), config.LogFormat, logger.AllLogFormats))
}

Expand All @@ -45,13 +45,13 @@ func ValidateAdmissionControllerConfiguration(config *admissioncontrollerconfig.
// ValidateResourceAdmissionConfiguration validates the given `ResourceAdmissionConfiguration`.
func validateResourceAdmissionConfiguration(config *admissioncontrollerconfig.ResourceAdmissionConfiguration, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
validValues := sets.New[string](string(admissioncontrollerconfig.AdmissionModeBlock), string(admissioncontrollerconfig.AdmissionModeLog))
validValues := sets.New(string(admissioncontrollerconfig.AdmissionModeBlock), string(admissioncontrollerconfig.AdmissionModeLog))

if config.OperationMode != nil && !validValues.Has(string(*config.OperationMode)) {
allErrs = append(allErrs, field.NotSupported(fldPath.Child("mode"), string(*config.OperationMode), validValues.UnsortedList()))
}

allowedSubjectKinds := sets.New[string](rbacv1.UserKind, rbacv1.GroupKind, rbacv1.ServiceAccountKind)
allowedSubjectKinds := sets.New(rbacv1.UserKind, rbacv1.GroupKind, rbacv1.ServiceAccountKind)

for i, subject := range config.UnrestrictedSubjects {
fld := fldPath.Child("unrestrictedSubjects").Index(i)
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/authentication/types_adminkubeconfigrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type AdminKubeconfigRequest struct {
type AdminKubeconfigRequestStatus struct {
// Kubeconfig contains the kubeconfig with cluster-admin privileges for the shoot cluster.
Kubeconfig []byte
// ExpirationTimestamp is the expiration timestamp of of the returned credential.
// ExpirationTimestamp is the expiration timestamp of the returned credential.
ExpirationTimestamp metav1.Time
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/core/helper/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func SecretBindingHasType(secretBinding *core.SecretBinding, providerType string
return false
}

return sets.New[string](types...).Has(providerType)
return sets.New(types...).Has(providerType)
}

// GetAllZonesFromShoot returns the set of all availability zones defined in the worker pools of the Shoot specification.
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/core/types_shoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ type HibernationSchedule struct {
Start *string
// End is a Cron spec at which time a Shoot will be woken up.
End *string
// Location is the time location in which both start and and shall be evaluated.
// Location is the time location in which both start and shall be evaluated.
Location *string
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/core/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/apis/core/v1alpha1/types_shoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ type HibernationSchedule struct {
// End is a Cron spec at which time a Shoot will be woken up.
// +optional
End *string `json:"end,omitempty" protobuf:"bytes,2,opt,name=end"`
// Location is the time location in which both start and and shall be evaluated.
// Location is the time location in which both start and shall be evaluated.
// +optional
Location *string `json:"location,omitempty" protobuf:"bytes,3,opt,name=location"`
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/core/v1beta1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/apis/core/v1beta1/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ func SecretBindingHasType(secretBinding *gardencorev1beta1.SecretBinding, provid
return false
}

return sets.New[string](types...).Has(providerType)
return sets.New(types...).Has(providerType)
}

// AddTypeToSecretBinding adds the given provider type to the SecretBinding.
Expand All @@ -1103,7 +1103,7 @@ func AddTypeToSecretBinding(secretBinding *gardencorev1beta1.SecretBinding, prov
}

types := GetSecretBindingTypes(secretBinding)
if !sets.New[string](types...).Has(providerType) {
if !sets.New(types...).Has(providerType) {
types = append(types, providerType)
}
secretBinding.Provider.Type = strings.Join(types, ",")
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/core/v1beta1/types_shoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ type HibernationSchedule struct {
// End is a Cron spec at which time a Shoot will be woken up.
// +optional
End *string `json:"end,omitempty" protobuf:"bytes,2,opt,name=end"`
// Location is the time location in which both start and and shall be evaluated.
// Location is the time location in which both start and shall be evaluated.
// +optional
Location *string `json:"location,omitempty" protobuf:"bytes,3,opt,name=location"`
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/core/validation/cloudprofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func validateKubernetesSettings(kubernetes core.KubernetesSettings, fldPath *fie
return allErrs
}

var supportedVersionClassifications = sets.New[string](string(core.ClassificationPreview), string(core.ClassificationSupported), string(core.ClassificationDeprecated))
var supportedVersionClassifications = sets.New(string(core.ClassificationPreview), string(core.ClassificationSupported), string(core.ClassificationDeprecated))

func validateExpirableVersion(version core.ExpirableVersion, allVersions []core.ExpirableVersion, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/core/validation/controllerregistration.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ import (
gardenerutils "github.com/gardener/gardener/pkg/utils/gardener"
)

var availablePolicies = sets.New[string](
var availablePolicies = sets.New(
string(core.ControllerDeploymentPolicyOnDemand),
string(core.ControllerDeploymentPolicyAlways),
string(core.ControllerDeploymentPolicyAlwaysExceptNoShoots),
)

var availableExtensionStrategies = sets.New[string](
var availableExtensionStrategies = sets.New(
string(core.BeforeKubeAPIServer),
string(core.AfterKubeAPIServer),
)
Expand All @@ -52,7 +52,7 @@ func ValidateControllerRegistration(controllerRegistration *core.ControllerRegis
}

// SupportedExtensionKinds contains all supported extension kinds.
var SupportedExtensionKinds = sets.New[string](
var SupportedExtensionKinds = sets.New(
extensionsv1alpha1.BackupBucketResource,
extensionsv1alpha1.BackupEntryResource,
extensionsv1alpha1.BastionResource,
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/core/validation/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func ValidateSubject(subject rbacv1.Subject, fldPath *field.Path) field.ErrorLis
return allErrs
}

var supportedRoles = sets.New[string](
var supportedRoles = sets.New(
core.ProjectMemberOwner,
core.ProjectMemberAdmin,
core.ProjectMemberViewer,
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/core/validation/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import (
)

var (
availableIngressKinds = sets.New[string](
availableIngressKinds = sets.New(
v1beta1constants.IngressKindNginx,
)
availableExternalTrafficPolicies = sets.New[string](
availableExternalTrafficPolicies = sets.New(
string(corev1.ServiceExternalTrafficPolicyTypeCluster),
string(corev1.ServiceExternalTrafficPolicyTypeLocal),
)
Expand Down Expand Up @@ -168,7 +168,7 @@ func ValidateSeedSpec(seedSpec *core.SeedSpec, fldPath *field.Path, inTemplate b
allErrs = append(allErrs, field.Forbidden(fldPath.Child("settings", "loadBalancerServices", "zones"), "zone-specific load balancer settings only allowed with at least two zones in spec.provider.zones"))
}

zones := sets.New[string](seedSpec.Provider.Zones...)
zones := sets.New(seedSpec.Provider.Zones...)
specifiedZones := sets.New[string]()

for i, zoneSettings := range seedSpec.Settings.LoadBalancerServices.Zones {
Expand Down
28 changes: 14 additions & 14 deletions pkg/apis/core/validation/shoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,64 +54,64 @@ import (
)

var (
availableProxyModes = sets.New[string](
availableProxyModes = sets.New(
string(core.ProxyModeIPTables),
string(core.ProxyModeIPVS),
)
availableKubernetesDashboardAuthenticationModes = sets.New[string](
availableKubernetesDashboardAuthenticationModes = sets.New(
core.KubernetesDashboardAuthModeToken,
)
availableNginxIngressExternalTrafficPolicies = sets.New[string](
availableNginxIngressExternalTrafficPolicies = sets.New(
string(corev1.ServiceExternalTrafficPolicyTypeCluster),
string(corev1.ServiceExternalTrafficPolicyTypeLocal),
)
availableShootOperations = sets.New[string](
availableShootOperations = sets.New(
v1beta1constants.ShootOperationMaintain,
v1beta1constants.ShootOperationRetry,
).Union(availableShootMaintenanceOperations)
availableShootMaintenanceOperations = sets.New[string](
availableShootMaintenanceOperations = sets.New(
v1beta1constants.GardenerOperationReconcile,
v1beta1constants.OperationRotateCAStart,
v1beta1constants.OperationRotateCAComplete,
v1beta1constants.ShootOperationRotateKubeconfigCredentials,
v1beta1constants.ShootOperationRotateObservabilityCredentials,
v1beta1constants.ShootOperationRotateSSHKeypair,
).Union(forbiddenShootOperationsWhenHibernated)
forbiddenShootOperationsWhenHibernated = sets.New[string](
forbiddenShootOperationsWhenHibernated = sets.New(
v1beta1constants.OperationRotateCredentialsStart,
v1beta1constants.OperationRotateCredentialsComplete,
v1beta1constants.OperationRotateETCDEncryptionKeyStart,
v1beta1constants.OperationRotateETCDEncryptionKeyComplete,
v1beta1constants.OperationRotateServiceAccountKeyStart,
v1beta1constants.OperationRotateServiceAccountKeyComplete,
)
availableShootPurposes = sets.New[string](
availableShootPurposes = sets.New(
string(core.ShootPurposeEvaluation),
string(core.ShootPurposeTesting),
string(core.ShootPurposeDevelopment),
string(core.ShootPurposeProduction),
)
availableWorkerCRINames = sets.New[string](
availableWorkerCRINames = sets.New(
string(core.CRINameContainerD),
string(core.CRINameDocker),
)
availableClusterAutoscalerExpanderModes = sets.New[string](
availableClusterAutoscalerExpanderModes = sets.New(
string(core.ClusterAutoscalerExpanderLeastWaste),
string(core.ClusterAutoscalerExpanderMostPods),
string(core.ClusterAutoscalerExpanderPriority),
string(core.ClusterAutoscalerExpanderRandom),
)
availableCoreDNSAutoscalingModes = sets.New[string](
availableCoreDNSAutoscalingModes = sets.New(
string(core.CoreDNSAutoscalingModeClusterProportional),
string(core.CoreDNSAutoscalingModeHorizontal),
)
availableSchedulingProfiles = sets.New[string](
availableSchedulingProfiles = sets.New(
string(core.SchedulingProfileBalanced),
string(core.SchedulingProfileBinPacking),
)

// asymmetric algorithms from https://datatracker.ietf.org/doc/html/rfc7518#section-3.1
availableOIDCSigningAlgs = sets.New[string](
availableOIDCSigningAlgs = sets.New(
"RS256",
"RS384",
"RS512",
Expand Down Expand Up @@ -238,7 +238,7 @@ func ValidateShootSpec(meta metav1.ObjectMeta, spec *core.ShootSpec, fldPath *fi
if purpose := spec.Purpose; purpose != nil {
allowedShootPurposes := availableShootPurposes
if meta.Namespace == v1beta1constants.GardenNamespace || inTemplate {
allowedShootPurposes = sets.New[string](append(sets.List(availableShootPurposes), string(core.ShootPurposeInfrastructure))...)
allowedShootPurposes = sets.New(append(sets.List(availableShootPurposes), string(core.ShootPurposeInfrastructure))...)
}

if !allowedShootPurposes.Has(string(*purpose)) {
Expand Down Expand Up @@ -1491,7 +1491,7 @@ func validateKubeletConfigReserved(reserved *core.KubeletConfigReserved, fldPath
return allErrs
}

var reservedTaintKeys = sets.NewString(v1beta1constants.TaintNodeCriticalComponentsNotReady)
var reservedTaintKeys = sets.New(v1beta1constants.TaintNodeCriticalComponentsNotReady)

func validateClusterAutoscalerIgnoreTaints(ignoredTaints []string, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/core/validation/shoot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5589,7 +5589,7 @@ var _ = Describe("Shoot Validation Tests", func() {
Entry("invalid spec", sets.New[string](), "foo", ConsistOf(PointTo(MatchFields(IgnoreExtras, Fields{
"Type": Equal(field.ErrorTypeInvalid),
})))),
Entry("duplicate spec", sets.New[string]("* * * * *"), "* * * * *", ConsistOf(PointTo(MatchFields(IgnoreExtras, Fields{
Entry("duplicate spec", sets.New("* * * * *"), "* * * * *", ConsistOf(PointTo(MatchFields(IgnoreExtras, Fields{
"Type": Equal(field.ErrorTypeDuplicate),
})))),
)
Expand Down
Loading

0 comments on commit f8ace4c

Please sign in to comment.