Skip to content

Commit 6e3682e

Browse files
committed
Adjust controller file structure to match logical
Signed-off-by: Mike Spreitzer <mspreitz@us.ibm.com>
1 parent 3003b33 commit 6e3682e

File tree

3 files changed

+36
-73
lines changed

3 files changed

+36
-73
lines changed

pkg/controller/dual-pods/controller.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import (
2323
"sync"
2424
"sync/atomic"
2525

26-
"github.com/spf13/pflag"
27-
2826
corev1 "k8s.io/api/core/v1"
2927
"k8s.io/apimachinery/pkg/api/errors"
3028
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -69,14 +67,6 @@ type Controller interface {
6967
Start(context.Context) error
7068
}
7169

72-
type CommonConfig struct {
73-
Verbosity int // `-v`
74-
}
75-
76-
func (cc *CommonConfig) AddToFlagSet(name string, flags *pflag.FlagSet) {
77-
flags.IntVar(&cc.Verbosity, name+"-verbosity", cc.Verbosity, "-v setting for "+name)
78-
}
79-
8070
// NewController makes a new dual pods controller.
8171
// The given namespace is the one to focus on.
8272
func NewController(

pkg/controller/dual-pods/server-requesting.go renamed to pkg/controller/dual-pods/inference-server.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,42 @@ func (ctl *controller) ensureReqStatus(ctx context.Context, requestingPod *corev
365365
return err, false
366366
}
367367

368+
func GetOwner(pod *corev1.Pod) (infSvrItem, bool) {
369+
ownerRef := metav1.GetControllerOfNoCopy(pod)
370+
if ownerRef != nil && ownerRef.Kind == "Pod" {
371+
return infSvrItem{ownerRef.UID, ownerRef.Name}, true
372+
}
373+
return infSvrItem{}, false
374+
}
375+
376+
func postToReadiness(url string) error {
377+
client := &http.Client{
378+
Timeout: 5 * time.Second,
379+
}
380+
381+
resp, err := client.Post(url, "application/json", nil)
382+
if err != nil {
383+
return fmt.Errorf("http post %q: %w", url, err)
384+
}
385+
defer resp.Body.Close() //nolint:errcheck
386+
387+
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
388+
body, _ := io.ReadAll(resp.Body)
389+
return fmt.Errorf("unexpected status %d: %s", resp.StatusCode, string(body))
390+
}
391+
392+
return nil
393+
}
394+
395+
func isPodReady(pod *corev1.Pod) bool {
396+
for _, cond := range pod.Status.Conditions {
397+
if cond.Type == corev1.PodReady && cond.Status == corev1.ConditionTrue {
398+
return true
399+
}
400+
}
401+
return false
402+
}
403+
368404
var coreScheme *k8sruntime.Scheme
369405
var codecFactory k8sserializer.CodecFactory
370406
var podDecoder k8sruntime.Decoder

pkg/controller/dual-pods/server-running.go

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)