Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use /tmp/termination-log for windows and linux #1052

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions pkg/apis/build/v1alpha2/build_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ const (
secretVolumeNameTemplate = "secret-volume-%v"
pullSecretVolumeNameTemplate = "pull-secret-volume-%v"

completionTerminationMessagePathWindows = "/dev/termination-log"
completionTerminationMessagePathLinux = "/tmp/termination-log"
cosignDefaultSecretPath = "/var/build-secrets/cosign/%s"
defaultSecretPath = "/var/build-secrets/%s"
ReportTOMLPath = "/var/report/report.toml"
completionTerminationMessagePath = "/tmp/termination-log"
cosignDefaultSecretPath = "/var/build-secrets/cosign/%s"
defaultSecretPath = "/var/build-secrets/%s"
ReportTOMLPath = "/var/report/report.toml"

BuildLabel = "kpack.io/build"
k8sOSLabel = "kubernetes.io/os"
Expand Down Expand Up @@ -99,9 +98,9 @@ func (bpi *BuildPodImages) completion(os string) string {
func terminationMsgPath(os string) string {
switch os {
case "windows":
return completionTerminationMessagePathWindows
return ""
default:
return completionTerminationMessagePathLinux
return completionTerminationMessagePath
}
}

Expand Down Expand Up @@ -345,7 +344,7 @@ func (b *Build) BuildPod(images BuildPodImages, buildContext BuildContext) (*cor
if err != nil {
return nil, errors.Wrapf(err, "parsing creation time %s", b.Spec.CreationTime)
}

return &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: b.PodName(),
Expand Down Expand Up @@ -374,7 +373,7 @@ func (b *Build) BuildPod(images BuildPodImages, buildContext BuildContext) (*cor
Env: []corev1.EnvVar{
homeEnv,
{Name: CacheTagEnvVar, Value: b.Spec.RegistryCacheTag()},
{Name: TerminationMessagePathEnvVar, Value: terminationMsgPath(buildContext.os())},
{Name: TerminationMessagePathEnvVar, Value: completionTerminationMessagePath},
},
Args: args(
b.notaryArgs(),
Expand Down Expand Up @@ -604,7 +603,7 @@ func (b *Build) BuildPod(images BuildPodImages, buildContext BuildContext) (*cor
if dateTime != nil {
return corev1.EnvVar{Name: "SOURCE_DATE_EPOCH", Value: strconv.Itoa(int(dateTime.Unix()))}
}
return corev1.EnvVar{Name:"", Value:""}
return corev1.EnvVar{Name: "", Value: ""}
}(),
func() corev1.EnvVar {
return corev1.EnvVar{
Expand Down Expand Up @@ -853,7 +852,7 @@ func (b *Build) rebasePod(buildContext BuildContext, images BuildPodImages) (*co
Command: []string{"/cnb/process/completion"},
Env: []corev1.EnvVar{
{Name: CacheTagEnvVar, Value: b.Spec.RegistryCacheTag()},
{Name: TerminationMessagePathEnvVar, Value: terminationMsgPath(buildContext.os())},
{Name: TerminationMessagePathEnvVar, Value: completionTerminationMessagePath},
},
Args: args(
b.notaryArgs(),
Expand Down Expand Up @@ -1234,7 +1233,6 @@ func envs(envs []corev1.EnvVar, envVars ...corev1.EnvVar) []corev1.EnvVar {
return envs
}


func parseTime(providedTime string) (*time.Time, error) {
var parsedTime time.Time
switch providedTime {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/build/v1alpha2/build_pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2640,7 +2640,7 @@ func testBuildPod(t *testing.T, when spec.G, it spec.S) {
assert.Equal(t, completionContainer.Env, []corev1.EnvVar{
{Name: "USERPROFILE", Value: "/builder/home"},
{Name: "CACHE_TAG", Value: ""},
{Name: "TERMINATION_MESSAGE_PATH", Value: "/dev/termination-log"},
{Name: "TERMINATION_MESSAGE_PATH", Value: "/tmp/termination-log"},
})
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/build/v1alpha2/cluster_stack_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (cs *ClusterStackSpec) convertTo(to *v1alpha1.ClusterStackSpec) {
func (cs *ClusterStackSpec) convertToAnnotations(toAnnotations map[string]string) error {
if cs.ServiceAccountRef != nil {
bytes, err := json.Marshal(cs.ServiceAccountRef)
if err!= nil {
if err != nil {
return err
}
toAnnotations[clusterStackServiceAccountRefAnnotation] = string(bytes)
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/build/v1alpha2/cluster_stack_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func testClusterStackConversion(t *testing.T, when spec.G, it spec.S) {
when("converting to and from v1alpha1", func() {
v1alpha2ClusterStack := &ClusterStack{
ObjectMeta: metav1.ObjectMeta{
Name: "test-clusterstack",
Name: "test-clusterstack",
Annotations: map[string]string{},
},
Spec: ClusterStackSpec{
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/build/v1alpha2/cluster_store_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (s *ClusterStore) ConvertTo(_ context.Context, to apis.Convertible) error {
func (cs *ClusterStoreSpec) convertToAnnotations(toAnnotations map[string]string) error {
if cs.ServiceAccountRef != nil {
bytes, err := json.Marshal(cs.ServiceAccountRef)
if err!= nil {
if err != nil {
return err
}
toAnnotations[clusterStoreServiceAccountRefAnnotation] = string(bytes)
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/build/v1alpha2/cluster_store_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func testClusterStoreConversion(t *testing.T, when spec.G, it spec.S) {

v1alpha1ClusterStore := &v1alpha1.ClusterStore{
ObjectMeta: metav1.ObjectMeta{
Name: "test-cluster-store",
Name: "test-cluster-store",
Annotations: map[string]string{
"some-key": "some-value",
"some-key": "some-value",
"kpack.io/clusterStoreServiceAccountRef": `{"namespace":"some-namespace","name":"some-service-account"}`,
},
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/build/v1alpha2/image_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (is *ImageSpec) convertTo(to *v1alpha1.ImageSpec) {
}
}

func (i *Image)convertFromAnnotations(fromAnnotations *map[string]string) error {
func (i *Image) convertFromAnnotations(fromAnnotations *map[string]string) error {
is := &i.Spec
ia := i.Annotations
if servicesJson, ok := (*fromAnnotations)[servicesConversionAnnotation]; ok {
Expand Down Expand Up @@ -144,7 +144,7 @@ func (i *Image)convertFromAnnotations(fromAnnotations *map[string]string) error
if is.Build == nil {
is.Build = &ImageBuild{}
}
temp , err := strconv.ParseInt(buildTimeout, 10, 64)
temp, err := strconv.ParseInt(buildTimeout, 10, 64)
if err != nil {
return err
}
Expand Down Expand Up @@ -193,7 +193,7 @@ func (i *Image)convertFromAnnotations(fromAnnotations *map[string]string) error
return nil
}

func (is *ImageSpec)convertToAnnotations(toAnnotations map[string]string) error{
func (is *ImageSpec) convertToAnnotations(toAnnotations map[string]string) error {
if build := is.Build; build != nil {
if len(build.Services) > 0 {
bytes, err := json.Marshal(build.Services)
Expand Down
30 changes: 15 additions & 15 deletions pkg/apis/build/v1alpha2/image_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func testImageConversion(t *testing.T, when spec.G, it spec.S) {
},
Tolerations: []corev1.Toleration{
{
Key: "some-key",
Key: "some-key",
Value: "some-value",
},
},
Expand All @@ -78,11 +78,11 @@ func testImageConversion(t *testing.T, when spec.G, it spec.S) {
Limits: corev1.ResourceList{"some-limit": resource.Quantity{}},
Requests: corev1.ResourceList{"some-request": resource.Quantity{}},
},
NodeSelector: map[string]string{"some-node-selector-key":"some-node-selector-value"},
Affinity: &affinity,
NodeSelector: map[string]string{"some-node-selector-key": "some-node-selector-value"},
Affinity: &affinity,
RuntimeClassName: &runtimeClassName,
SchedulerName: "some-scheduler-name",
BuildTimeout: &buildTimeout,
SchedulerName: "some-scheduler-name",
BuildTimeout: &buildTimeout,
},
Notary: &corev1alpha1.NotaryConfig{
V1: &corev1alpha1.NotaryV1Config{
Expand Down Expand Up @@ -129,17 +129,17 @@ func testImageConversion(t *testing.T, when spec.G, it spec.S) {
Name: "my-super-convertable-image",
Annotations: map[string]string{
"kpack.io/services": `[{"kind":"Secret","name":"some-secret","apiVersion":"v1"}]`,
"kpack.io/tolerations": `[{"key":"some-key","value":"some-value"}]`,
"kpack.io/nodeSelector": `{"some-node-selector-key":"some-node-selector-value"}`,
"kpack.io/affinity": `{}`,
"kpack.io/runtimeClassName": "some-runtime-class-name",
"kpack.io/schedulerName": "some-scheduler-name",
"kpack.io/buildTimeout": "7",
"kpack.io/tolerations": `[{"key":"some-key","value":"some-value"}]`,
"kpack.io/nodeSelector": `{"some-node-selector-key":"some-node-selector-value"}`,
"kpack.io/affinity": `{}`,
"kpack.io/runtimeClassName": "some-runtime-class-name",
"kpack.io/schedulerName": "some-scheduler-name",
"kpack.io/buildTimeout": "7",
"kpack.io/cache.volume.storageClassName": "some-storage-class",
"kpack.io/cache.registry.tag": "some-tag",
"kpack.io/projectDescriptorPath": "some-project-descriptor-path",
"kpack.io/cosignAnnotation": `[{"name":"some-cosign-name","value":"some-cosign-value"}]`,
"kpack.io/defaultProcess": "some-default-process",
"kpack.io/cache.registry.tag": "some-tag",
"kpack.io/projectDescriptorPath": "some-project-descriptor-path",
"kpack.io/cosignAnnotation": `[{"name":"some-cosign-name","value":"some-cosign-value"}]`,
"kpack.io/defaultProcess": "some-default-process",
},
},
Spec: v1alpha1.ImageSpec{
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/build/v1alpha2/image_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func testImageValidation(t *testing.T, when spec.G, it spec.S) {
assert.Nil(t, err)
})

it ("pass if it sets to a valid timestamp", func() {
it("pass if it sets to a valid timestamp", func() {
image.Spec.Build.CreationTime = "1566172801" //Mon Aug 19 2019 00:00:01 GMT+0000
err := image.Validate(ctx)
assert.Nil(t, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/openapi/openapi_generated.go

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