(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec)
| 3868 | } |
| 3869 | |
| 3870 | func applyUpdateStrategyConfig(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec) error { |
| 3871 | switch config.Daemonsets.UpdateStrategy { |
| 3872 | case "OnDelete": |
| 3873 | obj.Spec.UpdateStrategy = appsv1.DaemonSetUpdateStrategy{Type: appsv1.OnDeleteDaemonSetStrategyType} |
| 3874 | case "RollingUpdate": |
| 3875 | fallthrough |
| 3876 | default: |
| 3877 | // update config for RollingUpdate strategy |
| 3878 | if config.Daemonsets.RollingUpdate == nil || config.Daemonsets.RollingUpdate.MaxUnavailable == "" { |
| 3879 | return nil |
| 3880 | } |
| 3881 | if strings.HasPrefix(obj.Name, commonDriverDaemonsetName) { |
| 3882 | // disallow setting RollingUpdate strategy with the driver container |
| 3883 | return nil |
| 3884 | } |
| 3885 | var intOrString intstr.IntOrString |
| 3886 | if strings.HasSuffix(config.Daemonsets.RollingUpdate.MaxUnavailable, "%") { |
| 3887 | intOrString = intstr.IntOrString{Type: intstr.String, StrVal: config.Daemonsets.RollingUpdate.MaxUnavailable} |
| 3888 | } else { |
| 3889 | int64Val, err := strconv.ParseInt(config.Daemonsets.RollingUpdate.MaxUnavailable, 10, 32) |
| 3890 | if err != nil { |
| 3891 | return fmt.Errorf("failed to apply rolling update config: %s", err) |
| 3892 | } |
| 3893 | intOrString = intstr.IntOrString{Type: intstr.Int, IntVal: int32(int64Val)} |
| 3894 | } |
| 3895 | rollingUpdateSpec := appsv1.RollingUpdateDaemonSet{MaxUnavailable: &intOrString} |
| 3896 | obj.Spec.UpdateStrategy = appsv1.DaemonSetUpdateStrategy{Type: appsv1.RollingUpdateDaemonSetStrategyType, RollingUpdate: &rollingUpdateSpec} |
| 3897 | } |
| 3898 | return nil |
| 3899 | } |
| 3900 | |
| 3901 | func transformValidationInitContainer(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec) error { |
| 3902 | for i, initContainer := range obj.Spec.Template.Spec.InitContainers { |
no outgoing calls