Skip to content

Commit

Permalink
refactor based on comments
Browse files Browse the repository at this point in the history
  • Loading branch information
achulkov2 committed Sep 3, 2024
1 parent 13d73c0 commit ae1d2c9
Show file tree
Hide file tree
Showing 37 changed files with 305 additions and 302 deletions.
11 changes: 5 additions & 6 deletions api/v1/ytsaurus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,12 +635,11 @@ type YtsaurusSpec struct {
ControllerAgents *ControllerAgentsSpec `json:"controllerAgents,omitempty"`
TabletNodes []TabletNodesSpec `json:"tabletNodes,omitempty"`

StrawberryController *StrawberryControllerSpec `json:"strawberry,omitempty"`
DeprecatedChytController *StrawberryControllerSpec `json:"chyt,omitempty"`
QueryTrackers *QueryTrackerSpec `json:"queryTrackers,omitempty"`
Spyt *DeprecatedSpytSpec `json:"spyt,omitempty"`
YQLAgents *YQLAgentSpec `json:"yqlAgents,omitempty"`
QueueAgents *QueueAgentSpec `json:"queueAgents,omitempty"`
StrawberryController *StrawberryControllerSpec `json:"strawberry,omitempty"`
QueryTrackers *QueryTrackerSpec `json:"queryTrackers,omitempty"`
Spyt *DeprecatedSpytSpec `json:"spyt,omitempty"`
YQLAgents *YQLAgentSpec `json:"yqlAgents,omitempty"`
QueueAgents *QueueAgentSpec `json:"queueAgents,omitempty"`

UI *UISpec `json:"ui,omitempty"`
}
Expand Down
5 changes: 0 additions & 5 deletions api/v1/zz_generated.deepcopy.go

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

