Skip to content

Commit

Permalink
Init job creates from PrimaryMasters.InstanceSpec image if specified
Browse files Browse the repository at this point in the history
  • Loading branch information
wilwell committed Sep 9, 2024
1 parent 5863668 commit ee42949
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/components/chyt.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func NewChyt(
"user",
consts.ClientConfigFileName,
ytsaurus.Spec.CoreImage,
&ytsaurus.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetNativeClientConfig),
initEnvironment: NewInitJob(
&l,
Expand All @@ -63,6 +64,7 @@ func NewChyt(
"release",
consts.ClientConfigFileName,
chyt.GetResource().Spec.Image,
&ytsaurus.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetNativeClientConfig),
initChPublicJob: NewInitJob(
&l,
Expand All @@ -72,6 +74,7 @@ func NewChyt(
"ch-public",
consts.ClientConfigFileName,
chyt.GetResource().Spec.Image,
&ytsaurus.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetNativeClientConfig),
secret: resources.NewStringSecret(
l.GetSecretName(),
Expand Down
8 changes: 7 additions & 1 deletion pkg/components/init_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

ytv1 "github.com/ytsaurus/ytsaurus-k8s-operator/api/v1"
"github.com/ytsaurus/ytsaurus-k8s-operator/pkg/apiproxy"
"github.com/ytsaurus/ytsaurus-k8s-operator/pkg/consts"
"github.com/ytsaurus/ytsaurus-k8s-operator/pkg/labeller"
Expand Down Expand Up @@ -56,7 +57,12 @@ func NewInitJob(
conditionsManager apiproxy.ConditionManager,
imagePullSecrets []corev1.LocalObjectReference,
name, configFileName, image string,
instanceSpec *ytv1.InstanceSpec,
generator ytconfig.YsonGeneratorFunc) *InitJob {
trueImage := image
if instanceSpec.Image != nil {
trueImage = *instanceSpec.Image
}
return &InitJob{
baseComponent: baseComponent{
labeller: labeller,
Expand All @@ -65,7 +71,7 @@ func NewInitJob(
conditionsManager: conditionsManager,
imagePullSecrets: imagePullSecrets,
initCompletedCondition: fmt.Sprintf("%s%sInitJobCompleted", name, labeller.GetFullComponentName()),
image: image,
image: trueImage,
initJob: resources.NewJob(
labeller.GetInitJobName(name),
labeller,
Expand Down
1 change: 1 addition & 0 deletions pkg/components/init_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func newTestJob(ytsaurus *apiproxy.Ytsaurus) *InitJob {
"dummy",
consts.ClientConfigFileName,
"dummy-image",
&ytsaurus.GetResource().Spec.PrimaryMasters.InstanceSpec,
func() ([]byte, error) { return []byte("dummy-cfg"), nil },
)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/components/master.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func NewMaster(cfgen *ytconfig.Generator, ytsaurus *apiproxy.Ytsaurus) *Master {
"default",
consts.ClientConfigFileName,
resource.Spec.CoreImage,
&resource.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetNativeClientConfig)

exitReadOnlyJob := NewInitJob(
Expand All @@ -80,6 +81,7 @@ func NewMaster(cfgen *ytconfig.Generator, ytsaurus *apiproxy.Ytsaurus) *Master {
"exit-read-only",
consts.ClientConfigFileName,
resource.Spec.CoreImage,
&resource.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetNativeClientConfig,
)

Expand Down
1 change: 1 addition & 0 deletions pkg/components/query_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func NewQueryTracker(
"qt-state",
consts.ClientConfigFileName,
image,
&resource.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetNativeClientConfig),
secret: resources.NewStringSecret(
l.GetSecretName(),
Expand Down
1 change: 1 addition & 0 deletions pkg/components/queue_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func NewQueueAgent(
"qa-state",
consts.ClientConfigFileName,
image,
&resource.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetNativeClientConfig),
secret: resources.NewStringSecret(
l.GetSecretName(),
Expand Down
2 changes: 2 additions & 0 deletions pkg/components/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func NewScheduler(
"user",
consts.ClientConfigFileName,
resource.Spec.CoreImage,
&resource.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetNativeClientConfig),
initOpArchive: NewInitJob(
&l,
Expand All @@ -89,6 +90,7 @@ func NewScheduler(
"op-archive",
consts.ClientConfigFileName,
resource.Spec.CoreImage,
&resource.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetNativeClientConfig),
secret: resources.NewStringSecret(
l.GetSecretName(),
Expand Down
2 changes: 2 additions & 0 deletions pkg/components/spyt.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func NewSpyt(
"user",
consts.ClientConfigFileName,
ytsaurus.Spec.CoreImage,
&ytsaurus.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetNativeClientConfig),
initEnvironment: NewInitJob(
&l,
Expand All @@ -61,6 +62,7 @@ func NewSpyt(
"spyt-environment",
consts.ClientConfigFileName,
spyt.GetResource().Spec.Image,
&ytsaurus.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetNativeClientConfig),
secret: resources.NewStringSecret(
l.GetSecretName(),
Expand Down
2 changes: 2 additions & 0 deletions pkg/components/strawberry_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func NewStrawberryController(
"user",
consts.ClientConfigFileName,
resource.Spec.CoreImage,
&resource.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetNativeClientConfig),
initChytClusterJob: NewInitJob(
&l,
Expand All @@ -91,6 +92,7 @@ func NewStrawberryController(
"cluster",
ChytInitClusterJobConfigFileName,
image,
&resource.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetChytInitClusterConfig),
secret: resources.NewStringSecret(
l.GetSecretName(),
Expand Down
1 change: 1 addition & 0 deletions pkg/components/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func NewUI(cfgen *ytconfig.Generator, ytsaurus *apiproxy.Ytsaurus, master Compon
"default",
consts.ClientConfigFileName,
resource.Spec.CoreImage,
&resource.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetNativeClientConfig),
secret: resources.NewStringSecret(
l.GetSecretName(),
Expand Down
1 change: 1 addition & 0 deletions pkg/components/yql_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func NewYQLAgent(cfgen *ytconfig.Generator, ytsaurus *apiproxy.Ytsaurus, master
"yql-agent-environment",
consts.ClientConfigFileName,
resource.Spec.CoreImage,
&resource.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetNativeClientConfig),
secret: resources.NewStringSecret(
l.GetSecretName(),
Expand Down
1 change: 1 addition & 0 deletions pkg/components/ytsaurus_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func NewYtsaurusClient(
"user",
consts.ClientConfigFileName,
resource.Spec.CoreImage,
&resource.Spec.PrimaryMasters.InstanceSpec,
cfgen.GetNativeClientConfig),
secret: resources.NewStringSecret(
l.GetSecretName(),
Expand Down

0 comments on commit ee42949

Please sign in to comment.