Skip to content

Commit 1a8dc3c

Browse files
author
Aaron Schlesinger
committed
fix(git,gitreceive,sshd): make builder pod image pull policies configurable
1 parent b0d8941 commit 1a8dc3c

5 files changed

Lines changed: 61 additions & 16 deletions

File tree

pkg/git/git.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ REPOSITORY="$RECEIVE_REPO" \
3838
USERNAME="$RECEIVE_USER" \
3939
FINGERPRINT="$RECEIVE_FINGERPRINT" \
4040
POD_NAMESPACE="$POD_NAMESPACE" \
41+
SLUG_BUILDER_IMAGE_PULL_POLICY="$SLUG_BUILDER_IMAGE_PULL_POLICY" \
42+
DOCKER_BUILDER_IMAGE_PULL_POLICY="$DOCKER_BUILDER_IMAGE_PULL_POLICY" \
4143
boot git-receive | strip_remote_prefix
4244
`
4345

pkg/gitreceive/build.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,15 @@ func run(cmd *exec.Cmd) error {
4242
return cmd.Run()
4343
}
4444

45-
func build(conf *Config, storageDriver storagedriver.StorageDriver, kubeClient *client.Client, fs sys.FS, env sys.Env, builderKey, rawGitSha string) error {
45+
func build(
46+
conf *Config,
47+
storageDriver storagedriver.StorageDriver,
48+
kubeClient *client.Client,
49+
fs sys.FS,
50+
env sys.Env,
51+
builderKey,
52+
rawGitSha string) error {
53+
4654
repo := conf.Repository
4755
gitSha, err := git.NewSha(rawGitSha)
4856
if err != nil {
@@ -123,8 +131,9 @@ func build(conf *Config, storageDriver storagedriver.StorageDriver, kubeClient *
123131
appConf.Values,
124132
slugBuilderInfo.TarKey(),
125133
slugName,
126-
conf.DockerBuilderImage,
127134
conf.StorageType,
135+
conf.DockerBuilderImage,
136+
conf.DockerBuilderImagePullPolicy,
128137
)
129138
} else {
130139
buildPodName = slugBuilderPodName(appName, gitSha.Short())
@@ -136,8 +145,9 @@ func build(conf *Config, storageDriver storagedriver.StorageDriver, kubeClient *
136145
slugBuilderInfo.TarKey(),
137146
slugBuilderInfo.PushKey(),
138147
buildPackURL,
139-
conf.SlugBuilderImage,
140148
conf.StorageType,
149+
conf.SlugBuilderImage,
150+
conf.SlugBuilderImagePullPolicy,
141151
)
142152
}
143153

pkg/gitreceive/config.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ type Config struct {
1616
// k8s service discovery env vars
1717
ControllerHost string `envconfig:"DEIS_CONTROLLER_SERVICE_HOST" required:"true"`
1818
ControllerPort string `envconfig:"DEIS_CONTROLLER_SERVICE_PORT" required:"true"`
19-
RegistryHost string `envconfig:"DEIS_REGISTRY_SERVICE_HOST" required:"true"`
20-
RegistryPort string `envconfig:"DEIS_REGISTRY_SERVICE_PORT" required:"true"`
19+
RegistryHost string `envconfig:"DEIS_REGISTRY_SERVICE_HOST" required:"true"`
20+
RegistryPort string `envconfig:"DEIS_REGISTRY_SERVICE_PORT" required:"true"`
2121

2222
GitHome string `envconfig:"GIT_HOME" required:"true"`
2323
SSHConnection string `envconfig:"SSH_CONNECTION" required:"true"`
@@ -34,6 +34,8 @@ type Config struct {
3434
ObjectStorageWaitDurationMSec int `envconfig:"OBJECT_STORAGE_WAIT_DURATION" default:"300000"` // 5 minutes
3535
SlugBuilderImage string `envconfig:"SLUGBUILDER_IMAGE_NAME" default:"quay.io/deisci/slugbuilder:v2-beta"`
3636
DockerBuilderImage string `envconfig:"DOCKERBUILDER_IMAGE_NAME" default:"quay.io/deisci/dockerbuilder:v2-beta"`
37+
SlugBuilderImagePullPolicy string `envconfig:"SLUG_BUILDER_IMAGE_PULL_POLICY" default:"Always"`
38+
DockerBuilderImagePullPolicy string `envconfig:"DOCKER_BUILDER_IMAGE_PULL_POLICY" default:"Always"`
3739
StorageType string `envconfig:"BUILDER_STORAGE" default:"minio"`
3840
}
3941

pkg/gitreceive/k8s_util.go

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,19 @@ func slugBuilderPodName(appName, shortSha string) string {
3535
return fmt.Sprintf("slugbuild-%s-%s-%s", appName, shortSha, uid)
3636
}
3737

38-
func dockerBuilderPod(debug bool, name, namespace string, env map[string]interface{}, tarKey, imageName, dockerBuilderImage, storageType string) *api.Pod {
39-
pod := buildPod(debug, name, namespace, env)
38+
func dockerBuilderPod(
39+
debug bool,
40+
name,
41+
namespace string,
42+
env map[string]interface{},
43+
tarKey,
44+
imageName,
45+
storageType,
46+
dockerBuilderImage,
47+
dockerBuilderImagePullPolicy string,
48+
) *api.Pod {
49+
50+
pod := buildPod(debug, name, namespace, dockerBuilderImagePullPolicy, env)
4051

4152
pod.Spec.Containers[0].Name = dockerBuilderName
4253
pod.Spec.Containers[0].Image = dockerBuilderImage
@@ -62,8 +73,20 @@ func dockerBuilderPod(debug bool, name, namespace string, env map[string]interfa
6273
return &pod
6374
}
6475

65-
func slugbuilderPod(debug bool, name, namespace string, env map[string]interface{}, tarKey, putKey, buildpackURL, slugBuilderImage, storageType string) *api.Pod {
66-
pod := buildPod(debug, name, namespace, env)
76+
func slugbuilderPod(
77+
debug bool,
78+
name,
79+
namespace string,
80+
env map[string]interface{},
81+
tarKey,
82+
putKey,
83+
buildpackURL,
84+
storageType,
85+
slugBuilderImage,
86+
slugBuilderImagePullPolicy string,
87+
) *api.Pod {
88+
89+
pod := buildPod(debug, name, namespace, slugBuilderImagePullPolicy, env)
6790

6891
pod.Spec.Containers[0].Name = slugBuilderName
6992
pod.Spec.Containers[0].Image = slugBuilderImage
@@ -79,7 +102,13 @@ func slugbuilderPod(debug bool, name, namespace string, env map[string]interface
79102
return &pod
80103
}
81104

82-
func buildPod(debug bool, name, namespace string, env map[string]interface{}) api.Pod {
105+
func buildPod(
106+
debug bool,
107+
name,
108+
namespace,
109+
imagePullPolicy string,
110+
env map[string]interface{}) api.Pod {
111+
83112
pod := api.Pod{
84113
Spec: api.PodSpec{
85114
RestartPolicy: api.RestartPolicyNever,

pkg/sshd/config.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import (
66

77
// Config represents the required SSH server configuration.
88
type Config struct {
9-
SSHHostIP string `envconfig:"SSH_HOST_IP" default:"0.0.0.0" required:"true"`
10-
SSHHostPort int `envconfig:"SSH_HOST_PORT" default:"2223" required:"true"`
11-
HealthSrvPort int `envconfig:"HEALTH_SERVER_PORT" default:"8092"`
12-
HealthSrvTestStorageRegion string `envconfig:"STORAGE_REGION" default:"us-east-1"`
13-
CleanerPollSleepDurationSec int `envconfig:"CLEANER_POLL_SLEEP_DURATION_SEC" default:"1"`
14-
StorageType string `envconfig:"BUILDER_STORAGE" default:"minio"`
9+
SSHHostIP string `envconfig:"SSH_HOST_IP" default:"0.0.0.0" required:"true"`
10+
SSHHostPort int `envconfig:"SSH_HOST_PORT" default:"2223" required:"true"`
11+
HealthSrvPort int `envconfig:"HEALTH_SERVER_PORT" default:"8092"`
12+
HealthSrvTestStorageRegion string `envconfig:"STORAGE_REGION" default:"us-east-1"`
13+
CleanerPollSleepDurationSec int `envconfig:"CLEANER_POLL_SLEEP_DURATION_SEC" default:"1"`
14+
StorageType string `envconfig:"BUILDER_STORAGE" default:"minio"`
15+
SlugBuilderImagePullPolicy string `envconfig:"SLUG_BUILDER_IMAGE_PULL_POLICY" default:"Always"`
16+
DockerBuilderImagePullPolicy string `envconfig:"DOCKER_BUILDER_IMAGE_PULL_POLICY" default:"Always"`
1517
}
1618

1719
// CleanerPollSleepDuration returns c.CleanerPollSleepDurationSec as a time.Duration.

0 commit comments

Comments
 (0)