77 changes: 0 additions & 77 deletions config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,83 +98,6 @@ spec:
type: string
type: object
x-kubernetes-map-type: atomic
chyt:
properties:
image:
type: string
resources:
description: ResourceRequirements describes the compute resource
requirements.
properties:
claims:
description: Claims lists the names of resources, defined
in spec.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: Name must match the name of one entry in
pod.spec.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: Limits describes the maximum amount of compute
resources allowed.
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: Requests describes the minimum amount of compute
resources required.
type: object
type: object
tolerations:
items:
description: |-
The pod this Toleration is attached to tolerates any taint that matches
the trip
properties:
effect:
description: Effect indicates the taint effect to match.
Empty means match all taint effects.
type: string
key:
description: Key is the taint key that the toleration applies
to.
type: string
operator:
description: Operator represents a key's relationship to
the value.
type: string
tolerationSeconds:
description: |-
TolerationSeconds represents the period of time the toleration (which must be
of
format: int64
type: integer
value:
description: Value is the taint value the toleration matches
to.
type: string
type: object
type: array
type: object
configOverrides:
description: |-
LocalObjectReference contains enough information to let you locate the
Expand Down
2 changes: 1 addition & 1 deletion controllers/component_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func NewComponentManager(
allComponents = append(allComponents, yqla)
}

if (resource.Spec.DeprecatedChytController != nil || resource.Spec.StrawberryController != nil) && resource.Spec.Schedulers != nil {
if resource.Spec.StrawberryController != nil && resource.Spec.Schedulers != nil {
strawberry := components.NewStrawberryController(cfgen, ytsaurus, m, s, dnds)
allComponents = append(allComponents, strawberry)
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/remoteexecnodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func buildExecNodePod(h *testutil.TestHelper) corev1.Pod {
consts.YTComponentLabelName: strings.Join(
[]string{
remoteExecNodesName,
consts.YTComponentLabelExecNode,
consts.ComponentLabel(consts.ExecNodeType),
},
"-",
),
Expand Down
1 change: 0 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1726,7 +1726,6 @@ _Appears in:_
| `controllerAgents` _[ControllerAgentsSpec](#controlleragentsspec)_ | | | |
| `tabletNodes` _[TabletNodesSpec](#tabletnodesspec) array_ | | | |
| `strawberry` _[StrawberryControllerSpec](#strawberrycontrollerspec)_ | | | |
| `chyt` _[StrawberryControllerSpec](#strawberrycontrollerspec)_ | | | |
| `queryTrackers` _[QueryTrackerSpec](#querytrackerspec)_ | | | |
| `spyt` _[DeprecatedSpytSpec](#deprecatedspytspec)_ | | | |
| `yqlAgents` _[YQLAgentSpec](#yqlagentspec)_ | | | |
Expand Down
11 changes: 5 additions & 6 deletions pkg/components/chyt.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ func NewChyt(
chyt *apiproxy.Chyt,
ytsaurus *ytv1.Ytsaurus) *Chyt {
l := labeller.Labeller{
ObjectMeta: &chyt.GetResource().ObjectMeta,
APIProxy: chyt.APIProxy(),
ComponentType: consts.YTComponentLabelChyt,
ComponentLabel: cfgen.FormatComponentStringWithDefault(consts.YTComponentLabelChyt, chyt.GetResource().Name),
ComponentName: cfgen.FormatComponentStringWithDefault(string(consts.ChytType), chyt.GetResource().Name),
Annotations: ytsaurus.Spec.ExtraPodAnnotations,
ObjectMeta: &chyt.GetResource().ObjectMeta,
APIProxy: chyt.APIProxy(),
ComponentType: consts.ChytType,
ComponentNamePart: chyt.GetResource().Name,
Annotations: ytsaurus.Spec.ExtraPodAnnotations,
}

return &Chyt{
Expand Down
4 changes: 2 additions & 2 deletions pkg/components/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type baseComponent struct {
// For example for master component name is "Master",
// For data node name looks like "DataNode<NameFromSpec>".
func (c *baseComponent) GetName() string {
return c.labeller.ComponentName
return c.labeller.GetFullComponentName()
}

// localComponent is a base structs for components which have access to ytsaurus resource,
Expand Down Expand Up @@ -99,7 +99,7 @@ func (c *localComponent) SetReadyCondition(status ComponentStatus) {
ready = metav1.ConditionTrue
}
c.ytsaurus.SetStatusCondition(metav1.Condition{
Type: fmt.Sprintf("%sReady", c.labeller.ComponentName),
Type: fmt.Sprintf("%sReady", c.labeller.GetFullComponentName()),
Status: ready,
Reason: string(status.SyncStatus),
Message: status.Message,
Expand Down
7 changes: 3 additions & 4 deletions pkg/components/controller_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ type ControllerAgent struct {
func NewControllerAgent(cfgen *ytconfig.Generator, ytsaurus *apiproxy.Ytsaurus, master Component) *ControllerAgent {
resource := ytsaurus.GetResource()
l := labeller.Labeller{
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentLabel: consts.YTComponentLabelControllerAgent,
ComponentName: string(consts.ControllerAgentType),
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentType: consts.ControllerAgentType,
}

if resource.Spec.ControllerAgents.InstanceSpec.MonitoringPort == nil {
Expand Down
9 changes: 4 additions & 5 deletions pkg/components/data_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ func NewDataNode(
) *DataNode {
resource := ytsaurus.GetResource()
l := labeller.Labeller{
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentType: consts.YTComponentLabelDataNode,
ComponentLabel: cfgen.FormatComponentStringWithDefault(consts.YTComponentLabelDataNode, spec.Name),
ComponentName: cfgen.FormatComponentStringWithDefault(string(consts.DataNodeType), spec.Name),
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentType: consts.DataNodeType,
ComponentNamePart: spec.Name,
}

if spec.InstanceSpec.MonitoringPort == nil {
Expand Down
7 changes: 3 additions & 4 deletions pkg/components/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ type Discovery struct {
func NewDiscovery(cfgen *ytconfig.Generator, ytsaurus *apiproxy.Ytsaurus) *Discovery {
resource := ytsaurus.GetResource()
l := labeller.Labeller{
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentLabel: consts.YTComponentLabelDiscovery,
ComponentName: string(consts.DiscoveryType),
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentType: consts.DiscoveryType,
}

if resource.Spec.Discovery.InstanceSpec.MonitoringPort == nil {
Expand Down
9 changes: 4 additions & 5 deletions pkg/components/exec_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ func NewExecNode(
) *ExecNode {
resource := ytsaurus.GetResource()
l := labeller.Labeller{
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentType: consts.YTComponentLabelExecNode,
ComponentLabel: cfgen.FormatComponentStringWithDefault(consts.YTComponentLabelExecNode, spec.Name),
ComponentName: cfgen.FormatComponentStringWithDefault(string(consts.ExecNodeType), spec.Name),
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentType: consts.ExecNodeType,
ComponentNamePart: spec.Name,
}

if spec.InstanceSpec.MonitoringPort == nil {
Expand Down
9 changes: 4 additions & 5 deletions pkg/components/exec_node_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ func NewRemoteExecNodes(
commonSpec ytv1.CommonSpec,
) *RemoteExecNode {
l := labeller.Labeller{
ObjectMeta: &nodes.ObjectMeta,
APIProxy: proxy,
ComponentType: consts.YTComponentLabelExecNode,
ComponentLabel: cfgen.FormatComponentStringWithDefault(consts.YTComponentLabelExecNode, spec.Name),
ComponentName: cfgen.FormatComponentStringWithDefault(string(consts.ExecNodeType), spec.Name),
ObjectMeta: &nodes.ObjectMeta,
APIProxy: proxy,
ComponentType: consts.ExecNodeType,
ComponentNamePart: spec.Name,
}

if spec.InstanceSpec.MonitoringPort == nil {
Expand Down
9 changes: 4 additions & 5 deletions pkg/components/httpproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ func NewHTTPProxy(
spec ytv1.HTTPProxiesSpec) *HttpProxy {
resource := ytsaurus.GetResource()
l := labeller.Labeller{
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentType: consts.YTComponentLabelHTTPProxy,
ComponentLabel: cfgen.FormatComponentStringWithDefault(consts.YTComponentLabelHTTPProxy, spec.Role),
ComponentName: cfgen.FormatComponentStringWithDefault(string(consts.HttpProxyType), spec.Role),
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentType: consts.HttpProxyType,
ComponentNamePart: spec.Role,
}

if spec.InstanceSpec.MonitoringPort == nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/components/init_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewInitJob(
apiProxy: apiProxy,
conditionsManager: conditionsManager,
imagePullSecrets: imagePullSecrets,
initCompletedCondition: fmt.Sprintf("%s%sInitJobCompleted", name, labeller.ComponentName),
initCompletedCondition: fmt.Sprintf("%s%sInitJobCompleted", name, labeller.GetFullComponentName()),
image: image,
initJob: resources.NewJob(
labeller.GetInitJobName(name),
Expand All @@ -76,7 +76,7 @@ func NewInitJob(
fmt.Sprintf(
"%s-%s-init-job-config",
strings.ToLower(name),
labeller.ComponentLabel),
labeller.GetFullComponentLabel()),
nil,
map[string]ytconfig.GeneratorDescriptor{
configFileName: {
Expand Down Expand Up @@ -158,7 +158,7 @@ func (j *InitJob) Sync(ctx context.Context, dry bool) (ComponentStatus, error) {
}

if !j.initJob.Completed() {
logger.Info("Init job is not completed for " + j.labeller.ComponentName)
logger.Info("Init job is not completed for " + j.labeller.GetFullComponentName())
return WaitingStatus(SyncStatusBlocked, fmt.Sprintf("%s completion", j.initJob.Name())), err
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/components/init_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ func newTestJob(ytsaurus *apiproxy.Ytsaurus) *InitJob {
Name: k8sName,
Namespace: ytsaurus.GetResource().Namespace,
},
ComponentLabel: "ms",
ComponentName: k8sName,
ComponentType: consts.MasterCacheType,
},
ytsaurus.APIProxy(),
ytsaurus,
Expand Down
9 changes: 4 additions & 5 deletions pkg/components/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ type Master struct {
func NewMaster(cfgen *ytconfig.Generator, ytsaurus *apiproxy.Ytsaurus) *Master {
resource := ytsaurus.GetResource()
l := labeller.Labeller{
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentLabel: consts.YTComponentLabelMaster,
ComponentName: string(consts.MasterType),
Annotations: resource.Spec.ExtraPodAnnotations,
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentType: consts.MasterType,
Annotations: resource.Spec.ExtraPodAnnotations,
}

if resource.Spec.PrimaryMasters.InstanceSpec.MonitoringPort == nil {
Expand Down
9 changes: 4 additions & 5 deletions pkg/components/master_caches.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ type MasterCache struct {
func NewMasterCache(cfgen *ytconfig.Generator, ytsaurus *apiproxy.Ytsaurus) *MasterCache {
resource := ytsaurus.GetResource()
l := labeller.Labeller{
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentLabel: consts.YTComponentLabelMasterCache,
ComponentName: string(consts.MasterCacheType),
Annotations: resource.Spec.ExtraPodAnnotations,
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentType: consts.MasterCacheType,
Annotations: resource.Spec.ExtraPodAnnotations,
}

if resource.Spec.MasterCaches.InstanceSpec.MonitoringPort == nil {
Expand Down
9 changes: 4 additions & 5 deletions pkg/components/query_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ func NewQueryTracker(
) *QueryTracker {
resource := ytsaurus.GetResource()
l := labeller.Labeller{
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentLabel: consts.YTComponentLabelQueryTracker,
ComponentName: string(consts.QueryTrackerType),
Annotations: resource.Spec.ExtraPodAnnotations,
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentType: consts.QueryTrackerType,
Annotations: resource.Spec.ExtraPodAnnotations,
}

if resource.Spec.QueryTrackers.InstanceSpec.MonitoringPort == nil {
Expand Down
9 changes: 4 additions & 5 deletions pkg/components/queue_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ func NewQueueAgent(
) *QueueAgent {
resource := ytsaurus.GetResource()
l := labeller.Labeller{
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentLabel: consts.YTComponentLabelQueueAgent,
ComponentName: string(consts.QueueAgentType),
Annotations: resource.Spec.ExtraPodAnnotations,
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentType: consts.QueueAgentType,
Annotations: resource.Spec.ExtraPodAnnotations,
}

if resource.Spec.QueueAgents.InstanceSpec.MonitoringPort == nil {
Expand Down
9 changes: 4 additions & 5 deletions pkg/components/rpcproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ func NewRPCProxy(
spec ytv1.RPCProxiesSpec) *RpcProxy {
resource := ytsaurus.GetResource()
l := labeller.Labeller{
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentType: consts.YTComponentLabelRPCProxy,
ComponentLabel: cfgen.FormatComponentStringWithDefault(consts.YTComponentLabelRPCProxy, spec.Role),
ComponentName: cfgen.FormatComponentStringWithDefault(string(consts.RpcProxyType), spec.Role),
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
ComponentType: consts.RpcProxyType,
ComponentNamePart: spec.Role,
}

if spec.InstanceSpec.MonitoringPort == nil {
Expand Down
Loading

0 comments on commit ae1d2c9

Please sign in to comment.