@@ -733,8 +733,9 @@ func (feast *FeastServices) setInitContainer(podSpec *corev1.PodSpec, fsYamlB64
733733 Command : []string {"feast" , "apply" },
734734 WorkingDir : featureRepoDir ,
735735 }
736- // feast apply needs DB/store connectivity, so inherit env/envFrom
737- // from all server container configs (registry, online, offline).
736+ // feast apply needs DB/store connectivity, so inherit env, envFrom
737+ // and volume mounts from all server container configs.
738+ seen := map [string ]bool {}
738739 for _ , feastType := range []FeastServiceType {RegistryFeastType , OnlineFeastType , OfflineFeastType } {
739740 if serverConfigs := feast .getServerConfigs (feastType ); serverConfigs != nil {
740741 if serverConfigs .OptionalCtrConfigs .Env != nil {
@@ -743,6 +744,12 @@ func (feast *FeastServices) setInitContainer(podSpec *corev1.PodSpec, fsYamlB64
743744 if serverConfigs .OptionalCtrConfigs .EnvFrom != nil {
744745 applyContainer .EnvFrom = append (applyContainer .EnvFrom , * serverConfigs .OptionalCtrConfigs .EnvFrom ... )
745746 }
747+ for _ , vm := range feast .getVolumeMounts (feastType ) {
748+ if ! seen [vm .MountPath ] {
749+ applyContainer .VolumeMounts = append (applyContainer .VolumeMounts , vm )
750+ seen [vm .MountPath ] = true
751+ }
752+ }
746753 }
747754 }
748755 podSpec .InitContainers = append (podSpec .InitContainers , applyContainer )
@@ -1427,6 +1434,67 @@ func IsDeploymentAvailable(conditions []appsv1.DeploymentCondition) bool {
14271434 return false
14281435}
14291436
1437+ // GetPodContainerFailureMessage inspects pods belonging to the given deployment
1438+ // and returns a human-readable message describing the first init or regular
1439+ // container that is in a failing state. Returns empty string if no failure found.
1440+ func (feast * FeastServices ) GetPodContainerFailureMessage (deploy appsv1.Deployment ) string {
1441+ podList := corev1.PodList {}
1442+ labels := feast .getLabels ()
1443+ if err := feast .Handler .Client .List (feast .Handler .Context , & podList ,
1444+ client .InNamespace (deploy .Namespace ),
1445+ client .MatchingLabels (labels ),
1446+ ); err != nil {
1447+ return ""
1448+ }
1449+ for i := range podList .Items {
1450+ pod := & podList .Items [i ]
1451+ if msg := initContainerFailureMessage (pod ); msg != "" {
1452+ return msg
1453+ }
1454+ if msg := containerFailureMessage (pod ); msg != "" {
1455+ return msg
1456+ }
1457+ }
1458+ return ""
1459+ }
1460+
1461+ func initContainerFailureMessage (pod * corev1.Pod ) string {
1462+ for _ , cs := range pod .Status .InitContainerStatuses {
1463+ if cs .State .Waiting != nil && cs .State .Waiting .Reason != "" && cs .State .Waiting .Reason != "PodInitializing" {
1464+ return "Init container '" + cs .Name + "' waiting: " + cs .State .Waiting .Reason +
1465+ messageIfPresent (cs .State .Waiting .Message )
1466+ }
1467+ if cs .State .Terminated != nil && cs .State .Terminated .ExitCode != 0 {
1468+ return "Init container '" + cs .Name + "' failed with exit code " +
1469+ strconv .Itoa (int (cs .State .Terminated .ExitCode )) +
1470+ messageIfPresent (cs .State .Terminated .Message )
1471+ }
1472+ }
1473+ return ""
1474+ }
1475+
1476+ func containerFailureMessage (pod * corev1.Pod ) string {
1477+ for _ , cs := range pod .Status .ContainerStatuses {
1478+ if cs .State .Waiting != nil && cs .State .Waiting .Reason != "" && cs .State .Waiting .Reason != "ContainerCreating" {
1479+ return "Container '" + cs .Name + "' waiting: " + cs .State .Waiting .Reason +
1480+ messageIfPresent (cs .State .Waiting .Message )
1481+ }
1482+ if cs .State .Terminated != nil && cs .State .Terminated .ExitCode != 0 {
1483+ return "Container '" + cs .Name + "' failed with exit code " +
1484+ strconv .Itoa (int (cs .State .Terminated .ExitCode )) +
1485+ messageIfPresent (cs .State .Terminated .Message )
1486+ }
1487+ }
1488+ return ""
1489+ }
1490+
1491+ func messageIfPresent (msg string ) string {
1492+ if msg != "" {
1493+ return " - " + msg
1494+ }
1495+ return ""
1496+ }
1497+
14301498// GetFeastRestServiceName returns the feast REST service object name based on service type
14311499func (feast * FeastServices ) GetFeastRestServiceName (feastType FeastServiceType ) string {
14321500 return feast .GetFeastServiceName (feastType ) + "-rest"
0 commit comments