Skip to content
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
2 changes: 1 addition & 1 deletion cmd/machine-config-controller/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func runbootstrapCmd(cmd *cobra.Command, args []string) {
flag.Parse()

// To help debugging, immediately log version
glog.Infof("Version: %+v (%s)", version.Version, version.Hash)
glog.Infof("Version: %+v (%s)", version.Raw, version.Hash)

if bootstrapOpts.manifestsDir == "" || bootstrapOpts.destinationDir == "" {
glog.Fatalf("--dest-dir or --manifest-dir not set")
Expand Down
2 changes: 1 addition & 1 deletion cmd/machine-config-controller/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func runStartCmd(cmd *cobra.Command, args []string) {
flag.Parse()

// To help debugging, immediately log version
glog.Infof("Version: %+v (%s)", version.Version, version.Hash)
glog.Infof("Version: %+v (%s)", version.Raw, version.Hash)

cb, err := clients.NewBuilder(startOpts.kubeconfig)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/machine-config-controller/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func runVersionCmd(cmd *cobra.Command, args []string) {
flag.Parse()

program := "MachineConfigController"
version := "v" + version.Version.String() + "-" + version.Hash
version := version.Raw + "-" + version.Hash

fmt.Println(program, version)
}
2 changes: 1 addition & 1 deletion cmd/machine-config-daemon/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func runStartCmd(cmd *cobra.Command, args []string) {
glog.V(2).Infof("Options parsed: %+v", startOpts)

// To help debugging, immediately log version
glog.Infof("Version: %+v (%s)", version.Version, version.Hash)
glog.Infof("Version: %+v (%s)", version.Raw, version.Hash)

onceFromMode := startOpts.onceFrom != ""
if !onceFromMode {
Expand Down
2 changes: 1 addition & 1 deletion cmd/machine-config-daemon/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func runVersionCmd(cmd *cobra.Command, args []string) {
flag.Parse()

program := "MachineConfigDaemon"
version := "v" + version.Version.String() + "-" + version.Hash
version := version.Raw + "-" + version.Hash

fmt.Println(program, version)
}
2 changes: 1 addition & 1 deletion cmd/machine-config-operator/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func runBootstrapCmd(cmd *cobra.Command, args []string) {
flag.Parse()

// To help debugging, immediately log version
glog.Infof("Version: %+v (%s)", version.Version, version.Hash)
glog.Infof("Version: %+v (%s)", version.Raw, version.Hash)

imgs := operator.Images{
RenderConfigImages: operator.RenderConfigImages{
Expand Down
2 changes: 1 addition & 1 deletion cmd/machine-config-operator/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func runStartCmd(cmd *cobra.Command, args []string) {
flag.Parse()

// To help debugging, immediately log version
glog.Infof("Version: %+v (%s)", version.Version, version.Hash)
glog.Infof("Version: %+v (%s)", version.Raw, version.Hash)

if startOpts.imagesFile == "" {
glog.Fatal("--images-json cannot be empty")
Expand Down
2 changes: 1 addition & 1 deletion cmd/machine-config-operator/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func runVersionCmd(cmd *cobra.Command, args []string) {
flag.Parse()

program := "MachineConfigOperator"
version := "v" + version.Version.String() + "-" + version.Hash
version := version.Raw + "-" + version.Hash

fmt.Println(program, version)
}
2 changes: 1 addition & 1 deletion cmd/machine-config-server/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func runBootstrapCmd(cmd *cobra.Command, args []string) {
flag.Parse()

// To help debugging, immediately log version
glog.Infof("Version: %+v (%s)", version.Version, version.Hash)
glog.Infof("Version: %+v (%s)", version.Raw, version.Hash)

bs, err := server.NewBootstrapServer(bootstrapOpts.serverBaseDir, bootstrapOpts.serverKubeConfig)

Expand Down
2 changes: 1 addition & 1 deletion cmd/machine-config-server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func runStartCmd(cmd *cobra.Command, args []string) {
flag.Parse()

// To help debugging, immediately log version
glog.Infof("Version: %+v (%s)", version.Version, version.Hash)
glog.Infof("Version: %+v (%s)", version.Raw, version.Hash)

if startOpts.apiserverURL == "" {
glog.Exitf("--apiserver-url cannot be empty")
Expand Down
2 changes: 1 addition & 1 deletion cmd/machine-config-server/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func runVersionCmd(cmd *cobra.Command, args []string) {
flag.Parse()

program := "MachineConfigServer"
version := "v" + version.Version.String() + "-" + version.Hash
version := version.Raw + "-" + version.Hash

fmt.Println(program, version)
}
2 changes: 1 addition & 1 deletion cmd/setup-etcd-environment/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func runRunCmd(cmd *cobra.Command, args []string) error {
flag.Parse()

// To help debugging, immediately log version
glog.Infof("Version: %+v (%s)", version.Version, version.Hash)
glog.Infof("Version: %+v (%s)", version.Raw, version.Hash)

if runOpts.discoverySRV == "" {
return errors.New("--discovery-srv cannot be empty")
Expand Down
2 changes: 1 addition & 1 deletion cmd/setup-etcd-environment/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func runVersionCmd(cmd *cobra.Command, args []string) {
flag.Parse()

program := "Setup Etcd Environment"
version := "v" + version.Version.String() + "-" + version.Hash
version := version.Raw + "-" + version.Hash

fmt.Println(program, version)
}
6 changes: 3 additions & 3 deletions pkg/controller/template/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// - does not modify `failing` condition.
func (ctrl *Controller) syncRunningStatus(ctrlconfig *mcfgv1.ControllerConfig) error {
updateFunc := func(cfg *mcfgv1.ControllerConfig) error {
reason := fmt.Sprintf("syncing towards (%d) generation using controller version %s", cfg.GetGeneration(), version.Version)
reason := fmt.Sprintf("syncing towards (%d) generation using controller version %s", cfg.GetGeneration(), version.Raw)
rcond := mcfgv1.NewControllerConfigStatusCondition(mcfgv1.TemplateControllerRunning, corev1.ConditionTrue, "", reason)
mcfgv1.SetControllerConfigStatusCondition(&cfg.Status, *rcond)
if cfg.GetGeneration() != cfg.Status.ObservedGeneration && mcfgv1.IsControllerConfigStatusConditionPresentAndEqual(cfg.Status.Conditions, mcfgv1.TemplateControllerCompleted, corev1.ConditionTrue) {
Expand All @@ -38,7 +38,7 @@ func (ctrl *Controller) syncFailingStatus(ctrlconfig *mcfgv1.ControllerConfig, o
return nil
}
updateFunc := func(cfg *mcfgv1.ControllerConfig) error {
message := fmt.Sprintf("failed to syncing towards (%d) generation using controller version %s: %v", cfg.GetGeneration(), version.Version, oerr)
message := fmt.Sprintf("failed to syncing towards (%d) generation using controller version %s: %v", cfg.GetGeneration(), version.Raw, oerr)
fcond := mcfgv1.NewControllerConfigStatusCondition(mcfgv1.TemplateControllerFailing, corev1.ConditionTrue, "", message)
mcfgv1.SetControllerConfigStatusCondition(&cfg.Status, *fcond)
acond := mcfgv1.NewControllerConfigStatusCondition(mcfgv1.TemplateControllerCompleted, corev1.ConditionFalse, "", "")
Expand All @@ -59,7 +59,7 @@ func (ctrl *Controller) syncFailingStatus(ctrlconfig *mcfgv1.ControllerConfig, o
// - sets the `completed` condition to `true`
func (ctrl *Controller) syncCompletedStatus(ctrlconfig *mcfgv1.ControllerConfig) error {
updateFunc := func(cfg *mcfgv1.ControllerConfig) error {
reason := fmt.Sprintf("sync completed towards (%d) generation using controller version %s", cfg.GetGeneration(), version.Version)
reason := fmt.Sprintf("sync completed towards (%d) generation using controller version %s", cfg.GetGeneration(), version.Raw)
acond := mcfgv1.NewControllerConfigStatusCondition(mcfgv1.TemplateControllerCompleted, corev1.ConditionTrue, "", reason)
mcfgv1.SetControllerConfigStatusCondition(&cfg.Status, *acond)
rcond := mcfgv1.NewControllerConfigStatusCondition(mcfgv1.TemplateControllerRunning, corev1.ConditionFalse, "", "")
Expand Down
16 changes: 8 additions & 8 deletions pkg/controller/template/template_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func TestCreatesMachineConfigs(t *testing.T) {
}
rcc := cc.DeepCopy()
rcc.Status.ObservedGeneration = 1
rcc.Status.Conditions = []mcfgv1.ControllerConfigStatusCondition{{Type: mcfgv1.TemplateControllerRunning, Status: corev1.ConditionTrue, Message: "syncing towards (1) generation using controller version 0.0.0-was-not-built-properly"}}
rcc.Status.Conditions = []mcfgv1.ControllerConfigStatusCondition{{Type: mcfgv1.TemplateControllerRunning, Status: corev1.ConditionTrue, Message: "syncing towards (1) generation using controller version v0.0.0-was-not-built-properly"}}
f.expectUpdateControllerConfigStatus(rcc)
f.expectGetSecretAction(ps)

Expand All @@ -278,7 +278,7 @@ func TestCreatesMachineConfigs(t *testing.T) {
ccc := cc.DeepCopy()
ccc.Status.ObservedGeneration = 1
ccc.Status.Conditions = []mcfgv1.ControllerConfigStatusCondition{
{Type: mcfgv1.TemplateControllerCompleted, Status: corev1.ConditionTrue, Message: "sync completed towards (1) generation using controller version 0.0.0-was-not-built-properly"},
{Type: mcfgv1.TemplateControllerCompleted, Status: corev1.ConditionTrue, Message: "sync completed towards (1) generation using controller version v0.0.0-was-not-built-properly"},
{Type: mcfgv1.TemplateControllerRunning, Status: corev1.ConditionFalse},
{Type: mcfgv1.TemplateControllerFailing, Status: corev1.ConditionFalse},
}
Expand Down Expand Up @@ -306,7 +306,7 @@ func TestDoNothing(t *testing.T) {

rcc := cc.DeepCopy()
rcc.Status.ObservedGeneration = 1
rcc.Status.Conditions = []mcfgv1.ControllerConfigStatusCondition{{Type: mcfgv1.TemplateControllerRunning, Status: corev1.ConditionTrue, Message: "syncing towards (1) generation using controller version 0.0.0-was-not-built-properly"}}
rcc.Status.Conditions = []mcfgv1.ControllerConfigStatusCondition{{Type: mcfgv1.TemplateControllerRunning, Status: corev1.ConditionTrue, Message: "syncing towards (1) generation using controller version v0.0.0-was-not-built-properly"}}
f.expectUpdateControllerConfigStatus(rcc)
f.expectGetSecretAction(ps)
for idx := range mcs {
Expand All @@ -315,7 +315,7 @@ func TestDoNothing(t *testing.T) {
ccc := cc.DeepCopy()
ccc.Status.ObservedGeneration = 1
ccc.Status.Conditions = []mcfgv1.ControllerConfigStatusCondition{
{Type: mcfgv1.TemplateControllerCompleted, Status: corev1.ConditionTrue, Message: "sync completed towards (1) generation using controller version 0.0.0-was-not-built-properly"},
{Type: mcfgv1.TemplateControllerCompleted, Status: corev1.ConditionTrue, Message: "sync completed towards (1) generation using controller version v0.0.0-was-not-built-properly"},
{Type: mcfgv1.TemplateControllerRunning, Status: corev1.ConditionFalse},
{Type: mcfgv1.TemplateControllerFailing, Status: corev1.ConditionFalse},
}
Expand Down Expand Up @@ -343,7 +343,7 @@ func TestRecreateMachineConfig(t *testing.T) {

rcc := cc.DeepCopy()
rcc.Status.ObservedGeneration = 1
rcc.Status.Conditions = []mcfgv1.ControllerConfigStatusCondition{{Type: mcfgv1.TemplateControllerRunning, Status: corev1.ConditionTrue, Message: "syncing towards (1) generation using controller version 0.0.0-was-not-built-properly"}}
rcc.Status.Conditions = []mcfgv1.ControllerConfigStatusCondition{{Type: mcfgv1.TemplateControllerRunning, Status: corev1.ConditionTrue, Message: "syncing towards (1) generation using controller version v0.0.0-was-not-built-properly"}}
f.expectUpdateControllerConfigStatus(rcc)
f.expectGetSecretAction(ps)

Expand All @@ -354,7 +354,7 @@ func TestRecreateMachineConfig(t *testing.T) {
ccc := cc.DeepCopy()
ccc.Status.ObservedGeneration = 1
ccc.Status.Conditions = []mcfgv1.ControllerConfigStatusCondition{
{Type: mcfgv1.TemplateControllerCompleted, Status: corev1.ConditionTrue, Message: "sync completed towards (1) generation using controller version 0.0.0-was-not-built-properly"},
{Type: mcfgv1.TemplateControllerCompleted, Status: corev1.ConditionTrue, Message: "sync completed towards (1) generation using controller version v0.0.0-was-not-built-properly"},
{Type: mcfgv1.TemplateControllerRunning, Status: corev1.ConditionFalse},
{Type: mcfgv1.TemplateControllerFailing, Status: corev1.ConditionFalse},
}
Expand Down Expand Up @@ -387,7 +387,7 @@ func TestUpdateMachineConfig(t *testing.T) {
}
rcc := cc.DeepCopy()
rcc.Status.ObservedGeneration = 1
rcc.Status.Conditions = []mcfgv1.ControllerConfigStatusCondition{{Type: mcfgv1.TemplateControllerRunning, Status: corev1.ConditionTrue, Message: "syncing towards (1) generation using controller version 0.0.0-was-not-built-properly"}}
rcc.Status.Conditions = []mcfgv1.ControllerConfigStatusCondition{{Type: mcfgv1.TemplateControllerRunning, Status: corev1.ConditionTrue, Message: "syncing towards (1) generation using controller version v0.0.0-was-not-built-properly"}}
f.expectUpdateControllerConfigStatus(rcc)
f.expectGetSecretAction(ps)
for idx := range expmcs {
Expand All @@ -397,7 +397,7 @@ func TestUpdateMachineConfig(t *testing.T) {
ccc := cc.DeepCopy()
ccc.Status.ObservedGeneration = 1
ccc.Status.Conditions = []mcfgv1.ControllerConfigStatusCondition{
{Type: mcfgv1.TemplateControllerCompleted, Status: corev1.ConditionTrue, Message: "sync completed towards (1) generation using controller version 0.0.0-was-not-built-properly"},
{Type: mcfgv1.TemplateControllerCompleted, Status: corev1.ConditionTrue, Message: "sync completed towards (1) generation using controller version v0.0.0-was-not-built-properly"},
{Type: mcfgv1.TemplateControllerRunning, Status: corev1.ConditionFalse},
{Type: mcfgv1.TemplateControllerFailing, Status: corev1.ConditionFalse},
}
Expand Down
6 changes: 0 additions & 6 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package version

import (
"fmt"
"strings"

"github.com/blang/semver"
)

var (
Expand All @@ -15,9 +12,6 @@ var (
// Hash is the git hash we've built the MCO with
Hash = "was-not-built-properly"

// Version is semver representation of the version.
Version = semver.MustParse(strings.TrimLeft(Raw, "v"))

// String is the human-friendly representation of the version.
String = fmt.Sprintf("MachineConfigOperator %s", Raw)
)