Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure: Fix creating cluster when zones are not available for the region #1259

Merged
merged 2 commits into from
Jul 30, 2024

Conversation

@powerkimhub
Copy link
Member

@ish-hcc

@ish-hcc ish-hcc self-assigned this Jul 30, 2024
@ish-hcc
Copy link
Member Author

ish-hcc commented Jul 30, 2024

Fixed merge conflicts. :)

Comment on lines 1345 to 1353
availabilityZones, err := ac.getAvailabilityZones()
if err != nil {
return containerservice.ManagedClusterAgentPoolProfileProperties{}, err
}

var targetZones *[]string = nil
if availabilityZones != nil && len(*availabilityZones) > 0 {
targetZones = &[]string{ac.Region.Zone}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 AzureDirver.go에서 사전에 확인한 Zone 정보(iConn.Region.Zone)를 활용하는 것은 어떨지 검토 부탁드립니다. Azure 드라이버 내 공통적으로 사용되는 내용일 것으로 추정되며, 일관성을 유지할 필요가 있을 것 같습니다.

regionZoneHandler, err := iConn.CreateRegionZoneHandler()
if err != nil {
return nil, err
}
regionZoneInfo, err := regionZoneHandler.GetRegionZone(connectionInfo.RegionInfo.Region)
if err != nil {
return nil, err
}
if len(regionZoneInfo.ZoneList) == 0 {
cblog.Warn("Zone is not available for this region. (" + connectionInfo.RegionInfo.Region + ")")
iConn.Region.Zone = ""
} else {
var zoneFound bool
for _, zone := range regionZoneInfo.ZoneList {
if zone.Name == connectionInfo.RegionInfo.Zone {
zoneFound = true
break
}
}
if !zoneFound {
cblog.Warn("Configured zone is not found in the selected region." +
" (Region: " + connectionInfo.RegionInfo.Region + ", Zone: " + connectionInfo.RegionInfo.Zone + ")")
cblog.Warn("1 will be used as the default zone.")
iConn.Region.Zone = "1"
}
}

Comment on lines 1388 to 1396
availabilityZones, err := ac.getAvailabilityZones()
if err != nil {
return containerservice.ManagedClusterAgentPoolProfile{}, err
}

var targetZones *[]string = nil
if availabilityZones != nil && len(*availabilityZones) > 0 {
targetZones = &[]string{ac.Region.Zone}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

상동

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ac.getAvailabilityZones() 함수는 AvailabilityZone 목록을 가져오는 역할을 수행하고
실제로 zone들이 존재하는지 확인 한 후 0보다 클경우
사전에 Connection 정보에 설정된 Zone을 사용합니다.
이미 말씀 하신 사항대로 구동됩니다.

targetZones = &[]string{ac.Region.Zone}

ac.Region.Zone 부분이 Conneciton 에 설정된 Zone 입니다.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아. 그렇군요.
그렇다면 ac.getAvailabilityZones()를 호출할 필요 없이 ac.Region.Zone 값만 체크하면 되는 건 아닌지요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

생각해보니 그래도 될꺼 같네요. 수정해서 반영하겠습니다

@sykim-etri
Copy link
Member

LGTM

@powerkimhub powerkimhub merged commit fa43539 into cloud-barista:master Jul 30, 2024
3 checks passed
@ish-hcc ish-hcc deleted the cluster_azure branch August 1, 2024 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Azure:PMKS] When availability zone is not supported(WestUS region), it failed to create a kubernetes cluster
3 participants