Skip to content

Commit

Permalink
Refactor label names for components (#326)
Browse files Browse the repository at this point in the history
* Refactor label names for components

* address comments

* refactor based on comments
  • Loading branch information
achulkov2 authored Sep 4, 2024
1 parent 1a1e9b1 commit 3fe949a
Show file tree
Hide file tree
Showing 39 changed files with 346 additions and 363 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
10 changes: 5 additions & 5 deletions pkg/components/chyt.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ func NewChyt(
chyt *apiproxy.Chyt,
ytsaurus *ytv1.Ytsaurus) *Chyt {
l := labeller.Labeller{
ObjectMeta: &chyt.GetResource().ObjectMeta,
APIProxy: chyt.APIProxy(),
ComponentLabel: fmt.Sprintf("ytsaurus-chyt-%s", chyt.GetResource().Name),
ComponentName: fmt.Sprintf("CHYT-%s", 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
8 changes: 4 additions & 4 deletions pkg/components/data_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ func NewDataNode(
) *DataNode {
resource := ytsaurus.GetResource()
l := labeller.Labeller{
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
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
8 changes: 4 additions & 4 deletions pkg/components/exec_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ func NewExecNode(
) *ExecNode {
resource := ytsaurus.GetResource()
l := labeller.Labeller{
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
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
8 changes: 4 additions & 4 deletions pkg/components/exec_node_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ func NewRemoteExecNodes(
commonSpec ytv1.CommonSpec,
) *RemoteExecNode {
l := labeller.Labeller{
ObjectMeta: &nodes.ObjectMeta,
APIProxy: proxy,
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
8 changes: 4 additions & 4 deletions pkg/components/httpproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ func NewHTTPProxy(
spec ytv1.HTTPProxiesSpec) *HttpProxy {
resource := ytsaurus.GetResource()
l := labeller.Labeller{
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
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
5 changes: 2 additions & 3 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.MasterType,
},
ytsaurus.APIProxy(),
ytsaurus,
Expand Down Expand Up @@ -170,7 +169,7 @@ func TestJobScriptUpdateOnJobRestart(t *testing.T) {

cmData := testutil.FetchConfigMapData(
h,
"dummy-ms-init-job-config",
"dummy-yt-master-init-job-config",
consts.InitClusterScriptFileName,
)
require.Equal(t, scriptAfter, cmData)
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: "yt-query-tracker",
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: "yt-queue-agent",
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
8 changes: 4 additions & 4 deletions pkg/components/rpcproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ func NewRPCProxy(
spec ytv1.RPCProxiesSpec) *RpcProxy {
resource := ytsaurus.GetResource()
l := labeller.Labeller{
ObjectMeta: &resource.ObjectMeta,
APIProxy: ytsaurus.APIProxy(),
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 3fe949a

Please sign in to comment.