diff --git a/cmd/scheduler/main.go b/cmd/scheduler/main.go index 0751a686b..51e4df40e 100644 --- a/cmd/scheduler/main.go +++ b/cmd/scheduler/main.go @@ -12,7 +12,6 @@ func main() { logs.InitLogs() defer logs.FlushLogs() - // TODO: remove dependency on apiserver stopChan := apiserver.SetupSignalHandler() if err := app.NewSchedulerCommand(stopChan).Execute(); err != nil { diff --git a/pkg/controllers/execution/execution_controller.go b/pkg/controllers/execution/execution_controller.go index a5169609a..b932035eb 100644 --- a/pkg/controllers/execution/execution_controller.go +++ b/pkg/controllers/execution/execution_controller.go @@ -6,7 +6,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/record" @@ -90,8 +90,8 @@ func (c *Controller) syncWork(propagationWork *policyv1alpha1.PropagationWork) ( // isResourceApplied checking weather resource has been dispatched to member cluster or not func (c *Controller) isResourceApplied(propagationWorkStatus *policyv1alpha1.PropagationWorkStatus) bool { for _, condition := range propagationWorkStatus.Conditions { - if condition.Type == "Applied" { - if condition.Status == v1.ConditionTrue { + if condition.Type == policyv1alpha1.WorkApplied { + if condition.Status == metav1.ConditionTrue { return true } } @@ -191,7 +191,7 @@ func (c *Controller) syncToClusters(cluster *v1alpha1.Cluster, propagationWork * return err } - clusterObj, err := clusterDynamicClient.DynamicClientSet.Resource(dynamicResource).Namespace(workload.GetNamespace()).Get(context.TODO(), workload.GetName(), v1.GetOptions{}) + clusterObj, err := clusterDynamicClient.DynamicClientSet.Resource(dynamicResource).Namespace(workload.GetNamespace()).Get(context.TODO(), workload.GetName(), metav1.GetOptions{}) if err != nil { klog.Errorf("Failed to get resource %v from member cluster, err is %v ", workload.GetName(), err) return err @@ -235,16 +235,12 @@ func (c *Controller) removeFinalizer(propagationWork *policyv1alpha1.Propagation // updateAppliedCondition update the Applied condition for the given PropagationWork func (c *Controller) updateAppliedCondition(propagationWork *policyv1alpha1.PropagationWork) error { - currentTime := v1.Now() - propagationWorkApplied := "Applied" - appliedSuccess := "AppliedSuccess" - resourceApplied := "Success sync resource in member cluster" - newPropagationWorkAppliedCondition := v1.Condition{ - Type: propagationWorkApplied, - Status: v1.ConditionTrue, - Reason: appliedSuccess, - Message: resourceApplied, - LastTransitionTime: currentTime, + newPropagationWorkAppliedCondition := metav1.Condition{ + Type: policyv1alpha1.WorkApplied, + Status: metav1.ConditionTrue, + Reason: "AppliedSuccessful", + Message: "Manifest has been successfully applied", + LastTransitionTime: metav1.Now(), } propagationWork.Status.Conditions = append(propagationWork.Status.Conditions, newPropagationWorkAppliedCondition) err := c.Client.Status().Update(context.TODO(), propagationWork) diff --git a/pkg/util/cluster.go b/pkg/util/cluster.go index c557be9a8..9b95a84ad 100644 --- a/pkg/util/cluster.go +++ b/pkg/util/cluster.go @@ -14,7 +14,6 @@ import ( // IsClusterReady tells whether the cluster status in 'Ready' condition. func IsClusterReady(clusterStatus *v1alpha1.ClusterStatus) bool { for _, condition := range clusterStatus.Conditions { - // TODO(RainbowMango): Condition type should be defined in API, and after that update this hard code accordingly. if condition.Type == v1alpha1.ClusterConditionReady { if condition.Status == metav1.ConditionTrue { return true