diff --git a/.golangci.yaml b/.golangci.yaml index e701c219..18aae962 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -77,8 +77,8 @@ linters: # - gochecknoinits # checks that no init functions are present in Go code # - goconst # finds repeated strings that could be replaced by a constant - gocritic # provides diagnostics that check for bugs, performance and style issues - # - godot # checks if comments end in a period - # - goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt + - godot # checks if comments end in a period + - goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt # - gomnd # detects magic numbers - gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod - gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations @@ -110,7 +110,7 @@ linters: # - unparam # reports unused function parameters - usestdlibvars # detects the possibility to use variables/constants from the Go standard library - wastedassign # finds wasted assignment statements - # - whitespace # detects leading and trailing whitespace + - whitespace # detects leading and trailing whitespace # - wrapcheck # checks that errors returned from external packages are wrapped # - wsl # add or remove empty lines diff --git a/api/v1/chyt_types.go b/api/v1/chyt_types.go index ab66c8a8..45cd6888 100644 --- a/api/v1/chyt_types.go +++ b/api/v1/chyt_types.go @@ -34,7 +34,7 @@ const ( ChytReleaseStatusFinished ChytReleaseStatus = "Finished" ) -// ChytSpec defines the desired state of Chyt +// ChytSpec defines the desired state of Chyt. type ChytSpec struct { ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"` @@ -44,7 +44,7 @@ type ChytSpec struct { MakeDefault bool `json:"makeDefault"` } -// ChytStatus defines the observed state of Chyt +// ChytStatus defines the observed state of Chyt. type ChytStatus struct { Conditions []metav1.Condition `json:"conditions,omitempty"` ReleaseStatus ChytReleaseStatus `json:"releaseStatus,omitempty"` @@ -54,7 +54,7 @@ type ChytStatus struct { // +kubebuilder:printcolumn:name="ReleaseStatus",type="string",JSONPath=".status.releaseStatus",description="Status of release" //+kubebuilder:subresource:status -// Chyt is the Schema for the chyts API +// Chyt is the Schema for the chyts API. type Chyt struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -65,7 +65,7 @@ type Chyt struct { //+kubebuilder:object:root=true -// ChytList contains a list of Chyt +// ChytList contains a list of Chyt. type ChytList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/api/v1/chyt_webhook.go b/api/v1/chyt_webhook.go index df3d5b5d..e126ed4e 100644 --- a/api/v1/chyt_webhook.go +++ b/api/v1/chyt_webhook.go @@ -39,7 +39,7 @@ func (r *Chyt) SetupWebhookWithManager(mgr ctrl.Manager) error { var _ webhook.Defaulter = &Chyt{} -// Default implements webhook.Defaulter so a webhook will be registered for the type +// Default implements webhook.Defaulter so a webhook will be registered for the type. func (r *Chyt) Default() { chytlog.Info("default", "name", r.Name) @@ -51,7 +51,7 @@ func (r *Chyt) Default() { var _ webhook.Validator = &Chyt{} -// ValidateCreate implements webhook.Validator so a webhook will be registered for the type +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. func (r *Chyt) ValidateCreate() (admission.Warnings, error) { chytlog.Info("validate create", "name", r.Name) @@ -59,7 +59,7 @@ func (r *Chyt) ValidateCreate() (admission.Warnings, error) { return nil, nil } -// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. func (r *Chyt) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { chytlog.Info("validate update", "name", r.Name) @@ -67,7 +67,7 @@ func (r *Chyt) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { return nil, nil } -// ValidateDelete implements webhook.Validator so a webhook will be registered for the type +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. func (r *Chyt) ValidateDelete() (admission.Warnings, error) { chytlog.Info("validate delete", "name", r.Name) diff --git a/api/v1/groupversion_info.go b/api/v1/groupversion_info.go index 52400ae8..59694e20 100644 --- a/api/v1/groupversion_info.go +++ b/api/v1/groupversion_info.go @@ -25,10 +25,10 @@ import ( ) var ( - // GroupVersion is group version used to register these objects + // GroupVersion is group version used to register these objects. GroupVersion = schema.GroupVersion{Group: "cluster.ytsaurus.tech", Version: "v1"} - // SchemeBuilder is used to add go types to the GroupVersionKind scheme + // SchemeBuilder is used to add go types to the GroupVersionKind scheme. SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} // AddToScheme adds the types in this group-version to the given scheme. diff --git a/api/v1/remoteexecnodes_types.go b/api/v1/remoteexecnodes_types.go index 6845c574..da178396 100644 --- a/api/v1/remoteexecnodes_types.go +++ b/api/v1/remoteexecnodes_types.go @@ -24,7 +24,7 @@ import ( // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. -// RemoteExecNodesSpec defines the desired state of RemoteExecNodes +// RemoteExecNodesSpec defines the desired state of RemoteExecNodes. type RemoteExecNodesSpec struct { // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster // Important: Run "make" to regenerate code after modifying this file @@ -41,7 +41,7 @@ const ( RemoteExecNodeReleaseStatusRunning RemoteExecNodeReleaseStatus = "Running" ) -// RemoteExecNodesStatus defines the observed state of RemoteExecNodes +// RemoteExecNodesStatus defines the observed state of RemoteExecNodes. type RemoteExecNodesStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster // Important: Run "make" to regenerate code after modifying this file @@ -52,7 +52,7 @@ type RemoteExecNodesStatus struct { //+kubebuilder:printcolumn:name="ReleaseStatus",type="string",JSONPath=".status.releaseStatus",description="Release status" //+kubebuilder:subresource:status -// RemoteExecNodes is the Schema for the remoteexecnodes API +// RemoteExecNodes is the Schema for the remoteexecnodes API. type RemoteExecNodes struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -63,7 +63,7 @@ type RemoteExecNodes struct { //+kubebuilder:object:root=true -// RemoteExecNodesList contains a list of RemoteExecNodes +// RemoteExecNodesList contains a list of RemoteExecNodes. type RemoteExecNodesList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/api/v1/remoteytsaurus_types.go b/api/v1/remoteytsaurus_types.go index 7c2e5e33..39859647 100644 --- a/api/v1/remoteytsaurus_types.go +++ b/api/v1/remoteytsaurus_types.go @@ -23,7 +23,7 @@ import ( // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. -// RemoteYtsaurusSpec defines the desired state of RemoteYtsaurus +// RemoteYtsaurusSpec defines the desired state of RemoteYtsaurus. type RemoteYtsaurusSpec struct { // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster // Important: Run "make" to regenerate code after modifying this file @@ -32,7 +32,7 @@ type RemoteYtsaurusSpec struct { MasterCachesSpec `json:",inline"` } -// RemoteYtsaurusStatus defines the observed state of RemoteYtsaurus +// RemoteYtsaurusStatus defines the observed state of RemoteYtsaurus. type RemoteYtsaurusStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster // Important: Run "make" to regenerate code after modifying this file @@ -42,7 +42,7 @@ type RemoteYtsaurusStatus struct { //+kubebuilder:resource:path=remoteytsaurus //+kubebuilder:subresource:status -// RemoteYtsaurus is the Schema for the remoteytsauruses API +// RemoteYtsaurus is the Schema for the remoteytsauruses API. type RemoteYtsaurus struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -53,7 +53,7 @@ type RemoteYtsaurus struct { //+kubebuilder:object:root=true -// RemoteYtsaurusList contains a list of RemoteYtsaurus +// RemoteYtsaurusList contains a list of RemoteYtsaurus. type RemoteYtsaurusList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/api/v1/spyt_types.go b/api/v1/spyt_types.go index b9c7b5f5..aaa863e2 100644 --- a/api/v1/spyt_types.go +++ b/api/v1/spyt_types.go @@ -33,7 +33,7 @@ const ( SpytReleaseStatusFinished SpytReleaseStatus = "Finished" ) -// SpytSpec defines the desired state of Spyt +// SpytSpec defines the desired state of Spyt. type SpytSpec struct { ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"` @@ -41,7 +41,7 @@ type SpytSpec struct { Image string `json:"image,omitempty"` } -// SpytStatus defines the observed state of Spyt +// SpytStatus defines the observed state of Spyt. type SpytStatus struct { Conditions []metav1.Condition `json:"conditions,omitempty"` ReleaseStatus SpytReleaseStatus `json:"releaseStatus,omitempty"` @@ -55,7 +55,7 @@ type SpytStatus struct { // +kubebuilder:printcolumn:name="ReleaseStatus",type="string",JSONPath=".status.releaseStatus",description="Status of release" //+kubebuilder:subresource:status -// Spyt is the Schema for the spyts API +// Spyt is the Schema for the spyts API. type Spyt struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -65,7 +65,7 @@ type Spyt struct { //+kubebuilder:object:root=true -// SpytList contains a list of Spyt +// SpytList contains a list of Spyt. type SpytList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/api/v1/spyt_webhook.go b/api/v1/spyt_webhook.go index 520b455d..1bf0cacf 100644 --- a/api/v1/spyt_webhook.go +++ b/api/v1/spyt_webhook.go @@ -39,7 +39,7 @@ func (r *Spyt) SetupWebhookWithManager(mgr ctrl.Manager) error { var _ webhook.Defaulter = &Spyt{} -// Default implements webhook.Defaulter so a webhook will be registered for the type +// Default implements webhook.Defaulter so a webhook will be registered for the type. func (r *Spyt) Default() { spytlog.Info("default", "name", r.Name) @@ -51,7 +51,7 @@ func (r *Spyt) Default() { var _ webhook.Validator = &Spyt{} -// ValidateCreate implements webhook.Validator so a webhook will be registered for the type +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. func (r *Spyt) ValidateCreate() (admission.Warnings, error) { spytlog.Info("validate create", "name", r.Name) @@ -59,7 +59,7 @@ func (r *Spyt) ValidateCreate() (admission.Warnings, error) { return nil, nil } -// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. func (r *Spyt) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { spytlog.Info("validate update", "name", r.Name) @@ -67,7 +67,7 @@ func (r *Spyt) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { return nil, nil } -// ValidateDelete implements webhook.Validator so a webhook will be registered for the type +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. func (r *Spyt) ValidateDelete() (admission.Warnings, error) { spytlog.Info("validate delete", "name", r.Name) diff --git a/api/v1/ytsaurus_types.go b/api/v1/ytsaurus_types.go index ed769f78..e6b075f9 100644 --- a/api/v1/ytsaurus_types.go +++ b/api/v1/ytsaurus_types.go @@ -68,7 +68,7 @@ type EmbeddedObjectMetadata struct { } // LocationType string describes types of disk locations for YT components. -// +enum +// +enum. type LocationType string const ( @@ -95,7 +95,7 @@ type LocationSpec struct { } // LogLevel string describes possible Ytsaurus logging level. -// +enum +// +enum. type LogLevel string const ( @@ -107,7 +107,7 @@ const ( ) // LogWriterType string describes types of possible log writers. -// +enum +// +enum. type LogWriterType string const ( @@ -132,7 +132,7 @@ const ( ) // CategoriesFilterType string describes types of possible log CategoriesFilter. -// +enum +// +enum. type CategoriesFilterType string const ( @@ -565,7 +565,7 @@ type CommonSpec struct { ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"` } -// YtsaurusSpec defines the desired state of Ytsaurus +// YtsaurusSpec defines the desired state of Ytsaurus. type YtsaurusSpec struct { CommonSpec `json:",inline"` UIImage string `json:"uiImage,omitempty"` @@ -669,9 +669,9 @@ const ( UpdateSelectorStatelessOnly UpdateSelector = "StatelessOnly" // UpdateSelectorMasterOnly means that only master could be updated. UpdateSelectorMasterOnly UpdateSelector = "MasterOnly" - // UpdateSelectorTabletNodesOnly means that only tablet nodes could be updated + // UpdateSelectorTabletNodesOnly means that only tablet nodes could be updated. UpdateSelectorTabletNodesOnly UpdateSelector = "TabletNodesOnly" - // UpdateSelectorExecNodesOnly means that only tablet nodes could be updated + // UpdateSelectorExecNodesOnly means that only tablet nodes could be updated. UpdateSelectorExecNodesOnly UpdateSelector = "ExecNodesOnly" // UpdateSelectorEverything means that all components could be updated. // With this setting and if master or tablet nodes need update all the components would be updated. @@ -701,7 +701,7 @@ type UpdateStatus struct { MasterMonitoringPaths []string `json:"masterMonitoringPaths,omitempty"` } -// YtsaurusStatus defines the observed state of Ytsaurus +// YtsaurusStatus defines the observed state of Ytsaurus. type YtsaurusStatus struct { //+kubebuilder:default:=Created State ClusterState `json:"state,omitempty"` @@ -730,7 +730,7 @@ type YtsaurusStatus struct { // +kubebuilder:resource:path=ytsaurus,shortName=yt // +kubebuilder:subresource:status -// Ytsaurus is the Schema for the ytsaurus API +// Ytsaurus is the Schema for the ytsaurus API. type Ytsaurus struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -740,7 +740,7 @@ type Ytsaurus struct { //+kubebuilder:object:root=true -// YtsaurusList contains a list of Ytsaurus +// YtsaurusList contains a list of Ytsaurus. type YtsaurusList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/api/v1/ytsaurus_webhook.go b/api/v1/ytsaurus_webhook.go index 1fb608bd..14f224bf 100644 --- a/api/v1/ytsaurus_webhook.go +++ b/api/v1/ytsaurus_webhook.go @@ -51,7 +51,7 @@ func (r *Ytsaurus) SetupWebhookWithManager(mgr ctrl.Manager) error { var _ webhook.Defaulter = &Ytsaurus{} -// Default implements webhook.Defaulter so a webhook will be registered for the type +// Default implements webhook.Defaulter so a webhook will be registered for the type. func (r *Ytsaurus) Default() { ytsauruslog.Info("default", "name", r.Name) @@ -430,7 +430,6 @@ func (r *Ytsaurus) validateInstanceSpec(instanceSpec InstanceSpec, path *field.P if instanceSpec.Locations != nil { for locationIdx, location := range instanceSpec.Locations { - inVolumeMount := false for _, volumeMount := range instanceSpec.VolumeMounts { if strings.HasPrefix(location.Path, volumeMount.MountPath) { @@ -484,14 +483,14 @@ func (r *Ytsaurus) evaluateYtsaurusValidation(old *Ytsaurus) error { allErrors) } -// ValidateCreate implements webhook.Validator so a webhook will be registered for the type +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type. func (r *Ytsaurus) ValidateCreate() (admission.Warnings, error) { ytsauruslog.Info("validate create", "name", r.Name) return nil, r.evaluateYtsaurusValidation(nil) } -// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type. func (r *Ytsaurus) ValidateUpdate(oldObject runtime.Object) (admission.Warnings, error) { ytsauruslog.Info("validate update", "name", r.Name) old, ok := oldObject.(*Ytsaurus) @@ -501,7 +500,7 @@ func (r *Ytsaurus) ValidateUpdate(oldObject runtime.Object) (admission.Warnings, return nil, r.evaluateYtsaurusValidation(old) } -// ValidateDelete implements webhook.Validator so a webhook will be registered for the type +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type. func (r *Ytsaurus) ValidateDelete() (admission.Warnings, error) { ytsauruslog.Info("validate delete", "name", r.Name) diff --git a/config/crd/bases/cluster.ytsaurus.tech_chyts.yaml b/config/crd/bases/cluster.ytsaurus.tech_chyts.yaml index ab49be1f..d7748e1a 100644 --- a/config/crd/bases/cluster.ytsaurus.tech_chyts.yaml +++ b/config/crd/bases/cluster.ytsaurus.tech_chyts.yaml @@ -22,7 +22,7 @@ spec: name: v1 schema: openAPIV3Schema: - description: Chyt is the Schema for the chyts API + description: Chyt is the Schema for the chyts API. properties: apiVersion: description: APIVersion defines the versioned schema of this representation @@ -35,7 +35,7 @@ spec: metadata: type: object spec: - description: ChytSpec defines the desired state of Chyt + description: ChytSpec defines the desired state of Chyt. properties: image: type: string @@ -72,7 +72,7 @@ spec: - makeDefault type: object status: - description: ChytStatus defines the observed state of Chyt + description: ChytStatus defines the observed state of Chyt. properties: conditions: items: diff --git a/config/crd/bases/cluster.ytsaurus.tech_remoteexecnodes.yaml b/config/crd/bases/cluster.ytsaurus.tech_remoteexecnodes.yaml index e1b99826..6f95df8e 100644 --- a/config/crd/bases/cluster.ytsaurus.tech_remoteexecnodes.yaml +++ b/config/crd/bases/cluster.ytsaurus.tech_remoteexecnodes.yaml @@ -22,7 +22,7 @@ spec: name: v1 schema: openAPIV3Schema: - description: RemoteExecNodes is the Schema for the remoteexecnodes API + description: RemoteExecNodes is the Schema for the remoteexecnodes API. properties: apiVersion: description: APIVersion defines the versioned schema of this representation @@ -35,7 +35,7 @@ spec: metadata: type: object spec: - description: RemoteExecNodesSpec defines the desired state of RemoteExecNodes + description: RemoteExecNodesSpec defines the desired state of RemoteExecNodes. properties: affinity: description: Affinity is a group of affinity scheduling rules. @@ -2630,7 +2630,7 @@ spec: - remoteClusterSpec type: object status: - description: RemoteExecNodesStatus defines the observed state of RemoteExecNodes + description: RemoteExecNodesStatus defines the observed state of RemoteExecNodes. properties: releaseStatus: description: |- diff --git a/config/crd/bases/cluster.ytsaurus.tech_remoteytsaurus.yaml b/config/crd/bases/cluster.ytsaurus.tech_remoteytsaurus.yaml index bf98fbee..83cc0f7c 100644 --- a/config/crd/bases/cluster.ytsaurus.tech_remoteytsaurus.yaml +++ b/config/crd/bases/cluster.ytsaurus.tech_remoteytsaurus.yaml @@ -17,7 +17,7 @@ spec: - name: v1 schema: openAPIV3Schema: - description: RemoteYtsaurus is the Schema for the remoteytsauruses API + description: RemoteYtsaurus is the Schema for the remoteytsauruses API. properties: apiVersion: description: APIVersion defines the versioned schema of this representation @@ -30,7 +30,7 @@ spec: metadata: type: object spec: - description: RemoteYtsaurusSpec defines the desired state of RemoteYtsaurus + description: RemoteYtsaurusSpec defines the desired state of RemoteYtsaurus. properties: affinity: description: Affinity is a group of affinity scheduling rules. @@ -2368,7 +2368,7 @@ spec: - cellTagMasterCaches type: object status: - description: RemoteYtsaurusStatus defines the observed state of RemoteYtsaurus + description: RemoteYtsaurusStatus defines the observed state of RemoteYtsaurus. type: object type: object served: true diff --git a/config/crd/bases/cluster.ytsaurus.tech_spyts.yaml b/config/crd/bases/cluster.ytsaurus.tech_spyts.yaml index 01118094..8223addd 100644 --- a/config/crd/bases/cluster.ytsaurus.tech_spyts.yaml +++ b/config/crd/bases/cluster.ytsaurus.tech_spyts.yaml @@ -22,7 +22,7 @@ spec: name: v1 schema: openAPIV3Schema: - description: Spyt is the Schema for the spyts API + description: Spyt is the Schema for the spyts API. properties: apiVersion: description: APIVersion defines the versioned schema of this representation @@ -35,7 +35,7 @@ spec: metadata: type: object spec: - description: SpytSpec defines the desired state of Spyt + description: SpytSpec defines the desired state of Spyt. properties: image: type: string @@ -67,7 +67,7 @@ spec: x-kubernetes-map-type: atomic type: object status: - description: SpytStatus defines the observed state of Spyt + description: SpytStatus defines the observed state of Spyt. properties: conditions: items: diff --git a/config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml b/config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml index 445684ec..1cf6c6cd 100644 --- a/config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml +++ b/config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml @@ -32,7 +32,7 @@ spec: name: v1 schema: openAPIV3Schema: - description: Ytsaurus is the Schema for the ytsaurus API + description: Ytsaurus is the Schema for the ytsaurus API. properties: apiVersion: description: APIVersion defines the versioned schema of this representation @@ -45,7 +45,7 @@ spec: metadata: type: object spec: - description: YtsaurusSpec defines the desired state of Ytsaurus + description: YtsaurusSpec defines the desired state of Ytsaurus. properties: adminCredentials: description: |- @@ -36150,7 +36150,7 @@ spec: type: object type: object status: - description: YtsaurusStatus defines the observed state of Ytsaurus + description: YtsaurusStatus defines the observed state of Ytsaurus. properties: conditions: items: diff --git a/controllers/chyt_controller.go b/controllers/chyt_controller.go index b3764b79..9c2cee17 100644 --- a/controllers/chyt_controller.go +++ b/controllers/chyt_controller.go @@ -18,10 +18,11 @@ package controllers import ( "context" + "time" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" - "time" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" @@ -31,7 +32,7 @@ import ( ytv1 "github.com/ytsaurus/yt-k8s-operator/api/v1" ) -// ChytReconciler reconciles a Chyt object +// ChytReconciler reconciles a Chyt object. type ChytReconciler struct { client.Client Recorder record.EventRecorder diff --git a/controllers/chyt_sync.go b/controllers/chyt_sync.go index 890bb91b..322ee2e4 100644 --- a/controllers/chyt_sync.go +++ b/controllers/chyt_sync.go @@ -2,13 +2,14 @@ package controllers import ( "context" + "time" + ytv1 "github.com/ytsaurus/yt-k8s-operator/api/v1" "github.com/ytsaurus/yt-k8s-operator/pkg/apiproxy" "github.com/ytsaurus/yt-k8s-operator/pkg/components" "github.com/ytsaurus/yt-k8s-operator/pkg/ytconfig" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/log" - "time" ) func (r *ChytReconciler) Sync(ctx context.Context, resource *ytv1.Chyt, ytsaurus *ytv1.Ytsaurus) (ctrl.Result, error) { diff --git a/controllers/remoteexecnodes_controller.go b/controllers/remoteexecnodes_controller.go index a6b50f34..4b911c89 100644 --- a/controllers/remoteexecnodes_controller.go +++ b/controllers/remoteexecnodes_controller.go @@ -39,7 +39,7 @@ const ( remoteClusterSpecField = "remoteClusterSpec" ) -// RemoteExecNodesReconciler reconciles a RemoteExecNodes object +// RemoteExecNodesReconciler reconciles a RemoteExecNodes object. type RemoteExecNodesReconciler struct { client.Client Scheme *runtime.Scheme diff --git a/controllers/spyt_controller.go b/controllers/spyt_controller.go index e7590a97..a4e85e5f 100644 --- a/controllers/spyt_controller.go +++ b/controllers/spyt_controller.go @@ -18,10 +18,11 @@ package controllers import ( "context" + "time" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" - "time" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" @@ -31,7 +32,7 @@ import ( ytv1 "github.com/ytsaurus/yt-k8s-operator/api/v1" ) -// SpytReconciler reconciles a Spyt object +// SpytReconciler reconciles a Spyt object. type SpytReconciler struct { client.Client Scheme *runtime.Scheme diff --git a/controllers/spyt_sync.go b/controllers/spyt_sync.go index 7f8c6d64..776a4a74 100644 --- a/controllers/spyt_sync.go +++ b/controllers/spyt_sync.go @@ -2,13 +2,14 @@ package controllers import ( "context" + "time" + ytv1 "github.com/ytsaurus/yt-k8s-operator/api/v1" "github.com/ytsaurus/yt-k8s-operator/pkg/apiproxy" "github.com/ytsaurus/yt-k8s-operator/pkg/components" "github.com/ytsaurus/yt-k8s-operator/pkg/ytconfig" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/log" - "time" ) func (r *SpytReconciler) Sync(ctx context.Context, resource *ytv1.Spyt, ytsaurus *ytv1.Ytsaurus) (ctrl.Result, error) { diff --git a/controllers/ytsaurus_controller.go b/controllers/ytsaurus_controller.go index 621dd4b8..b19dae02 100644 --- a/controllers/ytsaurus_controller.go +++ b/controllers/ytsaurus_controller.go @@ -18,6 +18,7 @@ package controllers import ( "context" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" @@ -29,7 +30,7 @@ import ( ytv1 "github.com/ytsaurus/yt-k8s-operator/api/v1" ) -// YtsaurusReconciler reconciles a Ytsaurus object +// YtsaurusReconciler reconciles a Ytsaurus object. type YtsaurusReconciler struct { client.Client Scheme *runtime.Scheme diff --git a/docs/api.md b/docs/api.md index c5ba9a90..1006dd40 100644 --- a/docs/api.md +++ b/docs/api.md @@ -149,7 +149,7 @@ _Appears in:_ -Chyt is the Schema for the chyts API +Chyt is the Schema for the chyts API. @@ -167,7 +167,7 @@ Chyt is the Schema for the chyts API -ChytSpec defines the desired state of Chyt +ChytSpec defines the desired state of Chyt. @@ -1086,7 +1086,7 @@ _Appears in:_ -RemoteExecNodes is the Schema for the remoteexecnodes API +RemoteExecNodes is the Schema for the remoteexecnodes API. @@ -1104,7 +1104,7 @@ RemoteExecNodes is the Schema for the remoteexecnodes API -RemoteExecNodesSpec defines the desired state of RemoteExecNodes +RemoteExecNodesSpec defines the desired state of RemoteExecNodes. @@ -1166,7 +1166,7 @@ _Appears in:_ -RemoteYtsaurus is the Schema for the remoteytsauruses API +RemoteYtsaurus is the Schema for the remoteytsauruses API. @@ -1184,7 +1184,7 @@ RemoteYtsaurus is the Schema for the remoteytsauruses API -RemoteYtsaurusSpec defines the desired state of RemoteYtsaurus +RemoteYtsaurusSpec defines the desired state of RemoteYtsaurus. @@ -1265,7 +1265,7 @@ _Appears in:_ -Spyt is the Schema for the spyts API +Spyt is the Schema for the spyts API. @@ -1283,7 +1283,7 @@ Spyt is the Schema for the spyts API -SpytSpec defines the desired state of Spyt +SpytSpec defines the desired state of Spyt. @@ -1619,7 +1619,7 @@ _Appears in:_ -Ytsaurus is the Schema for the ytsaurus API +Ytsaurus is the Schema for the ytsaurus API. @@ -1637,7 +1637,7 @@ Ytsaurus is the Schema for the ytsaurus API -YtsaurusSpec defines the desired state of Ytsaurus +YtsaurusSpec defines the desired state of Ytsaurus. diff --git a/main.go b/main.go index da65fee1..e7b1cdce 100644 --- a/main.go +++ b/main.go @@ -18,10 +18,11 @@ package main import ( "flag" - "go.uber.org/zap/zapcore" "os" "strings" + "go.uber.org/zap/zapcore" + "github.com/ytsaurus/yt-k8s-operator/controllers" metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" "sigs.k8s.io/controller-runtime/pkg/webhook" diff --git a/pkg/apiproxy/chyt.go b/pkg/apiproxy/chyt.go index 0d35a561..09c50451 100644 --- a/pkg/apiproxy/chyt.go +++ b/pkg/apiproxy/chyt.go @@ -2,6 +2,7 @@ package apiproxy import ( "context" + ytv1 "github.com/ytsaurus/yt-k8s-operator/api/v1" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/apiproxy/proxy.go b/pkg/apiproxy/proxy.go index d1bc9645..a11ac038 100644 --- a/pkg/apiproxy/proxy.go +++ b/pkg/apiproxy/proxy.go @@ -3,6 +3,7 @@ package apiproxy import ( "context" "fmt" + corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/apiproxy/spyt.go b/pkg/apiproxy/spyt.go index 5bbbb211..f617663c 100644 --- a/pkg/apiproxy/spyt.go +++ b/pkg/apiproxy/spyt.go @@ -2,6 +2,7 @@ package apiproxy import ( "context" + ytv1 "github.com/ytsaurus/yt-k8s-operator/api/v1" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/apiproxy/ytsaurus.go b/pkg/apiproxy/ytsaurus.go index 7c769828..48b8e844 100644 --- a/pkg/apiproxy/ytsaurus.go +++ b/pkg/apiproxy/ytsaurus.go @@ -140,10 +140,10 @@ func (c *Ytsaurus) IsStatusConditionFalse(conditionType string) bool { func sortConditions(conditions []metav1.Condition) { slices.SortStableFunc(conditions, func(a, b metav1.Condition) int { - statusOrder := []metav1.ConditionStatus{metav1.ConditionTrue, metav1.ConditionFalse, metav1.ConditionUnknown} - if diff := cmp.Compare(slices.Index(statusOrder, a.Status), slices.Index(statusOrder, b.Status)); diff != 0 { - return diff - } - return a.LastTransitionTime.Compare(b.LastTransitionTime.Time) + statusOrder := []metav1.ConditionStatus{metav1.ConditionTrue, metav1.ConditionFalse, metav1.ConditionUnknown} + if diff := cmp.Compare(slices.Index(statusOrder, a.Status), slices.Index(statusOrder, b.Status)); diff != 0 { + return diff + } + return a.LastTransitionTime.Compare(b.LastTransitionTime.Time) }) } diff --git a/pkg/components/chyt.go b/pkg/components/chyt.go index 6adc5dc2..17a56ce8 100644 --- a/pkg/components/chyt.go +++ b/pkg/components/chyt.go @@ -33,7 +33,6 @@ func NewChyt( cfgen *ytconfig.Generator, chyt *apiproxy.Chyt, ytsaurus *ytv1.Ytsaurus) *Chyt { - l := labeller.Labeller{ ObjectMeta: &chyt.GetResource().ObjectMeta, APIProxy: chyt.APIProxy(), diff --git a/pkg/components/helpers.go b/pkg/components/helpers.go index f9bc518b..ae0723e2 100644 --- a/pkg/components/helpers.go +++ b/pkg/components/helpers.go @@ -31,7 +31,6 @@ func CreateTabletCells(ctx context.Context, ytClient yt.Client, bundle string, t ypath.Path(fmt.Sprintf("//sys/tablet_cell_bundles/%s/@tablet_cell_count", bundle)), &initTabletCellCount, nil); err != nil { - logger.Error(err, "Getting table_cell_count failed") return err } @@ -176,7 +175,6 @@ func SetWithIgnoreExisting(path string, value string) string { func AddAffinity(statefulSet *appsv1.StatefulSet, nodeSelectorRequirementKey string, nodeSelectorRequirementValues []string) { - affinity := &corev1.Affinity{} if statefulSet.Spec.Template.Spec.Affinity != nil { affinity = statefulSet.Spec.Template.Spec.Affinity diff --git a/pkg/components/httpproxy.go b/pkg/components/httpproxy.go index fc7671fa..0dd7a72a 100644 --- a/pkg/components/httpproxy.go +++ b/pkg/components/httpproxy.go @@ -31,7 +31,6 @@ func NewHTTPProxy( ytsaurus *apiproxy.Ytsaurus, masterReconciler Component, spec ytv1.HTTPProxiesSpec) *HttpProxy { - resource := ytsaurus.GetResource() l := labeller.Labeller{ ObjectMeta: &resource.ObjectMeta, diff --git a/pkg/components/pods_manager.go b/pkg/components/pods_manager.go index e5dfabef..9573d956 100644 --- a/pkg/components/pods_manager.go +++ b/pkg/components/pods_manager.go @@ -8,7 +8,7 @@ import ( "github.com/ytsaurus/yt-k8s-operator/pkg/labeller" ) -// TODO: move to Updatable +// TODO: move to Updatable. type podsManager interface { removePods(ctx context.Context) error arePodsRemoved(ctx context.Context) bool diff --git a/pkg/components/spyt.go b/pkg/components/spyt.go index 09d88249..c9a81427 100644 --- a/pkg/components/spyt.go +++ b/pkg/components/spyt.go @@ -32,7 +32,6 @@ func NewSpyt( cfgen *ytconfig.Generator, spyt *apiproxy.Spyt, ytsaurus *ytv1.Ytsaurus) *Spyt { - l := labeller.Labeller{ ObjectMeta: &spyt.GetResource().ObjectMeta, APIProxy: spyt.APIProxy(), diff --git a/pkg/components/ui.go b/pkg/components/ui.go index 1730365d..2af15c33 100644 --- a/pkg/components/ui.go +++ b/pkg/components/ui.go @@ -93,7 +93,6 @@ func (u *UI) IsUpdatable() bool { func (u *UI) GetType() consts.ComponentType { return consts.UIType } func (u *UI) Fetch(ctx context.Context) error { - return resources.Fetch(ctx, u.microservice, u.initJob, @@ -254,7 +253,6 @@ func (u *UI) doSync(ctx context.Context, dry bool) (ComponentStatus, error) { if u.ytsaurus.GetClusterState() == ytv1.ClusterStateUpdating { if IsUpdatingComponent(u.ytsaurus, u) { - if u.ytsaurus.GetUpdateState() == ytv1.UpdateStateWaitingForPodsRemoval { if !dry { err = removePods(ctx, u.microservice, &u.localComponent) diff --git a/pkg/components/volume.go b/pkg/components/volume.go index 0aa6ab69..b195db9a 100644 --- a/pkg/components/volume.go +++ b/pkg/components/volume.go @@ -2,11 +2,12 @@ package components import ( "fmt" + "path" + ytv1 "github.com/ytsaurus/yt-k8s-operator/api/v1" "github.com/ytsaurus/yt-k8s-operator/pkg/consts" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "path" ) func createVolumeClaims(specVolumeClaimTemplates []ytv1.EmbeddedPersistentVolumeClaim) []corev1.PersistentVolumeClaim { diff --git a/pkg/components/ytsaurus_client.go b/pkg/components/ytsaurus_client.go index deb92b45..2625a7af 100644 --- a/pkg/components/ytsaurus_client.go +++ b/pkg/components/ytsaurus_client.go @@ -155,7 +155,6 @@ func (yc *YtsaurusClient) handleUpdatingState(ctx context.Context) (ComponentSta case ytv1.UpdateStatePossibilityCheck: if !yc.ytsaurus.IsUpdateStatusConditionTrue(consts.ConditionHasPossibility) && !yc.ytsaurus.IsUpdateStatusConditionTrue(consts.ConditionNoPossibility) { - ok, msg, err := yc.HandlePossibilityCheck(ctx) if err != nil { return SimpleStatus(SyncStatusUpdating), err @@ -301,7 +300,6 @@ func (yc *YtsaurusClient) handleUpdatingState(ctx context.Context) (ComponentSta case ytv1.UpdateStateWaitingForTabletCellsRecovery: if !yc.ytsaurus.IsUpdateStatusConditionTrue(consts.ConditionTabletCellsRecovered) { - err = yc.RecoverTableCells(ctx, yc.ytsaurus.GetResource().Status.UpdateStatus.TabletCellBundles) if err != nil { return SimpleStatus(SyncStatusUpdating), err diff --git a/pkg/resources/ca_bundle.go b/pkg/resources/ca_bundle.go index 8c9d4aac..fcf70974 100644 --- a/pkg/resources/ca_bundle.go +++ b/pkg/resources/ca_bundle.go @@ -4,7 +4,7 @@ import ( corev1 "k8s.io/api/core/v1" ) -// CABundle represents mounted configmap with trusted certificates +// CABundle represents mounted configmap with trusted certificates. type CABundle struct { ConfigMapName string VolumeName string diff --git a/pkg/resources/deployment.go b/pkg/resources/deployment.go index cf14146f..895cc9c6 100644 --- a/pkg/resources/deployment.go +++ b/pkg/resources/deployment.go @@ -2,6 +2,7 @@ package resources import ( "context" + "github.com/ytsaurus/yt-k8s-operator/pkg/apiproxy" labeller2 "github.com/ytsaurus/yt-k8s-operator/pkg/labeller" appsv1 "k8s.io/api/apps/v1" diff --git a/pkg/testutil/testhelper.go b/pkg/testutil/testhelper.go index df1ba00a..8f772605 100644 --- a/pkg/testutil/testhelper.go +++ b/pkg/testutil/testhelper.go @@ -146,7 +146,7 @@ func (h *TestHelper) Logf(format string, args ...any) { h.t.Logf(format, args...) } -// helpers +// helpers. func GetObject(h *TestHelper, key string, emptyObject client.Object) { k8sCli := h.GetK8sClient() err := k8sCli.Get(context.Background(), h.GetObjectKey(key), emptyObject) @@ -280,7 +280,6 @@ func FetchAndCheckConfigMapContainsEventually(h *TestHelper, objectKey, cmKey, e require.Contains(h.t, cmData, cmKey) ysonContent := cmData[cmKey] require.Contains(h.t, ysonContent, expectSubstr) - } func FetchConfigMapData(h *TestHelper, objectKey, mapKey string) string { diff --git a/pkg/ytconfig/cri.go b/pkg/ytconfig/cri.go index 5b8fdfea..6399c88e 100644 --- a/pkg/ytconfig/cri.go +++ b/pkg/ytconfig/cri.go @@ -17,7 +17,6 @@ func GetContainerdSocketPath(spec *ytv1.ExecNodesSpec) string { } func (g *NodeGenerator) GetContainerdConfig(spec *ytv1.ExecNodesSpec) ([]byte, error) { - criSpec := spec.JobEnvironment.CRI var rootPath *string diff --git a/pkg/ytconfig/logging.go b/pkg/ytconfig/logging.go index cea71d6e..214a52fa 100644 --- a/pkg/ytconfig/logging.go +++ b/pkg/ytconfig/logging.go @@ -2,9 +2,10 @@ package ytconfig import ( "fmt" - "go.ytsaurus.tech/library/go/ptr" "path" + "go.ytsaurus.tech/library/go/ptr" + ytv1 "github.com/ytsaurus/yt-k8s-operator/api/v1" ) diff --git a/test/e2e/ytsaurus_controller_test.go b/test/e2e/ytsaurus_controller_test.go index 00016c50..4d334dbb 100644 --- a/test/e2e/ytsaurus_controller_test.go +++ b/test/e2e/ytsaurus_controller_test.go @@ -124,7 +124,6 @@ func getMasterPod(name, namespace string) corev1.Pod { } func deleteYtsaurus(ctx context.Context, ytsaurus *ytv1.Ytsaurus) { - if err := k8sClient.Delete(ctx, ytsaurus); err != nil { log.Error(err, "Deleting ytsaurus failed") } diff --git a/ytop-chart/templates/chyt-crd.yaml b/ytop-chart/templates/chyt-crd.yaml index 625cd804..e0bf10ce 100644 --- a/ytop-chart/templates/chyt-crd.yaml +++ b/ytop-chart/templates/chyt-crd.yaml @@ -35,7 +35,7 @@ spec: name: v1 schema: openAPIV3Schema: - description: Chyt is the Schema for the chyts API + description: Chyt is the Schema for the chyts API. properties: apiVersion: description: APIVersion defines the versioned schema of this representation @@ -48,7 +48,7 @@ spec: metadata: type: object spec: - description: ChytSpec defines the desired state of Chyt + description: ChytSpec defines the desired state of Chyt. properties: image: type: string @@ -85,7 +85,7 @@ spec: - makeDefault type: object status: - description: ChytStatus defines the observed state of Chyt + description: ChytStatus defines the observed state of Chyt. properties: conditions: items: diff --git a/ytop-chart/templates/remoteexecnodes-crd.yaml b/ytop-chart/templates/remoteexecnodes-crd.yaml index c69d6f9c..489ef652 100644 --- a/ytop-chart/templates/remoteexecnodes-crd.yaml +++ b/ytop-chart/templates/remoteexecnodes-crd.yaml @@ -23,7 +23,7 @@ spec: name: v1 schema: openAPIV3Schema: - description: RemoteExecNodes is the Schema for the remoteexecnodes API + description: RemoteExecNodes is the Schema for the remoteexecnodes API. properties: apiVersion: description: APIVersion defines the versioned schema of this representation @@ -36,7 +36,7 @@ spec: metadata: type: object spec: - description: RemoteExecNodesSpec defines the desired state of RemoteExecNodes + description: RemoteExecNodesSpec defines the desired state of RemoteExecNodes. properties: affinity: description: Affinity is a group of affinity scheduling rules. @@ -2607,7 +2607,7 @@ spec: - remoteClusterSpec type: object status: - description: RemoteExecNodesStatus defines the observed state of RemoteExecNodes + description: RemoteExecNodesStatus defines the observed state of RemoteExecNodes. properties: releaseStatus: description: |- diff --git a/ytop-chart/templates/remoteytsaurus-crd.yaml b/ytop-chart/templates/remoteytsaurus-crd.yaml index 0a892141..5ad04ee9 100644 --- a/ytop-chart/templates/remoteytsaurus-crd.yaml +++ b/ytop-chart/templates/remoteytsaurus-crd.yaml @@ -18,7 +18,7 @@ spec: - name: v1 schema: openAPIV3Schema: - description: RemoteYtsaurus is the Schema for the remoteytsauruses API + description: RemoteYtsaurus is the Schema for the remoteytsauruses API. properties: apiVersion: description: APIVersion defines the versioned schema of this representation @@ -31,7 +31,7 @@ spec: metadata: type: object spec: - description: RemoteYtsaurusSpec defines the desired state of RemoteYtsaurus + description: RemoteYtsaurusSpec defines the desired state of RemoteYtsaurus. properties: affinity: description: Affinity is a group of affinity scheduling rules. @@ -2345,7 +2345,7 @@ spec: - cellTagMasterCaches type: object status: - description: RemoteYtsaurusStatus defines the observed state of RemoteYtsaurus + description: RemoteYtsaurusStatus defines the observed state of RemoteYtsaurus. type: object type: object served: true diff --git a/ytop-chart/templates/spyt-crd.yaml b/ytop-chart/templates/spyt-crd.yaml index 578637bd..372a87c3 100644 --- a/ytop-chart/templates/spyt-crd.yaml +++ b/ytop-chart/templates/spyt-crd.yaml @@ -35,7 +35,7 @@ spec: name: v1 schema: openAPIV3Schema: - description: Spyt is the Schema for the spyts API + description: Spyt is the Schema for the spyts API. properties: apiVersion: description: APIVersion defines the versioned schema of this representation @@ -48,7 +48,7 @@ spec: metadata: type: object spec: - description: SpytSpec defines the desired state of Spyt + description: SpytSpec defines the desired state of Spyt. properties: image: type: string @@ -80,7 +80,7 @@ spec: x-kubernetes-map-type: atomic type: object status: - description: SpytStatus defines the observed state of Spyt + description: SpytStatus defines the observed state of Spyt. properties: conditions: items: diff --git a/ytop-chart/templates/ytsaurus-crd.yaml b/ytop-chart/templates/ytsaurus-crd.yaml index e7eac2ca..d30cf30a 100644 --- a/ytop-chart/templates/ytsaurus-crd.yaml +++ b/ytop-chart/templates/ytsaurus-crd.yaml @@ -45,7 +45,7 @@ spec: name: v1 schema: openAPIV3Schema: - description: Ytsaurus is the Schema for the ytsaurus API + description: Ytsaurus is the Schema for the ytsaurus API. properties: apiVersion: description: APIVersion defines the versioned schema of this representation @@ -58,7 +58,7 @@ spec: metadata: type: object spec: - description: YtsaurusSpec defines the desired state of Ytsaurus + description: YtsaurusSpec defines the desired state of Ytsaurus. properties: adminCredentials: description: |- @@ -35918,7 +35918,7 @@ spec: type: object type: object status: - description: YtsaurusStatus defines the observed state of Ytsaurus + description: YtsaurusStatus defines the observed state of Ytsaurus. properties: conditions: items: